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

Compare commits

..

1 Commits

Author SHA1 Message Date
kgv
77dba7664c 0030549: Coding - split Image_AlienPixMap into several classes
Image_AlienPixMap has been split into:
- Image_AlienPixMapI defining a general interface for reading/writing images from/to external files.
- Image_FreeImage implementing interface using FreeImage library.
- Image_WinCodec implementing interface using WinCodec library.
- Image_AlienPixMap redirecting to either Image_FreeImage or Image_WinCodec.

New static method Image_AlienPixMap::SetDefaultFactory() allows configuring
an external image library implementing Image_AlienPixMapI interface
to be used by default OCCT image processing routines (texturing, image dumps, etc.).
2019-03-09 14:27:03 +03:00
142 changed files with 5677 additions and 5274 deletions

View File

@@ -1679,43 +1679,6 @@ Some public methods of the class BRepFilletAPI_MakeChamfer are released from exc
- method Add for symmetric chamfer now takes only 2 arguments: distance and edge;
- method GetDistAngle now takes only 3 arguments: index of contour, distance and angle.
@subsection upgrade_740_aspects Aspects unification
Fill Area, Line and Marker aspects (classes *Graphic3d_AspectFillArea3d*, *Graphic3d_AspectLine3d*, *Graphic3d_AspectMarker3d* and *Graphic3d_AspectText3d*)
have been merged into new class *Graphic3d_Aspects* providing a single state for rendering primitives of any type.
The old per-primitive type aspect classes have been preserved as sub-classes of *Graphic3d_Aspects* with default values close to the previous behavior.
All aspects except Graphic3d_AspectFillArea3d define Graphic3d_TOSM_UNLIT shading model.
The previous approach with dedicated aspects per primitive type was handy in simplified case, but lead to confusion otherwise.
In fact, drawing points or lines with lighting applied is a valid use case, but only *Graphic3d_AspectFillArea3d* previously defined necessary material properties.
As aspects for different primitive types have been merged, Graphic3d_Group does no more provide per-type aspect properties.
Existing code relying on old behavior and putting interleaved per-type aspects into single Graphic3d_Group should be updated.
For example, the following pseudo-code will not work anymore, because all *SetGroupPrimitivesAspect* calls will setup the same property:
~~~~
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
aGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect()); //!< overrides previous aspect
Handle(Graphic3d_ArrayOfSegments) aLines = new Graphic3d_ArrayOfSegments (2);
Handle(Graphic3d_ArrayOfTriangles) aTris = new Graphic3d_ArrayOfTriangles (3);
aGroup->AddPrimitiveArray (aLines); //!< both arrays will use the same aspect
aGroup->AddPrimitiveArray (aTris);
~~~~
To solve the problem, the code should be modified to either put primitives into dedicated groups (preferred approach), or using *SetPrimitivesAspect* in proper order:
~~~~
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
Handle(Graphic3d_ArrayOfTriangles) aTris = new Graphic3d_ArrayOfTriangles (3);
aGroup->AddPrimitiveArray (aTris);
Handle(Graphic3d_ArrayOfSegments) aLines = new Graphic3d_ArrayOfSegments (2);
aGroup->SetPrimitivesAspect (myDrawer->LineAspect()->Aspect()); //!< next array will use the new aspect
aGroup->AddPrimitiveArray (aLines);
~~~~
@subsection upgrade_740_interiorstyles Interior styles
* *Aspect_IS_HOLLOW* is now an alias to *Aspect_IS_EMPTY* and does not implicitly enables drawing mesh edges anymore.

View File

@@ -236,18 +236,17 @@ void AIS_CameraFrustum::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
return;
}
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
switch (theMode)
{
case AIS_Shaded:
{
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
aGroup->AddPrimitiveArray (myTriangles);
}
Standard_FALLTHROUGH
case AIS_WireFrame:
{
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
aGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect());
aGroup->AddPrimitiveArray (myBorders);
break;

View File

@@ -232,6 +232,11 @@ void AIS_ColoredShape::SetCustomWidth (const TopoDS_Shape& theShape,
void AIS_ColoredShape::SetColor (const Quantity_Color& theColor)
{
setColor (myDrawer, theColor);
myDrawer->SetColor (theColor);
hasOwnColor = Standard_True;
LoadRecomputable (AIS_WireFrame);
LoadRecomputable (AIS_Shaded);
for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
{
const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
@@ -257,7 +262,6 @@ void AIS_ColoredShape::SetColor (const Quantity_Color& theColor)
aDrawer->FaceBoundaryAspect()->SetColor (theColor);
}
}
AIS_Shape::SetColor (theColor);
}
//=======================================================================
@@ -267,6 +271,10 @@ void AIS_ColoredShape::SetColor (const Quantity_Color& theColor)
void AIS_ColoredShape::SetWidth (const Standard_Real theLineWidth)
{
setWidth (myDrawer, theLineWidth);
myOwnWidth = theLineWidth;
LoadRecomputable (AIS_WireFrame);
LoadRecomputable (AIS_Shaded);
for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
{
const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
@@ -288,16 +296,6 @@ void AIS_ColoredShape::SetWidth (const Standard_Real theLineWidth)
aDrawer->FaceBoundaryAspect()->SetWidth (theLineWidth);
}
}
AIS_Shape::SetWidth (theLineWidth);
}
//=======================================================================
//function : UnsetWidth
//purpose :
//=======================================================================
void AIS_ColoredShape::UnsetWidth()
{
SetWidth (1.0f);
}
//=======================================================================
@@ -307,6 +305,10 @@ void AIS_ColoredShape::UnsetWidth()
void AIS_ColoredShape::SetTransparency (const Standard_Real theValue)
{
setTransparency (myDrawer, theValue);
myDrawer->SetTransparency ((Standard_ShortReal )theValue);
LoadRecomputable (AIS_WireFrame);
LoadRecomputable (AIS_Shaded);
for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
{
const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
@@ -320,7 +322,6 @@ void AIS_ColoredShape::SetTransparency (const Standard_Real theValue)
aDrawer->ShadingAspect()->SetTransparency (theValue, myCurrentFacingModel);
}
}
AIS_Shape::SetTransparency (theValue);
}
//=======================================================================
@@ -329,7 +330,27 @@ void AIS_ColoredShape::SetTransparency (const Standard_Real theValue)
//=======================================================================
void AIS_ColoredShape::UnsetTransparency()
{
SetTransparency (0.0f);
myDrawer->SetTransparency (0.0f);
if (myDrawer->HasOwnShadingAspect())
{
myDrawer->ShadingAspect()->SetTransparency (0.0, myCurrentFacingModel);
if (!HasColor()
&& !HasMaterial()
&& !myDrawer->ShadingAspect()->Aspect()->ToMapTexture())
{
myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
}
}
for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
{
const Handle(Prs3d_Drawer)& aDrawer = anIter.Value();
if (aDrawer->HasOwnShadingAspect())
{
aDrawer->ShadingAspect()->SetTransparency (0.0, myCurrentFacingModel);
}
}
SynchronizeAspects();
}
//=======================================================================
@@ -339,6 +360,10 @@ void AIS_ColoredShape::UnsetTransparency()
void AIS_ColoredShape::SetMaterial (const Graphic3d_MaterialAspect& theMaterial)
{
setMaterial (myDrawer, theMaterial, HasColor(), IsTransparent());
//myOwnMaterial = theMaterial;
hasOwnMaterial = Standard_True;
LoadRecomputable (AIS_Shaded);
for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
{
const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
@@ -348,7 +373,6 @@ void AIS_ColoredShape::SetMaterial (const Graphic3d_MaterialAspect& theMaterial)
setMaterial (aDrawer, theMaterial, aDrawer->HasOwnColor(), aDrawer->HasOwnTransparency());
}
}
AIS_Shape::SetMaterial (theMaterial);
}
//=======================================================================

View File

@@ -81,16 +81,11 @@ public: //! @name global aspects
//! Sets transparency value.
Standard_EXPORT virtual void SetTransparency (const Standard_Real theValue) Standard_OVERRIDE;
//! Sets the material aspect.
Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& theAspect) Standard_OVERRIDE;
public:
//! Removes the setting for transparency in the reconstructed compound shape.
Standard_EXPORT virtual void UnsetTransparency() Standard_OVERRIDE;
//! Setup line width of entire shape.
Standard_EXPORT virtual void UnsetWidth() Standard_OVERRIDE;
//! Sets the material aspect.
Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& theAspect) Standard_OVERRIDE;
protected: //! @name override presentation computation

View File

@@ -431,7 +431,6 @@ void AIS_Dimension::drawText (const Handle(Prs3d_Presentation)& thePresentation,
const TCollection_ExtendedString& theText,
const Standard_Integer theLabelPosition)
{
Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
if (myDrawer->DimensionAspect()->IsText3d())
{
// getting font parameters
@@ -518,7 +517,7 @@ void AIS_Dimension::drawText (const Handle(Prs3d_Presentation)& thePresentation,
aCenterOfLabel.Transform (aTextPlaneTrsf);
gp_Ax2 aFlippingAxes (aCenterOfLabel, GetPlane().Axis().Direction(), aTextDir);
aGroup->SetFlippingOptions (Standard_True, aFlippingAxes);
Prs3d_Root::CurrentGroup (thePresentation)->SetFlippingOptions (Standard_True, aFlippingAxes);
// draw text
if (myDrawer->DimensionAspect()->IsTextShaded())
@@ -547,14 +546,11 @@ void AIS_Dimension::drawText (const Handle(Prs3d_Presentation)& thePresentation,
{
myDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (aColor, Aspect_TOL_SOLID, 1.0));
}
myDrawer->FreeBoundaryAspect()->Aspect()->SetColor (aColor);
// drawing text
if (Handle(Graphic3d_ArrayOfPrimitives) anEdges = StdPrs_WFShape::AddAllEdges (aTextShape, myDrawer))
{
aGroup->SetGroupPrimitivesAspect (myDrawer->FreeBoundaryAspect()->Aspect());
aGroup->AddPrimitiveArray (anEdges);
}
StdPrs_WFShape::Add (thePresentation, aTextShape, myDrawer);
}
Prs3d_Root::CurrentGroup (thePresentation)->SetFlippingOptions (Standard_False, gp_Ax2());
@@ -569,7 +565,7 @@ void AIS_Dimension::drawText (const Handle(Prs3d_Presentation)& thePresentation,
// generate primitives for 2D text
myDrawer->DimensionAspect()->TextAspect()->Aspect()->SetDisplayType (Aspect_TODT_DIMENSION);
Prs3d_Text::Draw (aGroup,
Prs3d_Text::Draw (Prs3d_Root::CurrentGroup (thePresentation),
myDrawer->DimensionAspect()->TextAspect(),
theText,
theTextPos);
@@ -603,7 +599,6 @@ void AIS_Dimension::DrawExtension (const Handle(Prs3d_Presentation)& thePresenta
gp_Pnt aTextPos = ElCLib::Value (theExtensionSize, anExtensionLine);
gp_Dir aTextDir = theExtensionDir;
Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
drawText (thePresentation,
aTextPos,
aTextDir,
@@ -635,17 +630,16 @@ void AIS_Dimension::DrawExtension (const Handle(Prs3d_Presentation)& thePresenta
aSensitiveCurve.Append (anExtStart);
aSensitiveCurve.Append (anExtEnd);
Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
if (!myDrawer->DimensionAspect()->IsText3d() && theMode == ComputeMode_All)
{
aGroup->SetStencilTestOptions (Standard_True);
Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_True);
}
Handle(Graphic3d_AspectLine3d) aDimensionLineStyle = myDrawer->DimensionAspect()->LineAspect()->Aspect();
aGroup->SetPrimitivesAspect (aDimensionLineStyle);
aGroup->AddPrimitiveArray (anExtPrimitive);
Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionLineStyle);
Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (anExtPrimitive);
if (!myDrawer->DimensionAspect()->IsText3d() && theMode == ComputeMode_All)
{
aGroup->SetStencilTestOptions (Standard_False);
Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_False);
}
}
@@ -739,6 +733,8 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
case LabelPosition_HCenter:
{
// add label on dimension or extension line to presentation
Prs3d_Root::NewGroup (thePresentation);
gp_Pnt aTextPos = IsTextPositionCustom() ? myFixedTextPosition
: (aCenterLineBegin.XYZ() + aCenterLineEnd.XYZ()) * 0.5;
gp_Dir aTextDir = aDimensionLine.Direction();
@@ -746,7 +742,6 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
// add text primitives
if (theMode == ComputeMode_All || theMode == ComputeMode_Text)
{
thePresentation->NewGroup();
drawText (thePresentation,
aTextPos,
aTextDir,
@@ -804,28 +799,24 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
aDimensionAspect->TextAspect()->SetVerticalJustification (aTextJustificaton);
// main dimension line, short extension
if (!aDimensionAspect->IsText3d() && theMode == ComputeMode_All)
{
Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
if (!aDimensionAspect->IsText3d() && theMode == ComputeMode_All)
{
aGroup->SetStencilTestOptions (Standard_True);
}
aGroup->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
aGroup->AddPrimitiveArray (aPrimSegments);
if (!aDimensionAspect->IsText3d() && theMode == ComputeMode_All)
{
aGroup->SetStencilTestOptions (Standard_False);
}
Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_True);
}
Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
if (!aDimensionAspect->IsText3d() && theMode == ComputeMode_All)
{
Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_False);
}
// add arrows to presentation
Prs3d_Root::NewGroup (thePresentation);
DrawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir);
if (!theIsOneSide)
{
Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
DrawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir);
if (!theIsOneSide)
{
DrawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir);
}
DrawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir);
}
if (!isArrowsExternal)
@@ -834,18 +825,19 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
}
// add arrow extension lines to presentation
Prs3d_Root::NewGroup (thePresentation);
DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(),
aFirstArrowEnd, aFirstExtensionDir,
THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None);
if (!theIsOneSide)
{
DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(),
aFirstArrowEnd, aFirstExtensionDir,
aSecondArrowEnd, aSecondExtensionDir,
THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None);
if (!theIsOneSide)
{
DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(),
aSecondArrowEnd, aSecondExtensionDir,
THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None);
}
}
}
break;
}
// ------------------------------------------------------------------------ //
@@ -855,48 +847,45 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
case LabelPosition_Left:
{
// add label on dimension or extension line to presentation
{
// Left extension with the text
DrawExtension (thePresentation, anExtensionSize,
isArrowsExternal
? aFirstArrowEnd
: aFirstArrowBegin,
aFirstExtensionDir,
aLabelString,
aLabelWidth,
theMode,
aLabelPosition);
}
Prs3d_Root::NewGroup (thePresentation);
// Left extension with the text
DrawExtension (thePresentation, anExtensionSize,
isArrowsExternal
? aFirstArrowEnd
: aFirstArrowBegin,
aFirstExtensionDir,
aLabelString,
aLabelWidth,
theMode,
aLabelPosition);
// add dimension line primitives
if (theMode == ComputeMode_All || theMode == ComputeMode_Line)
{
// add central dimension line
{
Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
Prs3d_Root::NewGroup (thePresentation);
// add graphical primitives
Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (2);
aPrimSegments->AddVertex (aCenterLineBegin);
aPrimSegments->AddVertex (aCenterLineEnd);
// add graphical primitives
Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (2);
aPrimSegments->AddVertex (aCenterLineBegin);
aPrimSegments->AddVertex (aCenterLineEnd);
aGroup->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
aGroup->AddPrimitiveArray (aPrimSegments);
Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
// add selection primitives
SelectionGeometry::Curve& aSensitiveCurve = mySelectionGeom.NewCurve();
aSensitiveCurve.Append (aCenterLineBegin);
aSensitiveCurve.Append (aCenterLineEnd);
}
// add selection primitives
SelectionGeometry::Curve& aSensitiveCurve = mySelectionGeom.NewCurve();
aSensitiveCurve.Append (aCenterLineBegin);
aSensitiveCurve.Append (aCenterLineEnd);
// add arrows to presentation
Prs3d_Root::NewGroup (thePresentation);
DrawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir);
if (!theIsOneSide)
{
Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
DrawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir);
if (!theIsOneSide)
{
DrawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir);
}
DrawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir);
}
if (!isArrowsExternal || theIsOneSide)
@@ -905,11 +894,11 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
}
// add extension lines for external arrows
{
DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(),
aSecondArrowEnd, aSecondExtensionDir,
THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None);
}
Prs3d_Root::NewGroup (thePresentation);
DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(),
aSecondArrowEnd, aSecondExtensionDir,
THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None);
}
break;
@@ -921,6 +910,7 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
case LabelPosition_Right:
{
// add label on dimension or extension line to presentation
Prs3d_Root::NewGroup (thePresentation);
// Right extension with text
DrawExtension (thePresentation, anExtensionSize,
@@ -935,30 +925,27 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
if (theMode == ComputeMode_All || theMode == ComputeMode_Line)
{
// add central dimension line
{
Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
Prs3d_Root::NewGroup (thePresentation);
// add graphical primitives
Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (2);
aPrimSegments->AddVertex (aCenterLineBegin);
aPrimSegments->AddVertex (aCenterLineEnd);
aGroup->SetGroupPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
aGroup->AddPrimitiveArray (aPrimSegments);
// add graphical primitives
Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (2);
aPrimSegments->AddVertex (aCenterLineBegin);
aPrimSegments->AddVertex (aCenterLineEnd);
Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
// add selection primitives
SelectionGeometry::Curve& aSensitiveCurve = mySelectionGeom.NewCurve();
aSensitiveCurve.Append (aCenterLineBegin);
aSensitiveCurve.Append (aCenterLineEnd);
}
// add selection primitives
SelectionGeometry::Curve& aSensitiveCurve = mySelectionGeom.NewCurve();
aSensitiveCurve.Append (aCenterLineBegin);
aSensitiveCurve.Append (aCenterLineEnd);
// add arrows to presentation
Prs3d_Root::NewGroup (thePresentation);
DrawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir);
if (!theIsOneSide)
{
thePresentation->NewGroup();
DrawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir);
if (!theIsOneSide)
{
DrawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir);
}
DrawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir);
}
if (!isArrowsExternal || theIsOneSide)
@@ -967,11 +954,11 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
}
// add extension lines for external arrows
{
DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(),
aFirstArrowEnd, aFirstExtensionDir,
THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None);
}
Prs3d_Root::NewGroup (thePresentation);
DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(),
aFirstArrowEnd, aFirstExtensionDir,
THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None);
}
break;
@@ -981,7 +968,7 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
// add flyout lines to presentation
if (theMode == ComputeMode_All)
{
Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
Prs3d_Root::NewGroup (thePresentation);
Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments(4);
aPrimSegments->AddVertex (theFirstPoint);
@@ -990,8 +977,8 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
aPrimSegments->AddVertex (theSecondPoint);
aPrimSegments->AddVertex (aLineEndPoint);
aGroup->SetGroupPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
aGroup->AddPrimitiveArray (aPrimSegments);
Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
}
mySelectionGeom.IsComputed = Standard_True;

View File

@@ -198,21 +198,6 @@ public: //! @name highlighting management
const Handle(Prs3d_Drawer)& HighlightStyle (const Prs3d_TypeOfHighlight theStyleType) const { return myStyles[theStyleType]; }
//! Setup highlight style settings.
//! It is preferred modifying existing style returned by method HighlightStyle()
//! instead of creating a new drawer.
//!
//! If a new highlight style is created, its presentation Zlayer should be checked,
//! otherwise highlighting might not work as expected.
//! Default values are:
//! - Prs3d_TypeOfHighlight_Dynamic: Graphic3d_ZLayerId_Top,
//! object highlighting is drawn on top of main scene within Immediate Layers,
//! so that V3d_View::RedrawImmediate() will be enough to see update;
//! - Prs3d_TypeOfHighlight_LocalDynamic: Graphic3d_ZLayerId_Topmost,
//! object parts highlighting is drawn on top of main scene within Immediate Layers
//! with depth cleared (even overlapped geometry will be revealed);
//! - Prs3d_TypeOfHighlight_Selected: Graphic3d_ZLayerId_UNKNOWN,
//! object highlighting is drawn on top of main scene within the same layer
//! as object itself (e.g. Graphic3d_ZLayerId_Default by default) and increased priority.
void SetHighlightStyle (const Prs3d_TypeOfHighlight theStyleType,
const Handle(Prs3d_Drawer)& theStyle) { myStyles[theStyleType] = theStyle; }
@@ -227,14 +212,6 @@ public: //! @name highlighting management
}
//! Setup the style of dynamic highlighting.
//! It is preferred modifying existing style returned by method HighlightStyle()
//! instead of creating a new drawer.
//!
//! If a new highlight style is created, its presentation Zlayer should be checked,
//! otherwise highlighting might not work as expected.
//! Default value is Graphic3d_ZLayerId_Top,
//! object highlighting is drawn on top of main scene within Immediate Layers,
//! so that V3d_View::RedrawImmediate() will be enough to see update;
void SetHighlightStyle (const Handle(Prs3d_Drawer)& theStyle) { myStyles[Prs3d_TypeOfHighlight_Dynamic] = theStyle; }
//! Returns current selection style settings.
@@ -1285,10 +1262,6 @@ protected: //! @name internal methods
return myStyles[!theOwner.IsNull() && theOwner->ComesFromDecomposition() ? Prs3d_TypeOfHighlight_LocalDynamic : Prs3d_TypeOfHighlight_Dynamic];
}
//! Return TRUE if highlight style of owner requires full viewer redraw.
Standard_EXPORT Standard_Boolean isSlowHiStyle (const Handle(SelectMgr_EntityOwner)& theOwner,
const Handle(V3d_Viewer)& theViewer) const;
//! Helper function that returns correct selection style for the object:
//! if custom style is defined via object's highlight drawer, it will be used. Otherwise,
//! selection style of interactive context will be returned.

View File

@@ -293,22 +293,6 @@ void AIS_InteractiveContext::highlightWithSubintensity (const Handle(SelectMgr_E
theOwner->HilightWithColor (myMainPM, myStyles[Prs3d_TypeOfHighlight_SubIntensity], theMode);
}
//=======================================================================
//function : isSlowHiStyle
//purpose :
//=======================================================================
Standard_Boolean AIS_InteractiveContext::isSlowHiStyle (const Handle(SelectMgr_EntityOwner)& theOwner,
const Handle(V3d_Viewer)& theViewer) const
{
if (const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()))
{
const Handle(Prs3d_Drawer)& aHiStyle = getHiStyle (anObj, myLastPicked);
return aHiStyle->ZLayer() == Graphic3d_ZLayerId_UNKNOWN
|| !theViewer->ZLayerSettings (aHiStyle->ZLayer()).IsImmediate();
}
return Standard_False;
}
//=======================================================================
//function : MoveTo
//purpose :
@@ -388,11 +372,6 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th
// method call. As result it is necessary to rehighligt it with mySelectionColor.
if (!myLastPicked.IsNull() && myLastPicked->HasSelectable())
{
if (isSlowHiStyle (myLastPicked, theView->Viewer()))
{
theView->Viewer()->Invalidate();
}
clearDynamicHighlight();
toUpdateViewer = Standard_True;
}
@@ -408,11 +387,6 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th
&& (!myLastPicked->IsSelected()
|| myToHilightSelected))
{
if (isSlowHiStyle (myLastPicked, theView->Viewer()))
{
theView->Viewer()->Invalidate();
}
highlightWithColor (myLastPicked, theView->Viewer());
toUpdateViewer = Standard_True;
}
@@ -431,11 +405,6 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th
&& !myLastPicked.IsNull()
&& myLastPicked->HasSelectable())
{
if (isSlowHiStyle (myLastPicked, theView->Viewer()))
{
theView->Viewer()->Invalidate();
}
clearDynamicHighlight();
toUpdateViewer = Standard_True;
}
@@ -453,14 +422,7 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th
}
else
{
if (theView->IsInvalidated())
{
theView->Viewer()->Redraw();
}
else
{
theView->Viewer()->RedrawImmediate();
}
theView->Viewer()->RedrawImmediate();
}
}

View File

@@ -472,7 +472,33 @@ void AIS_InteractiveObject::SetPolygonOffsets(const Standard_Integer aMode,
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
myDrawer->ShadingAspect()->Aspect()->SetPolygonOffsets( aMode, aFactor, aUnits );
SynchronizeAspects();
// Modify existing presentations
for (Standard_Integer aPrsIter = 1, n = myPresentations.Length(); aPrsIter <= n; ++aPrsIter)
{
const Handle(PrsMgr_Presentation)& aPrs3d = myPresentations (aPrsIter).Presentation();
if ( !aPrs3d.IsNull() ) {
const Handle(Graphic3d_Structure)& aStruct = aPrs3d->Presentation();
if( !aStruct.IsNull() ) {
// Workaround for issue 23115: Need to update also groups, because their
// face aspect ALWAYS overrides the structure's.
const Graphic3d_SequenceOfGroup& aGroups = aStruct->Groups();
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aGroups); aGroupIter.More(); aGroupIter.Next())
{
Handle(Graphic3d_Group)& aGrp = aGroupIter.ChangeValue();
if (aGrp.IsNull()
|| !aGrp->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
{
continue;
}
Handle(Graphic3d_AspectFillArea3d) aFaceAsp = aGrp->FillAreaAspect();
aFaceAsp->SetPolygonOffsets(aMode, aFactor, aUnits);
aGrp->SetGroupPrimitivesAspect(aFaceAsp);
}
}
}
}
}
//=======================================================================
@@ -596,33 +622,3 @@ void AIS_InteractiveObject::SynchronizeAspects()
}
}
}
//=======================================================================
//function : replaceAspects
//purpose :
//=======================================================================
void AIS_InteractiveObject::replaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap)
{
if (theMap.IsEmpty())
{
return;
}
for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
{
const Handle(PrsMgr_Presentation)& aPrs3d = aPrsIter.ChangeValue().Presentation();
if (aPrs3d.IsNull()
|| aPrs3d->Presentation().IsNull())
{
continue;
}
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aPrs3d->Presentation()->Groups()); aGroupIter.More(); aGroupIter.Next())
{
if (!aGroupIter.Value().IsNull())
{
aGroupIter.ChangeValue()->ReplaceAspects (theMap);
}
}
}
}

View File

@@ -386,15 +386,6 @@ public:
//! so that modifications will take effect on already computed presentation groups (thus avoiding re-displaying the object).
Standard_EXPORT void SynchronizeAspects();
protected:
//! Replace aspects of existing (computed) presentation groups,
//! so that the new aspects can be applied without recomputing presentation.
//! It is NOT recommended approach, because user has to fill such map and then search for each occurrence in computed groups.
//! The recommended approach is computing presentation with necessary customized aspects,
//! and then modify them directly followed by SynchronizeAspects() call.
Standard_EXPORT void replaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap);
private:
Standard_EXPORT virtual Standard_Boolean RecomputeEveryPrs() const;

View File

@@ -26,7 +26,6 @@
#include <Prs3d_Root.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <Prs3d_ToolDisk.hxx>
#include <Prs3d_ToolSector.hxx>
#include <Prs3d_ToolSphere.hxx>
#include <Select3D_SensitiveCircle.hxx>
#include <Select3D_SensitivePoint.hxx>
@@ -152,19 +151,6 @@ void AIS_Manipulator::init()
myHighlightAspect->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
myHighlightAspect->SetMaterial (aHilightMaterial);
Graphic3d_MaterialAspect aDraggerMaterial;
aDraggerMaterial.SetReflectionModeOff(Graphic3d_TOR_DIFFUSE);
aDraggerMaterial.SetReflectionModeOff(Graphic3d_TOR_SPECULAR);
aDraggerMaterial.SetReflectionModeOff(Graphic3d_TOR_EMISSION);
aDraggerMaterial.SetMaterialType(Graphic3d_MATERIAL_ASPECT);
aDraggerMaterial.SetAmbient(1.0);
myDraggerHighlight = new Prs3d_ShadingAspect();
myDraggerHighlight->Aspect()->SetInteriorStyle(Aspect_IS_SOLID);
myDraggerHighlight->SetMaterial(aDraggerMaterial);
myDraggerHighlight->SetTransparency(0.5);
SetSize (100);
SetZLayer (Graphic3d_ZLayerId_Topmost);
}
@@ -184,11 +170,10 @@ Handle(Prs3d_Presentation) AIS_Manipulator::getHighlightPresentation (const Hand
switch (anOwner->Mode())
{
case AIS_MM_Translation : return myAxes[anOwner->Index()].TranslatorHighlightPrs();
case AIS_MM_Rotation : return myAxes[anOwner->Index()].RotatorHighlightPrs();
case AIS_MM_Scaling : return myAxes[anOwner->Index()].ScalerHighlightPrs();
case AIS_MM_TranslationPlane: return myAxes[anOwner->Index()].DraggerHighlightPrs();
case AIS_MM_None : break;
case AIS_MM_Translation: return myAxes[anOwner->Index()].TranslatorHighlightPrs();
case AIS_MM_Rotation : return myAxes[anOwner->Index()].RotatorHighlightPrs();
case AIS_MM_Scaling : return myAxes[anOwner->Index()].ScalerHighlightPrs();
case AIS_MM_None : break;
}
return aDummyPrs;
@@ -209,11 +194,10 @@ Handle(Graphic3d_Group) AIS_Manipulator::getGroup (const Standard_Integer theInd
switch (theMode)
{
case AIS_MM_Translation : return myAxes[theIndex].TranslatorGroup();
case AIS_MM_Rotation : return myAxes[theIndex].RotatorGroup();
case AIS_MM_Scaling : return myAxes[theIndex].ScalerGroup();
case AIS_MM_TranslationPlane: return myAxes[theIndex].DraggerGroup();
case AIS_MM_None : break;
case AIS_MM_Translation: return myAxes[theIndex].TranslatorGroup();
case AIS_MM_Rotation : return myAxes[theIndex].RotatorGroup();
case AIS_MM_Scaling : return myAxes[theIndex].ScalerGroup();
case AIS_MM_None : break;
}
return aDummyGroup;
@@ -282,10 +266,6 @@ void AIS_Manipulator::SetPart (const Standard_Integer theAxisIndex, const AIS_Ma
myAxes[theAxisIndex].SetScaling (theIsEnabled);
break;
case AIS_MM_TranslationPlane:
myAxes[theAxisIndex].SetDragging(theIsEnabled);
break;
case AIS_MM_None:
break;
}
@@ -297,7 +277,7 @@ void AIS_Manipulator::SetPart (const Standard_Integer theAxisIndex, const AIS_Ma
//=======================================================================
void AIS_Manipulator::SetPart (const AIS_ManipulatorMode theMode, const Standard_Boolean theIsEnabled)
{
for (Standard_Integer anIt = 0; anIt < 4; ++anIt)
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{
SetPart (anIt, theMode, theIsEnabled);
}
@@ -420,7 +400,6 @@ void AIS_Manipulator::Attach (const Handle(AIS_ManipulatorObjectSequence)& theOb
EnableMode (AIS_MM_Rotation);
EnableMode (AIS_MM_Translation);
EnableMode (AIS_MM_Scaling);
EnableMode (AIS_MM_TranslationPlane);
}
}
@@ -607,34 +586,6 @@ Standard_Boolean AIS_Manipulator::ObjectTransformation (const Standard_Integer t
myPrevState = anAngle;
return Standard_True;
}
case AIS_MM_TranslationPlane:
{
const gp_Pnt aPosLoc = myStartPosition.Location();
const gp_Ax1 aCurrAxis = getAx1FromAx2Dir(myStartPosition, myCurrentIndex);
IntAna_IntConicQuad aIntersector(anInputLine, gp_Pln(aPosLoc, aCurrAxis.Direction()), Precision::Angular(), Precision::Intersection());
if (!aIntersector.IsDone() || aIntersector.NbPoints() < 1)
{
return Standard_False;
}
const gp_Pnt aNewPosition = aIntersector.Point(1);
if (!myHasStartedTransformation)
{
myStartPick = aNewPosition;
myHasStartedTransformation = Standard_True;
return Standard_True;
}
if (aNewPosition.Distance(myStartPick) < Precision::Confusion())
{
return Standard_False;
}
gp_Trsf aNewTrsf;
aNewTrsf.SetTranslation(gp_Vec(myStartPick, aNewPosition));
theTrsf *= aNewTrsf;
return Standard_True;
}
case AIS_MM_None:
{
return Standard_False;
@@ -706,9 +657,8 @@ void AIS_Manipulator::Transform (const gp_Trsf& theTrsf)
}
}
if ((myCurrentMode == AIS_MM_Translation && myBehaviorOnTransform.FollowTranslation)
|| (myCurrentMode == AIS_MM_Rotation && myBehaviorOnTransform.FollowRotation)
|| (myCurrentMode == AIS_MM_TranslationPlane && myBehaviorOnTransform.FollowDragging))
if ((myCurrentMode == AIS_MM_Translation && myBehaviorOnTransform.FollowTranslation)
|| (myCurrentMode == AIS_MM_Rotation && myBehaviorOnTransform.FollowRotation))
{
gp_Pnt aPos = myStartPosition.Location().Transformed (theTrsf);
gp_Dir aVDir = myStartPosition.Direction().Transformed (theTrsf);
@@ -836,13 +786,8 @@ void AIS_Manipulator::DeactivateCurrentMode()
Handle(Prs3d_ShadingAspect) anAspect = new Prs3d_ShadingAspect();
anAspect->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
anAspect->SetMaterial (myDrawer->ShadingAspect()->Material());
if (myCurrentMode == AIS_MM_TranslationPlane)
anAspect->SetTransparency(1.0);
else
{
anAspect->SetTransparency(myDrawer->ShadingAspect()->Transparency());
anAspect->SetColor(myAxes[myCurrentIndex].Color());
}
anAspect->SetTransparency (myDrawer->ShadingAspect()->Transparency());
anAspect->SetColor (myAxes[myCurrentIndex].Color());
aGroup->SetGroupPrimitivesAspect (anAspect->Aspect());
}
@@ -937,14 +882,14 @@ void AIS_Manipulator::Compute (const Handle(PrsMgr_PresentationManager3d)& thePr
// Display center
myCenter.Init (myAxes[0].AxisRadius() * 2.0f, gp::Origin());
aGroup = thePrs->NewGroup ();
aGroup = Prs3d_Root::NewGroup (thePrs);
aGroup->SetPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
aGroup->AddPrimitiveArray (myCenter.Array());
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{
// Display axes
aGroup = thePrs->NewGroup ();
aGroup = Prs3d_Root::NewGroup (thePrs);
Handle(Prs3d_ShadingAspect) anAspectAx = new Prs3d_ShadingAspect (new Graphic3d_AspectFillArea3d(*anAspect->Aspect()));
anAspectAx->SetColor (myAxes[anIt].Color());
@@ -987,13 +932,7 @@ void AIS_Manipulator::HilightSelected (const Handle(PrsMgr_PresentationManager3d
return;
}
if (anOwner->Mode() == AIS_MM_TranslationPlane)
{
myDraggerHighlight->SetColor(myAxes[anOwner->Index()].Color());
aGroup->SetGroupPrimitivesAspect(myDraggerHighlight->Aspect());
}
else
aGroup->SetGroupPrimitivesAspect(myHighlightAspect->Aspect());
aGroup->SetGroupPrimitivesAspect (myHighlightAspect->Aspect());
myCurrentIndex = anOwner->Index();
myCurrentMode = anOwner->Mode();
@@ -1022,20 +961,13 @@ void AIS_Manipulator::HilightOwnerWithColor (const Handle(PrsMgr_PresentationMan
{
return;
}
if (anOwner->Mode() == AIS_MM_TranslationPlane)
{
Handle(Prs3d_Drawer) aStyle = new Prs3d_Drawer();
aStyle->SetColor(myAxes[anOwner->Index()].Color());
aStyle->SetTransparency(0.5);
aPresentation->Highlight(aStyle);
}
else
aPresentation->Highlight(theStyle);
aPresentation->Highlight (theStyle);
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aPresentation->Groups());
aGroupIter.More(); aGroupIter.Next())
{
Handle(Graphic3d_Group)& aGrp = aGroupIter.ChangeValue();
if (!aGrp.IsNull())
if (!aGrp.IsNull()
&& aGrp->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
{
aGrp->SetGroupPrimitivesAspect (myHighlightAspect->Aspect());
}
@@ -1144,38 +1076,6 @@ void AIS_Manipulator::ComputeSelection (const Handle(SelectMgr_Selection)& theSe
theSelection->Add (aTri);
}
}
if (aMode == AIS_MM_TranslationPlane || aMode == AIS_MM_None)
{
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{
if (!myAxes[anIt].HasDragging())
{
continue;
}
if (aMode != AIS_MM_None)
{
anOwner = new AIS_ManipulatorOwner(this, anIt, AIS_MM_TranslationPlane, 9);
}
// define sensitivity by two crossed lines
gp_Pnt aP1, aP2;
aP1 = myAxes[((anIt + 1) % 3)].TranslatorTipPosition();
aP2 = myAxes[((anIt + 2) % 3)].TranslatorTipPosition();
gp_XYZ aMidP = (aP1.XYZ() + aP2.XYZ()) / 2.0;
Handle(Select3D_SensitiveSegment) aLine1 = new Select3D_SensitiveSegment(anOwner, aP1, aP2);
aLine1->SetSensitivityFactor(10);
theSelection->Add(aLine1);
Handle(Select3D_SensitiveSegment) aLine2 = new Select3D_SensitiveSegment(anOwner, gp::Origin(), aMidP);
aLine2->SetSensitivityFactor(10);
theSelection->Add(aLine2);
// enlarge sensitivity by triangulation
Handle(Select3D_SensitiveTriangulation) aTri = new Select3D_SensitiveTriangulation(anOwner, myAxes[anIt].DraggerSector().Triangulation(), TopLoc_Location(), Standard_True);
theSelection->Add(aTri);
}
}
}
//=======================================================================
@@ -1291,24 +1191,6 @@ void AIS_Manipulator::Cube::addTriangle (const Standard_Integer theIndex,
myArray->AddVertex (theP3, theNormal);
}
//=======================================================================
//class : Sector
//function : Init
//purpose :
//=======================================================================
void AIS_Manipulator::Sector::Init (const Standard_ShortReal theRadius,
const gp_Ax1& thePosition,
const gp_Dir& theXDirection,
const Standard_Integer theSlicesNb,
const Standard_Integer theStacksNb)
{
Prs3d_ToolSector aTool(theRadius, theSlicesNb, theStacksNb);
gp_Ax3 aSystem(thePosition.Location(), thePosition.Direction(), theXDirection);
gp_Trsf aTrsf;
aTrsf.SetTransformation(aSystem, gp_Ax3());
aTool.FillArray(myArray, myTriangulation, aTrsf);
}
//=======================================================================
//class : Axis
//function : Constructor
@@ -1329,7 +1211,6 @@ AIS_Manipulator::Axis::Axis (const gp_Ax1& theAxis,
myInnerRadius (myLength + myBoxSize),
myDiskThickness (myBoxSize * 0.5f),
myIndent (0.2f),
myHasDragging(Standard_True),
myFacettesNumber (20),
myCircleRadius (myLength + myBoxSize + myBoxSize * 0.5f * 0.5f)
{
@@ -1358,7 +1239,7 @@ void AIS_Manipulator::Axis::Compute (const Handle(PrsMgr_PresentationManager)& t
myAxisRadius * 1.5,
anArrowLength,
myFacettesNumber);
myTranslatorGroup = thePrs->NewGroup ();
myTranslatorGroup = Prs3d_Root::NewGroup (thePrs);
myTranslatorGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
myTranslatorGroup->AddPrimitiveArray (myTriangleArray);
@@ -1382,7 +1263,7 @@ void AIS_Manipulator::Axis::Compute (const Handle(PrsMgr_PresentationManager)& t
myCubePos = myReferenceAxis.Direction().XYZ() * (myLength + myIndent);
myCube.Init (gp_Ax1 (myCubePos, myReferenceAxis.Direction()), myBoxSize);
myScalerGroup = thePrs->NewGroup ();
myScalerGroup = Prs3d_Root::NewGroup (thePrs);
myScalerGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
myScalerGroup->AddPrimitiveArray (myCube.Array());
@@ -1405,7 +1286,7 @@ void AIS_Manipulator::Axis::Compute (const Handle(PrsMgr_PresentationManager)& t
{
myCircleRadius = myInnerRadius + myIndent * 2 + myDiskThickness * 0.5f;
myCircle.Init (myInnerRadius + myIndent * 2, myInnerRadius + myDiskThickness + myIndent * 2, gp_Ax1(gp::Origin(), myReferenceAxis.Direction()), myFacettesNumber * 2);
myRotatorGroup = thePrs->NewGroup ();
myRotatorGroup = Prs3d_Root::NewGroup (thePrs);
myRotatorGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
myRotatorGroup->AddPrimitiveArray (myCircle.Array());
@@ -1423,36 +1304,4 @@ void AIS_Manipulator::Axis::Compute (const Handle(PrsMgr_PresentationManager)& t
aGroup->AddPrimitiveArray (myCircle.Array());
}
}
if (myHasDragging)
{
gp_Dir aXDirection;
if (myReferenceAxis.Direction().X() > 0)
aXDirection = gp::DY();
else if (myReferenceAxis.Direction().Y() > 0)
aXDirection = gp::DZ();
else
aXDirection = gp::DX();
mySector.Init(myInnerRadius + myIndent * 2, gp_Ax1(gp::Origin(), myReferenceAxis.Direction()), aXDirection, myFacettesNumber * 2);
myDraggerGroup = thePrs->NewGroup();
Handle(Graphic3d_AspectFillArea3d) aFillArea = new Graphic3d_AspectFillArea3d();
myDraggerGroup->SetGroupPrimitivesAspect(aFillArea);
myDraggerGroup->AddPrimitiveArray(mySector.Array());
if (myHighlightDragger.IsNull())
{
myHighlightDragger = new Prs3d_Presentation(thePrsMgr->StructureManager());
}
else
{
myHighlightDragger->Clear();
}
{
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(myHighlightDragger);
aGroup->SetGroupPrimitivesAspect(aFillArea);
aGroup->AddPrimitiveArray(mySector.Array());
}
}
}

View File

@@ -280,14 +280,12 @@ public:
//! - FollowRotation - whether the manipulator will be rotated together with an object.
struct BehaviorOnTransform {
BehaviorOnTransform() : FollowTranslation (Standard_True), FollowRotation (Standard_True), FollowDragging (Standard_True) {}
BehaviorOnTransform() : FollowTranslation (Standard_True), FollowRotation (Standard_True) {}
BehaviorOnTransform& SetFollowTranslation (const Standard_Boolean theApply) { FollowTranslation = theApply; return *this; }
BehaviorOnTransform& SetFollowRotation (const Standard_Boolean theApply) { FollowRotation = theApply; return *this; }
BehaviorOnTransform& SetFollowDragging (const Standard_Boolean theApply) { FollowDragging = theApply; return *this; }
Standard_Boolean FollowTranslation;
Standard_Boolean FollowRotation;
Standard_Boolean FollowDragging;
};
//! Sets behavior settings for transformation action carried on the manipulator,
@@ -448,29 +446,6 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
Handle(Graphic3d_ArrayOfTriangles) myArray;
};
class Sector : public Quadric
{
public:
Sector()
: Quadric(),
myRadius(0.0f)
{ }
~Sector() { }
void Init(const Standard_ShortReal theRadius,
const gp_Ax1& thePosition,
const gp_Dir& theXDirection,
const Standard_Integer theSlicesNb = 5,
const Standard_Integer theStacksNb = 5);
protected:
gp_Ax1 myPosition;
Standard_ShortReal myRadius;
};
//! The class describes on axis sub-object.
//! It includes sub-objects itself:
//! -rotator
@@ -510,11 +485,6 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
{
myHighlightRotator->SetTransformPersistence (theTrsfPers);
}
if (!myHighlightDragger.IsNull())
{
myHighlightDragger->SetTransformPersistence(theTrsfPers);
}
}
void Transform (const Handle(Geom_Transformation)& theTransformation)
@@ -533,11 +503,6 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
{
myHighlightRotator->SetTransformation (theTransformation);
}
if (!myHighlightDragger.IsNull())
{
myHighlightDragger->SetTransformation(theTransformation);
}
}
Standard_Boolean HasTranslation() const { return myHasTranslation; }
@@ -546,16 +511,12 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
Standard_Boolean HasScaling() const { return myHasScaling; }
Standard_Boolean HasDragging() const { return myHasDragging; }
void SetTranslation (const Standard_Boolean theIsEnabled) { myHasTranslation = theIsEnabled; }
void SetRotation (const Standard_Boolean theIsEnabled) { myHasRotation = theIsEnabled; }
void SetScaling (const Standard_Boolean theIsEnabled) { myHasScaling = theIsEnabled; }
void SetDragging(const Standard_Boolean theIsEnabled) { myHasDragging = theIsEnabled; }
Quantity_Color Color() const { return myColor; }
Standard_ShortReal AxisLength() const { return myLength; }
@@ -570,16 +531,12 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
const Handle(Prs3d_Presentation)& ScalerHighlightPrs() const { return myHighlightScaler; }
const Handle(Prs3d_Presentation)& DraggerHighlightPrs() const { return myHighlightDragger; }
const Handle(Graphic3d_Group)& TranslatorGroup() const { return myTranslatorGroup; }
const Handle(Graphic3d_Group)& RotatorGroup() const { return myRotatorGroup; }
const Handle(Graphic3d_Group)& ScalerGroup() const { return myScalerGroup; }
const Handle(Graphic3d_Group)& DraggerGroup() const { return myDraggerGroup; }
const Handle(Graphic3d_ArrayOfTriangles)& TriangleArray() const { return myTriangleArray; }
void SetIndent (const Standard_ShortReal theValue) { myIndent = theValue; }
@@ -613,7 +570,6 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
public:
const gp_Pnt& TranslatorTipPosition() const { return myArrowTipPos; }
const Sector& DraggerSector() const { return mySector; }
const Disk& RotatorDisk() const { return myCircle; }
float RotatorDiskRadius() const { return myCircleRadius; }
const Cube& ScalerCube() const { return myCube; }
@@ -637,14 +593,11 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
Standard_ShortReal myDiskThickness;
Standard_ShortReal myIndent; //!< Gap between visual part of the manipulator.
Standard_Boolean myHasDragging;
protected:
Standard_Integer myFacettesNumber;
gp_Pnt myArrowTipPos;
Sector mySector;
Disk myCircle;
float myCircleRadius;
Cube myCube;
@@ -653,12 +606,10 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
Handle(Graphic3d_Group) myTranslatorGroup;
Handle(Graphic3d_Group) myScalerGroup;
Handle(Graphic3d_Group) myRotatorGroup;
Handle(Graphic3d_Group) myDraggerGroup;
Handle(Prs3d_Presentation) myHighlightTranslator;
Handle(Prs3d_Presentation) myHighlightScaler;
Handle(Prs3d_Presentation) myHighlightRotator;
Handle(Prs3d_Presentation) myHighlightDragger;
Handle(Graphic3d_ArrayOfTriangles) myTriangleArray;
@@ -687,9 +638,6 @@ protected: //! @name Fields for interactive transformation. Fields only for inte
//! Aspect used to color current detected part and current selected part.
Handle(Prs3d_ShadingAspect) myHighlightAspect;
//! Aspect used to color sector part when it's selected.
Handle(Prs3d_ShadingAspect) myDraggerHighlight;
public:
DEFINE_STANDARD_RTTIEXT(AIS_Manipulator, AIS_InteractiveObject)

View File

@@ -22,8 +22,7 @@ enum AIS_ManipulatorMode
AIS_MM_None = 0,
AIS_MM_Translation = 1,
AIS_MM_Rotation,
AIS_MM_Scaling,
AIS_MM_TranslationPlane
AIS_MM_Scaling
};
#endif

View File

@@ -173,8 +173,8 @@ void AIS_PointCloudOwner::Clear (const Handle(PrsMgr_PresentationManager)& thePr
//==================================================
AIS_PointCloud::AIS_PointCloud()
{
myDrawer->SetupOwnShadingAspect();
myDrawer->ShadingAspect()->Aspect()->SetMarkerType (Aspect_TOM_POINT);
// override default point style to Aspect_TOM_POINT
myDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, Quantity_NOC_YELLOW, 1.0));
SetDisplayMode (AIS_PointCloud::DM_Points);
SetHilightMode (AIS_PointCloud::DM_BndBox);
@@ -282,8 +282,52 @@ void AIS_PointCloud::SetColor (const Quantity_Color& theColor)
{
AIS_InteractiveObject::SetColor(theColor);
if (!myDrawer->HasOwnPointAspect())
{
myDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, theColor, 1.0));
if (myDrawer->HasLink())
{
*myDrawer->PointAspect()->Aspect() = *myDrawer->Link()->PointAspect()->Aspect();
}
}
if (!myDrawer->HasOwnShadingAspect())
{
myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
if (myDrawer->HasLink())
{
*myDrawer->ShadingAspect()->Aspect() = *myDrawer->Link()->ShadingAspect()->Aspect();
}
}
// Override color
myDrawer->ShadingAspect()->SetColor (theColor);
SynchronizeAspects();
myDrawer->PointAspect() ->SetColor (theColor);
const PrsMgr_Presentations& aPrsList = Presentations();
Handle(Graphic3d_AspectMarker3d) aPointAspect = myDrawer->PointAspect()->Aspect();
Handle(Graphic3d_AspectFillArea3d) anAreaAspect = myDrawer->ShadingAspect()->Aspect();
for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
{
const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
if (aPrsModed.Mode() != AIS_PointCloud::DM_Points)
{
continue;
}
const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
{
const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_MARKER))
{
aGroup->SetGroupPrimitivesAspect (aPointAspect);
}
if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
{
aGroup->SetGroupPrimitivesAspect (anAreaAspect);
}
}
}
}
//=======================================================================
@@ -298,20 +342,34 @@ void AIS_PointCloud::UnsetColor()
}
AIS_InteractiveObject::UnsetColor();
if (!HasWidth())
{
myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)());
}
else
{
myDrawer->PointAspect()->SetColor (myDrawer->HasLink()
? myDrawer->Link()->PointAspect()->Aspect()->Color()
: Quantity_Color (Quantity_NOC_YELLOW));
}
if (HasMaterial()
|| IsTransparent())
{
Graphic3d_MaterialAspect aDefaultMat (Graphic3d_NOM_BRASS);
Graphic3d_MaterialAspect aMat = aDefaultMat;
Quantity_Color aColor = aDefaultMat.Color();
if (myDrawer->HasLink())
{
aColor = myDrawer->Link()->ShadingAspect()->Color (myCurrentFacingModel);
}
if (HasMaterial() || myDrawer->HasLink())
{
aMat = AIS_GraphicTool::GetMaterial (HasMaterial() ? myDrawer : myDrawer->Link());
}
if (HasMaterial())
{
Quantity_Color aColor = aDefaultMat.AmbientColor();
if (myDrawer->HasLink())
{
aColor = myDrawer->Link()->ShadingAspect()->Color (myCurrentFacingModel);
}
aMat.SetColor (aColor);
}
if (IsTransparent())
@@ -320,10 +378,43 @@ void AIS_PointCloud::UnsetColor()
aMat.SetTransparency (Standard_ShortReal(aTransp));
}
myDrawer->ShadingAspect()->SetMaterial (aMat, myCurrentFacingModel);
myDrawer->ShadingAspect()->Aspect()->SetInteriorColor (aColor);
}
else
{
myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
}
myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)());
SynchronizeAspects();
// modify shading presentation without re-computation
const PrsMgr_Presentations& aPrsList = Presentations();
Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->Link()->ShadingAspect()->Aspect();
Handle(Graphic3d_AspectMarker3d) aMarkerAsp = myDrawer->Link()->PointAspect()->Aspect();
for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
{
const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
if (aPrsModed.Mode() != AIS_PointCloud::DM_Points)
{
continue;
}
const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
{
const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
// Check if aspect of given type is set for the group,
// because setting aspect for group with no already set aspect
// can lead to loss of presentation data
if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
{
aGroup->SetGroupPrimitivesAspect (anAreaAsp);
}
if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_MARKER))
{
aGroup->SetGroupPrimitivesAspect (aMarkerAsp);
}
}
}
}
//=======================================================================
@@ -332,6 +423,14 @@ void AIS_PointCloud::UnsetColor()
//=======================================================================
void AIS_PointCloud::SetMaterial (const Graphic3d_MaterialAspect& theMat)
{
if (!myDrawer->HasOwnShadingAspect())
{
myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
if (myDrawer->HasLink())
{
*myDrawer->ShadingAspect()->Aspect() = *myDrawer->Link()->ShadingAspect()->Aspect();
}
}
hasOwnMaterial = Standard_True;
myDrawer->ShadingAspect()->SetMaterial (theMat, myCurrentFacingModel);
@@ -340,7 +439,28 @@ void AIS_PointCloud::SetMaterial (const Graphic3d_MaterialAspect& theMat)
myDrawer->ShadingAspect()->SetColor (myDrawer->Color(), myCurrentFacingModel);
}
myDrawer->ShadingAspect()->SetTransparency (myDrawer->Transparency(), myCurrentFacingModel);
SynchronizeAspects();
// modify shading presentation without re-computation
const PrsMgr_Presentations& aPrsList = Presentations();
Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
{
const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
if (aPrsModed.Mode() != AIS_PointCloud::DM_Points)
{
continue;
}
const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
{
const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
{
aGroup->SetGroupPrimitivesAspect (anAreaAsp);
}
}
}
}
//=======================================================================
@@ -354,6 +474,8 @@ void AIS_PointCloud::UnsetMaterial()
return;
}
if (HasColor()
|| IsTransparent())
{
Graphic3d_MaterialAspect aDefaultMat (Graphic3d_NOM_BRASS);
myDrawer->ShadingAspect()->SetMaterial (myDrawer->HasLink() ?
@@ -366,8 +488,33 @@ void AIS_PointCloud::UnsetMaterial()
myDrawer->ShadingAspect()->SetTransparency (myDrawer->Transparency(), myCurrentFacingModel);
}
}
else
{
myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
}
hasOwnMaterial = Standard_False;
SynchronizeAspects();
// modify shading presentation without re-computation
const PrsMgr_Presentations& aPrsList = Presentations();
Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
{
const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
if (aPrsModed.Mode() != AIS_PointCloud::DM_Points)
{
continue;
}
const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
{
const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
{
aGroup->SetGroupPrimitivesAspect (anAreaAsp);
}
}
}
}
//=======================================================================
@@ -388,7 +535,8 @@ void AIS_PointCloud::Compute (const Handle(PrsMgr_PresentationManager3d)& /*theP
return;
}
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePrs);
aGroup->SetGroupPrimitivesAspect (myDrawer->PointAspect()->Aspect());
aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
aGroup->AddPrimitiveArray (aPoints);
break;

View File

@@ -28,7 +28,6 @@
#include <Geom_Line.hxx>
#include <Geom_Plane.hxx>
#include <Geom_Surface.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
#include <gp_Circ.hxx>
#include <gp_Lin.hxx>
#include <gp_Pnt.hxx>
@@ -185,13 +184,8 @@ void AIS_Relation::ComputeProjVertexPresentation(const Handle(Prs3d_Presentation
pa->SetTypeOfMarker(aProjTOM);
}
{
Handle(Graphic3d_Group) aGroup = aPrs->NewGroup();
Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
anArrayOfPoints->AddVertex (ProjPoint);
aGroup->SetGroupPrimitivesAspect (myDrawer->PointAspect()->Aspect());
aGroup->AddPrimitiveArray (anArrayOfPoints);
}
// calcul du projete
StdPrs_Point::Add(aPrs, new Geom_CartesianPoint(ProjPoint), myDrawer);
if (!myDrawer->HasOwnWireAspect()){
myDrawer->SetWireAspect(new Prs3d_LineAspect(aColor,aCallTOL,2.));}
@@ -203,14 +197,10 @@ void AIS_Relation::ComputeProjVertexPresentation(const Handle(Prs3d_Presentation
}
// Si les points ne sont pas confondus...
if (!ProjPoint.IsEqual (BRep_Tool::Pnt(aVertex),Precision::Confusion()))
{
Handle(Graphic3d_Group) aGroup = aPrs->NewGroup();
Handle(Graphic3d_ArrayOfSegments) anArrayOfLines = new Graphic3d_ArrayOfSegments (2);
anArrayOfLines->AddVertex (ProjPoint);
anArrayOfLines->AddVertex (BRep_Tool::Pnt(aVertex));
aGroup->SetGroupPrimitivesAspect (myDrawer->WireAspect()->Aspect());
aGroup->AddPrimitiveArray (anArrayOfLines);
if (!ProjPoint.IsEqual (BRep_Tool::Pnt(aVertex),Precision::Confusion())) {
// calcul des lignes de rappel
BRepBuilderAPI_MakeEdge MakEd (ProjPoint,BRep_Tool::Pnt(aVertex));
StdPrs_WFShape::Add (aPrs, MakEd.Edge(), myDrawer);
}
}

View File

@@ -392,12 +392,13 @@ void AIS_RubberBand::Compute (const Handle(PrsMgr_PresentationManager3d)& /*theP
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer /*theMode*/)
{
Handle (Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
// Draw filling
if (IsFilling() && fillTriangles())
{
Handle(Graphic3d_Group) aGroup1 = thePresentation->NewGroup();
aGroup1->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
aGroup1->AddPrimitiveArray (myTriangles);
aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
aGroup->AddPrimitiveArray (myTriangles);
}
// Draw frame
@@ -432,7 +433,6 @@ void AIS_RubberBand::Compute (const Handle(PrsMgr_PresentationManager3d)& /*theP
}
}
Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
aGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect());
aGroup->AddPrimitiveArray (myBorders);
}

View File

@@ -77,40 +77,6 @@ static Standard_Boolean IsInList(const TColStd_ListOfInteger& LL, const Standard
return Standard_False;
}
// Auxiliary macros
#define replaceAspectWithDef(theMap, theAspect) \
if (myDrawer->Link()->theAspect()->Aspect() != myDrawer->theAspect()->Aspect()) \
{ \
theMap.Bind (myDrawer->theAspect()->Aspect(), myDrawer->Link()->theAspect()->Aspect()); \
}
// Auxiliary macros for replaceWithNewOwnAspects()
#define replaceAspectWithOwn(theMap, theAspect) \
if (myDrawer->Link()->theAspect()->Aspect() != myDrawer->theAspect()->Aspect()) \
{ \
theMap.Bind (myDrawer->Link()->theAspect()->Aspect(), myDrawer->theAspect()->Aspect()); \
}
//=======================================================================
//function : replaceWithNewOwnAspects
//purpose :
//=======================================================================
void AIS_Shape::replaceWithNewOwnAspects()
{
Graphic3d_MapOfAspectsToAspects aReplaceMap;
replaceAspectWithOwn (aReplaceMap, ShadingAspect);
replaceAspectWithOwn (aReplaceMap, LineAspect);
replaceAspectWithOwn (aReplaceMap, WireAspect);
replaceAspectWithOwn (aReplaceMap, FreeBoundaryAspect);
replaceAspectWithOwn (aReplaceMap, UnFreeBoundaryAspect);
replaceAspectWithOwn (aReplaceMap, SeenLineAspect);
replaceAspectWithOwn (aReplaceMap, FaceBoundaryAspect);
replaceAspectWithOwn (aReplaceMap, PointAspect);
replaceAspects (aReplaceMap);
}
//==================================================
// Function: AIS_Shape
// Purpose :
@@ -386,7 +352,11 @@ bool AIS_Shape::setColor (const Handle(Prs3d_Drawer)& theDrawer,
bool toRecompute = false;
toRecompute = theDrawer->SetupOwnShadingAspect() || toRecompute;
toRecompute = theDrawer->SetOwnLineAspects() || toRecompute;
toRecompute = theDrawer->SetupOwnPointAspect() || toRecompute;
if (theDrawer->SetupOwnPointAspect())
{
toRecompute = true;
}
// override color
theDrawer->ShadingAspect()->SetColor (theColor, myCurrentFacingModel);
@@ -410,19 +380,52 @@ void AIS_Shape::SetColor (const Quantity_Color& theColor)
const bool toRecompute = setColor (myDrawer, theColor);
myDrawer->SetColor (theColor);
hasOwnColor = Standard_True;
myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update
myToRecomputeModes.Clear();
if (!toRecompute
|| !myDrawer->HasLink())
if (!toRecompute)
{
myToRecomputeModes.Clear();
myRecomputeEveryPrs = false;
SynchronizeAspects();
return;
}
else
// modify shading presentation without re-computation
const PrsMgr_Presentations& aPrsList = Presentations();
Handle(Graphic3d_AspectFillArea3d) anAreaAspect = myDrawer->ShadingAspect()->Aspect();
Handle(Graphic3d_AspectLine3d) aLineAspect = myDrawer->LineAspect()->Aspect();
Handle(Graphic3d_AspectMarker3d) aPointAspect = myDrawer->PointAspect()->Aspect();
for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
{
replaceWithNewOwnAspects();
const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
if (aPrsModed.Mode() != AIS_Shaded)
{
continue;
}
const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
{
const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
// Check if aspect of given type is set for the group,
// because setting aspect for group with no already set aspect
// can lead to loss of presentation data
if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
{
aGroup->SetGroupPrimitivesAspect (anAreaAspect);
}
if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_LINE))
{
aGroup->SetGroupPrimitivesAspect (aLineAspect);
}
if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_MARKER))
{
aGroup->SetGroupPrimitivesAspect (aPointAspect);
}
}
}
recomputeComputed();
LoadRecomputable (AIS_WireFrame);
LoadRecomputable (2);
}
//=======================================================================
@@ -432,31 +435,25 @@ void AIS_Shape::SetColor (const Quantity_Color& theColor)
void AIS_Shape::UnsetColor()
{
myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update
myToRecomputeModes.Clear();
if (!HasColor())
{
myToRecomputeModes.Clear();
myRecomputeEveryPrs = false;
return;
}
hasOwnColor = Standard_False;
myDrawer->SetColor (myDrawer->HasLink() ? myDrawer->Link()->Color() : Quantity_Color (Quantity_NOC_WHITE));
Graphic3d_MapOfAspectsToAspects aReplaceMap;
if (!HasWidth())
{
replaceAspectWithDef (aReplaceMap, LineAspect);
replaceAspectWithDef (aReplaceMap, WireAspect);
replaceAspectWithDef (aReplaceMap, FreeBoundaryAspect);
replaceAspectWithDef (aReplaceMap, UnFreeBoundaryAspect);
replaceAspectWithDef (aReplaceMap, SeenLineAspect);
replaceAspectWithDef (aReplaceMap, FaceBoundaryAspect);
myDrawer->SetLineAspect (Handle(Prs3d_LineAspect)());
myDrawer->SetWireAspect (Handle(Prs3d_LineAspect)());
myDrawer->SetFreeBoundaryAspect (Handle(Prs3d_LineAspect)());
myDrawer->SetUnFreeBoundaryAspect(Handle(Prs3d_LineAspect)());
myDrawer->SetSeenLineAspect (Handle(Prs3d_LineAspect)());
myDrawer->SetFaceBoundaryAspect (Handle(Prs3d_LineAspect)());
Handle(Prs3d_LineAspect) anEmptyAsp;
myDrawer->SetLineAspect (anEmptyAsp);
myDrawer->SetWireAspect (anEmptyAsp);
myDrawer->SetFreeBoundaryAspect (anEmptyAsp);
myDrawer->SetUnFreeBoundaryAspect(anEmptyAsp);
myDrawer->SetSeenLineAspect (anEmptyAsp);
myDrawer->SetFaceBoundaryAspect (anEmptyAsp);
}
else
{
@@ -538,17 +535,10 @@ void AIS_Shape::UnsetColor()
}
else
{
replaceAspectWithDef (aReplaceMap, ShadingAspect);
myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
}
if (myDrawer->HasOwnPointAspect())
{
replaceAspectWithDef (aReplaceMap, PointAspect);
myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)());
}
replaceAspects (aReplaceMap);
SynchronizeAspects();
recomputeComputed();
myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)());
myRecomputeEveryPrs = true;
}
//=======================================================================
@@ -579,19 +569,16 @@ bool AIS_Shape::setWidth (const Handle(Prs3d_Drawer)& theDrawer,
void AIS_Shape::SetWidth (const Standard_Real theLineWidth)
{
myOwnWidth = theLineWidth;
myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update
myToRecomputeModes.Clear();
if (!setWidth (myDrawer, theLineWidth)
|| !myDrawer->HasLink())
if (setWidth (myDrawer, theLineWidth))
{
SynchronizeAspects();
myRecomputeEveryPrs = true;
}
else
{
replaceWithNewOwnAspects();
myRecomputeEveryPrs = false;
myToRecomputeModes.Clear();
SynchronizeAspects();
}
recomputeComputed();
}
//=======================================================================
@@ -601,30 +588,24 @@ void AIS_Shape::SetWidth (const Standard_Real theLineWidth)
void AIS_Shape::UnsetWidth()
{
myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update
myToRecomputeModes.Clear();
if (myOwnWidth == 0.0)
{
myToRecomputeModes.Clear();
myRecomputeEveryPrs = false;
return;
}
myOwnWidth = 0.0;
if (!HasColor())
{
Graphic3d_MapOfAspectsToAspects aReplaceMap;
replaceAspectWithDef (aReplaceMap, LineAspect);
replaceAspectWithDef (aReplaceMap, WireAspect);
replaceAspectWithDef (aReplaceMap, FreeBoundaryAspect);
replaceAspectWithDef (aReplaceMap, UnFreeBoundaryAspect);
replaceAspectWithDef (aReplaceMap, SeenLineAspect);
replaceAspectWithDef (aReplaceMap, FaceBoundaryAspect);
myDrawer->SetLineAspect (Handle(Prs3d_LineAspect)());
myDrawer->SetWireAspect (Handle(Prs3d_LineAspect)());
myDrawer->SetFreeBoundaryAspect (Handle(Prs3d_LineAspect)());
myDrawer->SetUnFreeBoundaryAspect(Handle(Prs3d_LineAspect)());
myDrawer->SetSeenLineAspect (Handle(Prs3d_LineAspect)());
myDrawer->SetFaceBoundaryAspect (Handle(Prs3d_LineAspect)());
replaceAspects (aReplaceMap);
const Handle(Prs3d_LineAspect) anEmptyAsp;
myDrawer->SetLineAspect (anEmptyAsp);
myDrawer->SetWireAspect (anEmptyAsp);
myDrawer->SetFreeBoundaryAspect (anEmptyAsp);
myDrawer->SetUnFreeBoundaryAspect(anEmptyAsp);
myDrawer->SetSeenLineAspect (anEmptyAsp);
myDrawer->SetFaceBoundaryAspect (anEmptyAsp);
myRecomputeEveryPrs = true;
}
else
{
@@ -641,8 +622,9 @@ void AIS_Shape::UnsetWidth()
myDrawer->FaceBoundaryAspect() ->SetWidth (myDrawer->HasLink() ?
AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_FaceBoundary) : 1.);
SynchronizeAspects();
myToRecomputeModes.Clear();
myRecomputeEveryPrs = false;
}
recomputeComputed();
}
//=======================================================================
@@ -677,21 +659,37 @@ void AIS_Shape::setMaterial (const Handle(Prs3d_Drawer)& theDrawer,
void AIS_Shape::SetMaterial (const Graphic3d_MaterialAspect& theMat)
{
const bool toRecompute = !myDrawer->HasOwnShadingAspect();
setMaterial (myDrawer, theMat, HasColor(), IsTransparent());
hasOwnMaterial = Standard_True;
myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update
// modify shading presentation without re-computation
const PrsMgr_Presentations& aPrsList = Presentations();
Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
{
const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
if (aPrsModed.Mode() != AIS_Shaded)
{
continue;
}
const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
{
const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
// Check if aspect of given type is set for the group,
// because setting aspect for group with no already set aspect
// can lead to loss of presentation data
if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
{
aGroup->SetGroupPrimitivesAspect (anAreaAsp);
}
}
}
myRecomputeEveryPrs = Standard_False; // no mode to recalculate :only viewer update
myToRecomputeModes.Clear();
if (!toRecompute
|| !myDrawer->HasLink())
{
SynchronizeAspects();
}
else
{
replaceWithNewOwnAspects();
}
}
//=======================================================================
@@ -701,8 +699,6 @@ void AIS_Shape::SetMaterial (const Graphic3d_MaterialAspect& theMat)
void AIS_Shape::UnsetMaterial()
{
myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update
myToRecomputeModes.Clear();
if (!HasMaterial())
{
return;
@@ -726,15 +722,37 @@ void AIS_Shape::UnsetMaterial()
myDrawer->ShadingAspect()->SetColor (myDrawer->Color(), myCurrentFacingModel);
myDrawer->ShadingAspect()->SetTransparency (myDrawer->Transparency(), myCurrentFacingModel);
}
SynchronizeAspects();
}
else
{
Graphic3d_MapOfAspectsToAspects aReplaceMap;
replaceAspectWithDef (aReplaceMap, ShadingAspect);
myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
replaceAspects (aReplaceMap);
}
hasOwnMaterial = Standard_False;
// modify shading presentation without re-computation
const PrsMgr_Presentations& aPrsList = Presentations();
Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
{
const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
if (aPrsModed.Mode() != AIS_Shaded)
{
continue;
}
const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
{
const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
{
aGroup->SetGroupPrimitivesAspect (anAreaAsp);
}
}
}
myRecomputeEveryPrs = Standard_False; // no mode to recalculate :only viewer update
myToRecomputeModes.Clear();
}
//=======================================================================
@@ -757,21 +775,33 @@ void AIS_Shape::setTransparency (const Handle(Prs3d_Drawer)& theDrawer,
void AIS_Shape::SetTransparency (const Standard_Real theValue)
{
const bool toRecompute = !myDrawer->HasOwnShadingAspect();
setTransparency (myDrawer, theValue);
myDrawer->SetTransparency ((Standard_ShortReal )theValue);
myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update
// modify shading presentation without re-computation
const PrsMgr_Presentations& aPrsList = Presentations();
Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
{
const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
if (aPrsModed.Mode() != AIS_Shaded)
{
continue;
}
const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
{
const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
{
aGroup->SetGroupPrimitivesAspect (anAreaAsp);
}
}
}
myRecomputeEveryPrs = Standard_False; // no mode to recalculate - only viewer update
myToRecomputeModes.Clear();
if (!toRecompute
|| !myDrawer->HasLink())
{
SynchronizeAspects();
}
else
{
replaceWithNewOwnAspects();
}
}
//=======================================================================
@@ -781,9 +811,6 @@ void AIS_Shape::SetTransparency (const Standard_Real theValue)
void AIS_Shape::UnsetTransparency()
{
myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update
myToRecomputeModes.Clear();
myDrawer->SetTransparency (0.0f);
if (!myDrawer->HasOwnShadingAspect())
{
@@ -794,15 +821,36 @@ void AIS_Shape::UnsetTransparency()
|| myDrawer->ShadingAspect()->Aspect()->ToMapTexture())
{
myDrawer->ShadingAspect()->SetTransparency (0.0, myCurrentFacingModel);
SynchronizeAspects();
}
else
{
Graphic3d_MapOfAspectsToAspects aReplaceMap;
replaceAspectWithDef (aReplaceMap, ShadingAspect);
myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
replaceAspects (aReplaceMap);
}
// modify shading presentation without re-computation
const PrsMgr_Presentations& aPrsList = Presentations();
Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
{
const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
if (aPrsModed.Mode() != AIS_Shaded)
{
continue;
}
const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
{
const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
{
aGroup->SetGroupPrimitivesAspect (anAreaAsp);
}
}
}
myRecomputeEveryPrs = Standard_False; // no mode to recalculate :only viewer update
myToRecomputeModes.Clear();
}
//=======================================================================

View File

@@ -316,9 +316,6 @@ protected:
Standard_EXPORT void setMaterial (const Handle(Prs3d_Drawer)& theDrawer, const Graphic3d_MaterialAspect& theMaterial, const Standard_Boolean theToKeepColor, const Standard_Boolean theToKeepTransp) const;
//! Replace aspects of already computed groups from drawer link by the new own value.
Standard_EXPORT void replaceWithNewOwnAspects();
public:
//! Compute HLR presentation for specified shape.

View File

@@ -218,6 +218,36 @@ void AIS_TexturedShape::SetColor (const Quantity_Color& theColor)
void AIS_TexturedShape::UnsetColor()
{
AIS_Shape::UnsetColor();
for (Standard_Integer aPrsIt = 1; aPrsIt <= Presentations().Length(); ++aPrsIt)
{
const PrsMgr_ModedPresentation& aPrsModed = Presentations().Value (aPrsIt);
if (aPrsModed.Mode() != 3)
continue;
Handle(Prs3d_Presentation) aPrs = aPrsModed.Presentation()->Presentation();
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (aPrs);
Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->Link()->ShadingAspect()->Aspect();
Handle(Graphic3d_AspectLine3d) aLineAsp = myDrawer->Link()->LineAspect()->Aspect();
Quantity_Color aColor;
AIS_GraphicTool::GetInteriorColor (myDrawer->Link(), aColor);
anAreaAsp->SetInteriorColor (aColor);
// Check if aspect of given type is set for the group,
// because setting aspect for group with no already set aspect
// can lead to loss of presentation data
if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
{
aGroup->SetGroupPrimitivesAspect (anAreaAsp);
}
if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_LINE))
{
aGroup->SetGroupPrimitivesAspect (aLineAsp);
}
updateAttributes (aPrs);
}
}
//=======================================================================
@@ -347,6 +377,10 @@ void AIS_TexturedShape::updateAttributes (const Handle(Prs3d_Presentation)& theP
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (thePrs->Groups()); aGroupIt.More(); aGroupIt.Next())
{
const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
if (!aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
{
continue;
}
aGroup->SetGroupPrimitivesAspect (myAspect);
}
}

View File

@@ -108,7 +108,10 @@ void AIS_Triangulation::updatePresentation()
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
{
const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
aGroup->SetGroupPrimitivesAspect (anAreaAsp);
if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
{
aGroup->SetGroupPrimitivesAspect (anAreaAsp);
}
}
}

View File

@@ -682,7 +682,7 @@ void BRepMesh_Delaun::cleanupMesh()
if ( anEdges[aCurEdgeIdx] != aFreeEdgeId )
continue;
for ( Standard_Integer anOtherEdgeIt = 1; anOtherEdgeIt <= 2 && isCanNotBeRemoved; ++anOtherEdgeIt )
for ( Standard_Integer anOtherEdgeIt = 1; anOtherEdgeIt <= 2; ++anOtherEdgeIt )
{
Standard_Integer anOtherEdgeId = ( aCurEdgeIdx + anOtherEdgeIt ) % 3;
const BRepMesh_PairOfIndex& anOtherEdgePair =
@@ -691,27 +691,7 @@ void BRepMesh_Delaun::cleanupMesh()
if ( anOtherEdgePair.Extent() < 2 )
{
isCanNotBeRemoved = Standard_False;
}
else
{
for (int aTriIdx = 1; aTriIdx <= anOtherEdgePair.Extent () && isCanNotBeRemoved; ++aTriIdx)
{
if (anOtherEdgePair.Index (aTriIdx) == aTriId)
continue;
Standard_Integer v[3];
const BRepMesh_Triangle& aCurTriangle = GetTriangle (anOtherEdgePair.Index (aTriIdx));
myMeshData->ElementNodes (aCurTriangle, v);
for (int aNodeIdx = 0; aNodeIdx < 3 && isCanNotBeRemoved; ++aNodeIdx)
{
if (v[aNodeIdx] == mySupVert[0] ||
v[aNodeIdx] == mySupVert[1] ||
v[aNodeIdx] == mySupVert[2])
{
isCanNotBeRemoved = Standard_False;
}
}
}
break;
}
}

View File

@@ -179,8 +179,7 @@ static
const TopTools_MapOfShape& theEdgesInvalidByVertex,
const TopTools_MapOfShape& theMFHoles,
TopTools_IndexedMapOfShape& theMFInvInHole,
TopTools_ListOfShape& theInvFaces,
TopTools_ListOfShape& theInvertedFaces);
TopTools_ListOfShape& theInvFaces);
static
void FindFacesInsideHoleWires(const TopoDS_Face& theFOrigin,
@@ -239,8 +238,6 @@ static
TopTools_IndexedDataMapOfShapeListOfShape& theInvFaces,
const TopTools_DataMapOfShapeShape& theArtInvFaces,
const TopTools_IndexedMapOfShape& theInvEdges,
const TopTools_MapOfShape& theInvertedEdges,
const TopTools_ListOfShape& theInvertedFaces,
const TopTools_IndexedMapOfShape& theMFToCheckInt,
const TopTools_IndexedMapOfShape& theMFInvInHole,
const TopoDS_Shape& theFHoles,
@@ -261,7 +258,6 @@ static
const TopTools_DataMapOfShapeShape& theDMFImF,
const TopTools_IndexedMapOfShape& theMFInv,
const TopTools_IndexedMapOfShape& theInvEdges,
const TopTools_MapOfShape& theInvertedEdges,
TopTools_MapOfShape& theMFToRem);
static
@@ -600,21 +596,6 @@ static
void AppendToList(TopTools_ListOfShape& theL,
const TopoDS_Shape& theS);
template <class ContainerType, class FenceMapType>
static Standard_Boolean TakeModified(const TopoDS_Shape& theS,
const TopTools_DataMapOfShapeListOfShape& theImages,
ContainerType& theMapOut,
FenceMapType* theMFence);
template <class ContainerType>
static Standard_Boolean TakeModified(const TopoDS_Shape& theS,
const TopTools_DataMapOfShapeListOfShape& theImages,
ContainerType& theMapOut)
{
TopTools_MapOfShape* aDummy = NULL;
return TakeModified (theS, theImages, theMapOut, aDummy);
}
//=======================================================================
//function : BuildSplitsOfTrimmedFaces
//purpose : Building splits of already trimmed faces
@@ -1007,12 +988,6 @@ void BuildSplitsOfFaces(const TopTools_ListOfShape& theLF,
}
#endif
#ifdef OFFSET_DEBUG
// Show all obtained splits of faces
TopoDS_Compound aCFIm1;
BRep_Builder().MakeCompound(aCFIm1);
#endif
// Build Edge-Face connectivity map to find faces which removal
// may potentially lead to creation of the holes in the faces
// preventing from obtaining closed volume in the result
@@ -1022,12 +997,7 @@ void BuildSplitsOfFaces(const TopTools_ListOfShape& theLF,
{
TopTools_ListIteratorOfListOfShape itLFIm(theFImages(i));
for (; itLFIm.More(); itLFIm.Next())
{
TopExp::MapShapesAndAncestors(itLFIm.Value(), TopAbs_EDGE, TopAbs_FACE, anEFMap);
#ifdef OFFSET_DEBUG
BRep_Builder().Add(aCFIm1, itLFIm.Value());
#endif
}
}
TopTools_ListOfShape anEmptyList;
@@ -1036,8 +1006,6 @@ void BuildSplitsOfFaces(const TopTools_ListOfShape& theLF,
// all hole faces
TopoDS_Compound aFHoles;
aBB.MakeCompound(aFHoles);
// Find the faces containing only the inverted edges and the invalid ones
TopTools_ListOfShape anInvertedFaces;
// find invalid faces
// considering faces containing only invalid edges as invalid
aItLF.Initialize(aLFDone);
@@ -1076,7 +1044,7 @@ void BuildSplitsOfFaces(const TopTools_ListOfShape& theLF,
// find invalid faces
FindInvalidFaces(aLFImages, theInvEdges, theValidEdges, aDMFLVE, aDMFLIE,
*pLNE, *pLIVE, theInvertedEdges, aMEdgeInvalidByVertex,
aMFHoles, aMFInvInHole, aLFInv, anInvertedFaces);
aMFHoles, aMFInvInHole, aLFInv);
}
//
if (aLFInv.Extent()) {
@@ -1127,8 +1095,8 @@ void BuildSplitsOfFaces(const TopTools_ListOfShape& theLF,
//
// remove inside faces
TopTools_IndexedMapOfShape aMEInside;
RemoveInsideFaces(theFImages, theInvFaces, theArtInvFaces, theInvEdges, theInvertedEdges,
anInvertedFaces, aMFToCheckInt, aMFInvInHole, aFHoles, theSSInterfs,
RemoveInsideFaces(theFImages, theInvFaces, theArtInvFaces, theInvEdges,
aMFToCheckInt, aMFInvInHole, aFHoles, theSSInterfs,
aMERemoved, aMEInside, theSolids);
//
// make compound of valid splits
@@ -1851,8 +1819,7 @@ void FindInvalidFaces(TopTools_ListOfShape& theLFImages,
const TopTools_MapOfShape& theEdgesInvalidByVertex,
const TopTools_MapOfShape& theMFHoles,
TopTools_IndexedMapOfShape& theMFInvInHole,
TopTools_ListOfShape& theInvFaces,
TopTools_ListOfShape& theInvertedFaces)
TopTools_ListOfShape& theInvFaces)
{
// The face should be considered as invalid in the following cases:
// 1. It has been reverted, i.e. at least two not connected edges
@@ -1865,8 +1832,7 @@ void FindInvalidFaces(TopTools_ListOfShape& theLFImages,
// The face will be kept in the following cases:
// 1. Some of the edges are valid for this face.
Standard_Boolean bHasValid, bAllValid, bAllInvalid, bHasReallyInvalid, bAllInvNeutral;
Standard_Boolean bValid, bValidLoc, bInvalid, bInvalidLoc, bNeutral, bInverted;
Standard_Boolean bIsInvalidByInverted;
Standard_Boolean bValid, bValidLoc, bInvalid, bInvalidLoc, bNeutral;
Standard_Integer i, aNbChecked;
//
// neutral edges
@@ -1883,7 +1849,7 @@ void FindInvalidFaces(TopTools_ListOfShape& theLFImages,
aMEValInverted.Add(aItLE.Value());
}
//
Standard_Boolean bTreatInvertedAsInvalid = (theLFImages.Extent() == 1);
Standard_Boolean bCheckInverted = (theLFImages.Extent() == 1);
//
// neutral edges to remove
TopTools_IndexedMapOfShape aMENRem;
@@ -1917,7 +1883,6 @@ void FindInvalidFaces(TopTools_ListOfShape& theLFImages,
bAllInvalid = Standard_True;
bHasReallyInvalid = Standard_False;
bAllInvNeutral = Standard_True;
bIsInvalidByInverted = Standard_True;
aNbChecked = 0;
//
const TopoDS_Wire& aWIm = BRepTools::OuterWire(aFIm);
@@ -1944,19 +1909,17 @@ void FindInvalidFaces(TopTools_ListOfShape& theLFImages,
bNeutral = aMEN.Contains(aEIm);
bValidLoc = aMVE.Contains(aEIm);
//
bInverted = theMEInverted.Contains(aEIm);
if (!bInvalid && bTreatInvertedAsInvalid) {
bInvalid = bInverted;
if (!bInvalid && bCheckInverted) {
bInvalid = theMEInverted.Contains(aEIm);
}
//
if (bValidLoc && (bNeutral || aMEValInverted.Contains(aEIm))) {
bHasValid = Standard_True;
}
//
bAllValid &= bValidLoc;
bAllInvalid &= bInvalid;
bAllInvNeutral &= (bAllInvalid && bNeutral);
bIsInvalidByInverted &= (bInvalidLoc || bInverted);
bAllValid = bAllValid && bValidLoc;
bAllInvalid = bAllInvalid && bInvalid;
bAllInvNeutral = bAllInvNeutral && bAllInvalid && bNeutral;
}
//
if (!aNbChecked) {
@@ -1991,12 +1954,6 @@ void FindInvalidFaces(TopTools_ListOfShape& theLFImages,
continue;
}
//
if (bIsInvalidByInverted && !(bHasValid || bAllValid))
{
// The face contains only the inverted and locally invalid edges
theInvertedFaces.Append(aFIm);
}
if (!bAllInvNeutral) {
aLFPT.Append(aFIm);
}
@@ -2046,7 +2003,7 @@ void FindInvalidFaces(TopTools_ListOfShape& theLFImages,
bNeutral = aMEN.Contains(aEIm);
bValidLoc = aMVE.Contains(aEIm);
//
if (!bInvalid && bTreatInvertedAsInvalid) {
if (!bInvalid && bCheckInverted) {
bInvalid = theMEInverted.Contains(aEIm);
}
//
@@ -2916,8 +2873,6 @@ void RemoveInsideFaces(TopTools_IndexedDataMapOfShapeListOfShape& theFImages,
TopTools_IndexedDataMapOfShapeListOfShape& theInvFaces,
const TopTools_DataMapOfShapeShape& theArtInvFaces,
const TopTools_IndexedMapOfShape& theInvEdges,
const TopTools_MapOfShape& theInvertedEdges,
const TopTools_ListOfShape& theInvertedFaces,
const TopTools_IndexedMapOfShape& theMFToCheckInt,
const TopTools_IndexedMapOfShape& theMFInvInHole,
const TopoDS_Shape& theFHoles,
@@ -2977,9 +2932,6 @@ void RemoveInsideFaces(TopTools_IndexedDataMapOfShapeListOfShape& theFImages,
aMV.SetArguments(aLS);
aMV.SetIntersect(Standard_True);
aMV.Perform();
if (aMV.HasErrors())
return;
//
// get shapes connection for using in the rebuilding process
// for the cases in which some of the intersection left undetected
@@ -3064,21 +3016,19 @@ void RemoveInsideFaces(TopTools_IndexedDataMapOfShapeListOfShape& theFImages,
TopExp::MapShapes(aFIm, TopAbs_EDGE, aMEBoundary);
}
}
// Tool for getting the splits of faces
const TopTools_DataMapOfShapeListOfShape& aMVIms = aMV.Images();
//
// update invalid faces with images
aNb = aMFInv.Extent();
for (i = 1; i <= aNb; ++i) {
const TopoDS_Shape& aFInv = aMFInv(i);
TakeModified(aFInv, aMVIms, aMFInv);
const TopTools_ListOfShape& aLFInvIm = aMV.Modified(aFInv);
TopTools_ListIteratorOfListOfShape aItLFInvIm(aLFInvIm);
for (; aItLFInvIm.More(); aItLFInvIm.Next()) {
const TopoDS_Shape& aFInvIm = aItLFInvIm.Value();
aMFInv.Add(aFInvIm);
}
}
// Take into account the faces invalid by inverted edges
for (TopTools_ListOfShape::Iterator itLF(theInvertedFaces); itLF.More(); itLF.Next())
TakeModified(itLF.Value(), aMVIms, aMFInv);
//
// check if the invalid faces inside the holes are really invalid:
// check its normal direction - if it has changed relatively the
// original face the offset face is invalid and should be kept for rebuilding
@@ -3132,14 +3082,10 @@ void RemoveInsideFaces(TopTools_IndexedDataMapOfShapeListOfShape& theFImages,
//
if (aFS.Orientation() == TopAbs_INTERNAL) {
aMFToRem.Add(aFS);
continue;
}
if (aMFToRem.Contains(aFS))
continue;
bAllRemoved = false;
bAllInv &= aMFInv.Contains(aFS);
//
bAllRemoved = bAllRemoved && aMFToRem.Contains(aFS);
bAllInv = bAllInv && (aMFToRem.Contains(aFS) || aMFInv.Contains(aFS));
}
//
if (bAllInv && !bAllRemoved) {
@@ -3170,7 +3116,7 @@ void RemoveInsideFaces(TopTools_IndexedDataMapOfShapeListOfShape& theFImages,
}
// Remove the invalid hanging parts external to the solids
RemoveHangingParts(aMV, aDMFImF, aMFInv, theInvEdges, theInvertedEdges, aMFToRem);
RemoveHangingParts(aMV, aDMFImF, aMFInv, theInvEdges, aMFToRem);
// Remove newly found internal and hanging faces
RemoveValidSplits(aMFToRem, theFImages, aMV, theMERemoved);
@@ -3356,7 +3302,6 @@ void RemoveHangingParts(const BOPAlgo_MakerVolume& theMV,
const TopTools_DataMapOfShapeShape& theDMFImF,
const TopTools_IndexedMapOfShape& theMFInv,
const TopTools_IndexedMapOfShape& theInvEdges,
const TopTools_MapOfShape& theInvertedEdges,
TopTools_MapOfShape& theMFToRem)
{
// Map the faces of the result solids to filter them from avoided faces
@@ -3378,7 +3323,22 @@ void RemoveHangingParts(const BOPAlgo_MakerVolume& theMV,
for (; anExpF.More(); anExpF.Next())
{
const TopoDS_Shape& aF = anExpF.Current();
TakeModified(aF, aMVIms, aCFHangs, &aMFS);
const TopTools_ListOfShape* pLFIm = aMVIms.Seek(aF);
if (pLFIm)
{
TopTools_ListIteratorOfListOfShape aItLFIm(*pLFIm);
for (; aItLFIm.More(); aItLFIm.Next())
{
const TopoDS_Shape& aFIm = aItLFIm.Value();
if (!aMFS.Contains(aFIm))
aBB.Add(aCFHangs, aFIm);
}
}
else
{
if (!aMFS.Contains(aF))
aBB.Add(aCFHangs, aF);
}
}
}
@@ -3404,41 +3364,27 @@ void RemoveHangingParts(const BOPAlgo_MakerVolume& theMV,
// Update invalid edges with intersection results
TopTools_MapOfShape aMEInv;
Standard_Integer i, aNbE = theInvEdges.Extent();
for (i = 1; i <= aNbE; ++i)
TakeModified(theInvEdges(i), aMVIms, aMEInv);
// Update inverted edges with intersection results
TopTools_MapOfShape aMEInverted;
for (TopTools_MapIteratorOfMapOfShape itM(theInvertedEdges); itM.More(); itM.Next())
TakeModified(itM.Value(), aMVIms, aMEInverted);
for (i = 1; i <= aNbE; ++i) {
const TopoDS_Shape& aEInv = theInvEdges(i);
const TopTools_ListOfShape *pLEIm = aMVIms.Seek(aEInv);
if (pLEIm)
{
TopTools_ListIteratorOfListOfShape aItLEIm(*pLEIm);
for (; aItLEIm.More(); aItLEIm.Next())
aMEInv.Add(aItLEIm.Value());
}
else
aMEInv.Add(aEInv);
}
// Tool for getting the origins of the splits
const TopTools_DataMapOfShapeListOfShape& aMVOrs = theMV.Origins();
// Find hanging blocks to remove
TopTools_ListOfShape aBlocksToRemove;
TopTools_ListIteratorOfListOfShape aItLCBH(aLCBHangs);
for (; aItLCBH.More(); aItLCBH.Next())
{
const TopoDS_Shape& aCBH = aItLCBH.Value();
// Remove the block containing the inverted edges
Standard_Boolean bHasInverted = Standard_False;
TopExp_Explorer anExpE(aCBH, TopAbs_EDGE);
for (; anExpE.More() && !bHasInverted; anExpE.Next())
{
const TopoDS_Shape& aE = anExpE.Current();
bHasInverted = !aDMEF .Contains(aE) &&
aMEInverted.Contains(aE);
}
if (bHasInverted)
{
aBlocksToRemove.Append(aCBH);
continue;
}
// Check the block to contain invalid split
Standard_Boolean bHasInvalidFace = Standard_False;
// Check connectivity to invalid parts
@@ -3460,7 +3406,7 @@ void RemoveHangingParts(const BOPAlgo_MakerVolume& theMV,
if (!bIsConnected)
{
// check edges
anExpE.Init(aF, TopAbs_EDGE);
TopExp_Explorer anExpE(aF, TopAbs_EDGE);
for (; anExpE.More() && !bIsConnected; anExpE.Next())
{
const TopoDS_Shape& aE = anExpE.Current();
@@ -3473,20 +3419,17 @@ void RemoveHangingParts(const BOPAlgo_MakerVolume& theMV,
}
}
// check vertices
if (!bIsConnected)
TopExp_Explorer anExpV(aF, TopAbs_VERTEX);
for (; anExpV.More() && !bIsConnected; anExpV.Next())
{
TopExp_Explorer anExpV(aF, TopAbs_VERTEX);
for (; anExpV.More() && !bIsConnected; anExpV.Next())
const TopoDS_Shape& aV = anExpV.Current();
const TopTools_ListOfShape *pLE = aDMVE.Seek(aV);
if (pLE)
{
const TopoDS_Shape& aV = anExpV.Current();
const TopTools_ListOfShape *pLE = aDMVE.Seek(aV);
if (pLE)
{
TopTools_ListIteratorOfListOfShape aItLE(*pLE);
for (; aItLE.More() && !bIsConnected; aItLE.Next())
bIsConnected = !aBlockME.Contains(aItLE.Value()) &&
aMEInv .Contains(aItLE.Value());
}
TopTools_ListIteratorOfListOfShape aItLE(*pLE);
for (; aItLE.More() && !bIsConnected; aItLE.Next())
bIsConnected = !aBlockME.Contains(aItLE.Value()) &&
aMEInv .Contains(aItLE.Value());
}
}
}
@@ -3515,17 +3458,12 @@ void RemoveHangingParts(const BOPAlgo_MakerVolume& theMV,
(!bIsConnected || aMOffsetF.Extent() == 1);
if (bRemove)
aBlocksToRemove.Append(aCBH);
}
// remove the invalidated blocks
aItLCBH.Initialize(aBlocksToRemove);
for (; aItLCBH.More(); aItLCBH.Next())
{
const TopoDS_Shape& aCBH = aItLCBH.Value();
TopExp_Explorer anExpF(aCBH, TopAbs_FACE);
for (; anExpF.More(); anExpF.Next())
theMFToRem.Add(anExpF.Current());
{
// remove the block
anExpF.Init(aCBH, TopAbs_FACE);
for (; anExpF.More(); anExpF.Next())
theMFToRem.Add(anExpF.Current());
}
}
}
@@ -6986,16 +6924,13 @@ void UpdateImages(const TopTools_ListOfShape& theLA,
TopTools_MapOfShape& theModified)
{
TopTools_ListIteratorOfListOfShape aIt(theLA);
for (; aIt.More(); aIt.Next())
{
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS = aIt.Value();
//
TopTools_ListOfShape* pLSIm = theImages.ChangeSeek(aS);
if (!pLSIm)
{
if (!pLSIm) {
const TopTools_ListOfShape& aLSIm = theGF.Modified(aS);
if (aLSIm.Extent())
{
if (aLSIm.Extent()) {
theImages.Bind(aS, aLSIm);
theModified.Add(aS);
}
@@ -7009,14 +6944,27 @@ void UpdateImages(const TopTools_ListOfShape& theLA,
//
// check modifications of the images
TopTools_ListIteratorOfListOfShape aIt1(*pLSIm);
for (; aIt1.More(); aIt1.Next())
{
for (; aIt1.More(); aIt1.Next()) {
const TopoDS_Shape& aSIm = aIt1.Value();
bModified |= TakeModified(aSIm, theGF.Images(), aLSImNew, &aMFence);
const TopTools_ListOfShape& aLSIm1 = theGF.Modified(aSIm);
if (aLSIm1.IsEmpty()) {
if (aMFence.Add(aSIm)) {
aLSImNew.Append(aSIm);
}
}
else {
TopTools_ListIteratorOfListOfShape aIt2(aLSIm1);
for (; aIt2.More(); aIt2.Next()) {
const TopoDS_Shape& aSImIm = aIt2.Value();
if (aMFence.Add(aSImIm)) {
aLSImNew.Append(aSImIm);
}
}
bModified = Standard_True;
}
}
//
if (bModified)
{
if (bModified) {
*pLSIm = aLSImNew;
theModified.Add(aS);
}
@@ -7151,61 +7099,3 @@ void AppendToList(TopTools_ListOfShape& theList,
}
theList.Append(theShape);
}
//=======================================================================
//function : AddToContainer
//purpose : Set of methods to add a shape into container
//=======================================================================
static void AddToContainer(const TopoDS_Shape& theS,
TopTools_ListOfShape& theList)
{
theList.Append(theS);
}
static Standard_Boolean AddToContainer(const TopoDS_Shape& theS,
TopTools_MapOfShape& theMap)
{
return theMap.Add(theS);
}
static Standard_Boolean AddToContainer(const TopoDS_Shape& theS,
TopTools_IndexedMapOfShape& theMap)
{
const Standard_Integer aNb = theMap.Extent();
const Standard_Integer anInd = theMap.Add(theS);
return anInd > aNb;
}
static void AddToContainer(const TopoDS_Shape& theS,
TopoDS_Shape& theSOut)
{
BRep_Builder().Add(theSOut, theS);
}
//=======================================================================
//function : TakeModified
//purpose : Check if the shape has images in the given images map.
// Puts in the output map either the images or the shape itself.
//=======================================================================
template <class ContainerType, class FenceMapType>
Standard_Boolean TakeModified(const TopoDS_Shape& theS,
const TopTools_DataMapOfShapeListOfShape& theImages,
ContainerType& theContainer,
FenceMapType* theMFence)
{
const TopTools_ListOfShape *pLSIm = theImages.Seek(theS);
if (pLSIm)
{
TopTools_ListIteratorOfListOfShape itLSIm(*pLSIm);
for (; itLSIm.More(); itLSIm.Next())
{
const TopoDS_Shape& aSIm = itLSIm.Value();
if (!theMFence || AddToContainer(aSIm, *theMFence))
AddToContainer(aSIm, theContainer);
}
return Standard_True;
}
else
{
if (!theMFence || AddToContainer(theS, *theMFence))
AddToContainer(theS, theContainer);
return Standard_False;
}
}

View File

@@ -1804,26 +1804,40 @@ static Standard_Boolean SaveBitmap (HBITMAP theHBitmap,
{
return Standard_False;
}
anImage.SetTopDown (false);
// Setup image data
BITMAPINFOHEADER aBitmapInfo;
memset (&aBitmapInfo, 0, sizeof(BITMAPINFOHEADER));
aBitmapInfo.biSize = sizeof(BITMAPINFOHEADER);
aBitmapInfo.biWidth = aBitmap.bmWidth;
aBitmapInfo.biHeight = aBitmap.bmHeight; // positive means bottom-up!
aBitmapInfo.biHeight = anImage.IsTopDown() ? -aBitmap.bmHeight : aBitmap.bmHeight;
aBitmapInfo.biPlanes = 1;
aBitmapInfo.biBitCount = 24;
aBitmapInfo.biCompression = BI_RGB;
// Copy the pixels
HDC aDC = GetDC (NULL);
Standard_Boolean isSuccess = GetDIBits (aDC, theHBitmap,
0, // first scan line to set
aBitmap.bmHeight, // number of scan lines to copy
anImage.ChangeData(), // array for bitmap bits
(LPBITMAPINFO )&aBitmapInfo, // bitmap data info
DIB_RGB_COLORS) != 0;
Standard_Boolean isSuccess = Standard_True;
if (anImage.SizeRowBytes() != aSizeRowBytes)
{
for (Standard_Size aRowIter = 0; aRowIter < anImage.SizeY(); ++aRowIter)
{
const Standard_Size aRow = anImage.SizeY() - aRowIter - 1;
isSuccess = isSuccess && GetDIBits (aDC, theHBitmap,
(UINT )aRow, 1,
anImage.ChangeRow (aRowIter),
(LPBITMAPINFO )&aBitmapInfo, DIB_RGB_COLORS) != 0;
}
}
else
{
isSuccess = GetDIBits (aDC, theHBitmap,
0, // first scan line to set
aBitmap.bmHeight, // number of scan lines to copy
anImage.ChangeData(), // array for bitmap bits
(LPBITMAPINFO )&aBitmapInfo, // bitmap data info
DIB_RGB_COLORS) != 0;
}
ReleaseDC (NULL, aDC);
return isSuccess && anImage.Save (theFileName);
}

View File

@@ -55,11 +55,12 @@ void DsgPrs::ComputeSymbol (const Handle(Prs3d_Presentation)& aPresentation,
const DsgPrs_ArrowSide ArrowSide,
const Standard_Boolean drawFromCenter)
{
Handle(Graphic3d_Group) aGroup = aPresentation->NewGroup();
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
Quantity_Color aColor = LA->LineAspect()->Aspect()->Color();
Handle(Graphic3d_AspectMarker3d) aMarkerAsp = new Graphic3d_AspectMarker3d (Aspect_TOM_O, aColor, 1.0);
aGroup->SetGroupPrimitivesAspect (LA->LineAspect()->Aspect());
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect (aMarkerAsp);
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
switch(ArrowSide) {
case DsgPrs_AS_NONE:
@@ -68,7 +69,7 @@ void DsgPrs::ComputeSymbol (const Handle(Prs3d_Presentation)& aPresentation,
}
case DsgPrs_AS_FIRSTAR:
{
Prs3d_Arrow::Draw (aGroup,
Prs3d_Arrow::Draw(Prs3d_Root::CurrentGroup (aPresentation),
pt1,
dir1,
LA->ArrowAspect()->Angle(),
@@ -78,7 +79,7 @@ void DsgPrs::ComputeSymbol (const Handle(Prs3d_Presentation)& aPresentation,
case DsgPrs_AS_LASTAR:
{
Prs3d_Arrow::Draw (aGroup,
Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation),
pt2,
dir2,
LA->ArrowAspect()->Angle(),
@@ -88,12 +89,12 @@ void DsgPrs::ComputeSymbol (const Handle(Prs3d_Presentation)& aPresentation,
case DsgPrs_AS_BOTHAR:
{
Prs3d_Arrow::Draw (aGroup,
Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation),
pt1,
dir1,
LA->ArrowAspect()->Angle(),
LA->ArrowAspect()->Length());
Prs3d_Arrow::Draw (aGroup,
Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation),
pt2,
dir2,
LA->ArrowAspect()->Angle(),
@@ -126,11 +127,15 @@ void DsgPrs::ComputeSymbol (const Handle(Prs3d_Presentation)& aPresentation,
{
if(drawFromCenter)
{
Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints1 = new Graphic3d_ArrayOfPoints (2);
Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints1 = new Graphic3d_ArrayOfPoints (1);
anArrayOfPoints1->AddVertex (pt1.X(), pt1.Y(), pt1.Z());
anArrayOfPoints1->AddVertex (pt2.X(), pt2.Y(), pt2.Z());
aGroup->SetGroupPrimitivesAspect (aMarkerAsp);
aGroup->AddPrimitiveArray (anArrayOfPoints1);
Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints1);
}
if(drawFromCenter)
{
Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints2 = new Graphic3d_ArrayOfPoints (1);
anArrayOfPoints2->AddVertex (pt2.X(), pt2.Y(), pt2.Z());
Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints2);
}
break;
}
@@ -138,7 +143,7 @@ void DsgPrs::ComputeSymbol (const Handle(Prs3d_Presentation)& aPresentation,
case DsgPrs_AS_FIRSTAR_LASTPT:
{
// an Arrow
Prs3d_Arrow::Draw (aGroup,
Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation),
pt1,
dir1,
LA->ArrowAspect()->Angle(),
@@ -146,28 +151,25 @@ void DsgPrs::ComputeSymbol (const Handle(Prs3d_Presentation)& aPresentation,
// a Round
Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
anArrayOfPoints->AddVertex (pt2.X(), pt2.Y(), pt2.Z());
aGroup->SetPrimitivesAspect (aMarkerAsp);
aGroup->AddPrimitiveArray (anArrayOfPoints);
Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints);
break;
}
case DsgPrs_AS_FIRSTPT_LASTAR:
{
// a Round
if(drawFromCenter)
{
Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
anArrayOfPoints->AddVertex (pt1.X(), pt1.Y(), pt1.Z());
Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints);
}
// an Arrow
Prs3d_Arrow::Draw (aGroup,
Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation),
pt2,
dir2,
LA->ArrowAspect()->Angle(),
LA->ArrowAspect()->Length());
// a Round
if (drawFromCenter)
{
Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
anArrayOfPoints->AddVertex (pt1.X(), pt1.Y(), pt1.Z());
aGroup->SetPrimitivesAspect (aMarkerAsp);
aGroup->AddPrimitiveArray (anArrayOfPoints);
}
break;
}
}

View File

@@ -155,7 +155,7 @@ FEmTool_ProfileMatrix::FEmTool_ProfileMatrix(const TColStd_Array1OfInteger& Firs
Standard_Real * x = &X(X.Lower());
x--;
const Standard_Real * b = &B(B.Lower());
Standard_Real * b = &B(B.Lower());
b--;
const Standard_Real * SMA = &SMatrix->Value(1);
SMA --;
@@ -207,7 +207,7 @@ FEmTool_ProfileMatrix::FEmTool_ProfileMatrix(const TColStd_Array1OfInteger& Firs
Standard_Integer i, j, jj, DiagAddr, CurrAddr;
Standard_Real * m = &MX(MX.Lower());
m--;
const Standard_Real * x = &X(X.Lower());
Standard_Real * x = &X(X.Lower());
x--;
const Standard_Real * PM = &ProfileMatrix->Value(1);
PM--;

View File

@@ -1381,7 +1381,7 @@ void GeomFill_LocationGuide::Resolution (const Standard_Integer ,
//Function : InitX
//Purpose : recherche par interpolation d'une valeur initiale
//==================================================================
void GeomFill_LocationGuide::InitX(const Standard_Real Param)
void GeomFill_LocationGuide::InitX(const Standard_Real Param) const
{
Standard_Integer Ideb = 1, Ifin = myPoles2d->RowLength(), Idemi;

View File

@@ -186,7 +186,7 @@ private:
Standard_EXPORT void SetRotation (const Standard_Real PrecAngle, Standard_Real& LastAngle);
Standard_EXPORT void InitX (const Standard_Real Param);
Standard_EXPORT void InitX (const Standard_Real Param) const;
Handle(GeomFill_TrihedronWithGuide) myLaw;
Handle(GeomFill_SectionLaw) mySec;

View File

@@ -11,8 +11,6 @@ Graphic3d_ArrayOfSegments.hxx
Graphic3d_ArrayOfTriangleFans.hxx
Graphic3d_ArrayOfTriangles.hxx
Graphic3d_ArrayOfTriangleStrips.hxx
Graphic3d_Aspects.cxx
Graphic3d_Aspects.hxx
Graphic3d_AspectFillArea3d.cxx
Graphic3d_AspectFillArea3d.hxx
Graphic3d_AspectLine3d.cxx
@@ -21,6 +19,7 @@ Graphic3d_AspectMarker3d.cxx
Graphic3d_AspectMarker3d.hxx
Graphic3d_AspectText3d.cxx
Graphic3d_AspectText3d.hxx
Graphic3d_AspectTextDefinitionError.hxx
Graphic3d_AttribBuffer.cxx
Graphic3d_AttribBuffer.hxx
Graphic3d_BndBox3d.hxx
@@ -74,7 +73,6 @@ Graphic3d_IndexedMapOfAddress.hxx
Graphic3d_LevelOfTextureAnisotropy.hxx
Graphic3d_LightSet.cxx
Graphic3d_LightSet.hxx
Graphic3d_MapOfAspectsToAspects.hxx
Graphic3d_MapIteratorOfMapOfStructure.hxx
Graphic3d_MapOfObject.hxx
Graphic3d_MapOfStructure.hxx

View File

@@ -15,15 +15,31 @@
#include <Graphic3d_AspectFillArea3d.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectFillArea3d, Graphic3d_Aspects)
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectFillArea3d, Standard_Transient)
// =======================================================================
// function : Graphic3d_AspectFillArea3d
// purpose :
// =======================================================================
Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d()
: myInteriorColor (Quantity_NOC_CYAN1),
myBackInteriorColor (Quantity_NOC_CYAN1),
myEdgeColor (Quantity_NOC_WHITE),
myInteriorStyle (Aspect_IS_EMPTY),
myShadingModel (Graphic3d_TOSM_DEFAULT),
myAlphaMode (Graphic3d_AlphaMode_BlendAuto),
myAlphaCutoff (0.5f),
myEdgeType (Aspect_TOL_SOLID),
myEdgeWidth (1.0f),
myHatchStyle (Handle(Graphic3d_HatchStyle)()),
myToSkipFirstEdge (false),
myToDistinguishMaterials (false),
myToDrawEdges (false),
myToDrawSilhouette (false),
myToSuppressBackFaces (true),
myToMapTexture (false)
{
myInteriorStyle = Aspect_IS_EMPTY;
//
}
// =======================================================================
@@ -37,13 +53,42 @@ Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d (const Aspect_InteriorSty
const Standard_Real theEdgeLineWidth,
const Graphic3d_MaterialAspect& theFrontMaterial,
const Graphic3d_MaterialAspect& theBackMaterial)
: myFrontMaterial (theFrontMaterial),
myBackMaterial (theBackMaterial),
myInteriorColor (theInteriorColor),
myBackInteriorColor (theInteriorColor),
myEdgeColor (theEdgeColor),
myInteriorStyle (theInteriorStyle),
myShadingModel (Graphic3d_TOSM_DEFAULT),
myAlphaMode (Graphic3d_AlphaMode_BlendAuto),
myAlphaCutoff (0.5f),
myEdgeType (theEdgeLineType),
myEdgeWidth ((float )theEdgeLineWidth),
myHatchStyle (Handle(Graphic3d_HatchStyle)()),
myToSkipFirstEdge (false),
myToDistinguishMaterials (false),
myToDrawEdges (false),
myToDrawSilhouette (false),
myToSuppressBackFaces (true),
myToMapTexture (false)
{
myFrontMaterial = theFrontMaterial;
myBackMaterial = theBackMaterial;
myInteriorColor.SetRGB (theInteriorColor);
myBackInteriorColor.SetRGB (theInteriorColor);
myEdgeColor.SetRGB (theEdgeColor);
myInteriorStyle = theInteriorStyle;
myLineType = theEdgeLineType;
SetEdgeWidth ((float )theEdgeLineWidth);
if (theEdgeLineWidth <= 0.0)
{
throw Aspect_AspectFillAreaDefinitionError("Bad value for EdgeLineWidth");
}
}
// =======================================================================
// function : Graphic3d_AspectFillArea3d
// purpose :
// =======================================================================
void Graphic3d_AspectFillArea3d::SetTextureMap (const Handle(Graphic3d_TextureMap)& theTexture)
{
if (theTexture.IsNull())
{
myTextureSet.Nullify();
return;
}
myTextureSet = new Graphic3d_TextureSet (theTexture);
}

View File

@@ -17,12 +17,30 @@
#ifndef _Graphic3d_AspectFillArea3d_HeaderFile
#define _Graphic3d_AspectFillArea3d_HeaderFile
#include <Graphic3d_Aspects.hxx>
#include <Aspect_AspectFillAreaDefinitionError.hxx>
#include <Aspect_PolygonOffsetMode.hxx>
#include <Aspect_InteriorStyle.hxx>
#include <Aspect_TypeOfLine.hxx>
#include <Graphic3d_AlphaMode.hxx>
#include <Graphic3d_HatchStyle.hxx>
#include <Graphic3d_MaterialAspect.hxx>
#include <Graphic3d_PolygonOffset.hxx>
#include <Graphic3d_ShaderProgram.hxx>
#include <Graphic3d_TextureMap.hxx>
#include <Graphic3d_TextureSet.hxx>
#include <Graphic3d_TypeOfShadingModel.hxx>
#include <Standard.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_Integer.hxx>
#include <Standard_ShortReal.hxx>
#include <Standard_Real.hxx>
#include <Standard_Type.hxx>
#include <Quantity_ColorRGBA.hxx>
//! This class defines graphic attributes for opaque 3d primitives (polygons, triangles, quadrilaterals).
class Graphic3d_AspectFillArea3d : public Graphic3d_Aspects
class Graphic3d_AspectFillArea3d : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectFillArea3d, Graphic3d_Aspects)
DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectFillArea3d, Standard_Transient)
public:
//! Creates a context table for fill area primitives defined with the following default values:
@@ -55,13 +73,340 @@ public:
const Graphic3d_MaterialAspect& theFrontMaterial,
const Graphic3d_MaterialAspect& theBackMaterial);
//! Return interior rendering style (Aspect_IS_EMPTY by default, which means nothing will be rendered!).
Aspect_InteriorStyle InteriorStyle() const { return myInteriorStyle; }
//! Modifies the interior type used for rendering
void SetInteriorStyle (const Aspect_InteriorStyle theStyle) { myInteriorStyle = theStyle; }
//! Returns shading model (Graphic3d_TOSM_DEFAULT by default, which means that Shading Model set as default for entire Viewer will be used)
Graphic3d_TypeOfShadingModel ShadingModel() const { return myShadingModel; }
//! Sets shading model
void SetShadingModel (const Graphic3d_TypeOfShadingModel theShadingModel) { myShadingModel = theShadingModel; }
//! Returns the way how alpha value should be treated (Graphic3d_AlphaMode_BlendAuto by default, for backward compatibility).
Graphic3d_AlphaMode AlphaMode() const { return myAlphaMode; }
//! Returns alpha cutoff threshold, for discarding fragments within Graphic3d_AlphaMode_Mask mode (0.5 by default).
//! If the alpha value is greater than or equal to this value then it is rendered as fully opaque, otherwise, it is rendered as fully transparent.
Standard_ShortReal AlphaCutoff() const { return myAlphaCutoff; }
//! Defines the way how alpha value should be treated.
void SetAlphaMode (Graphic3d_AlphaMode theMode, Standard_ShortReal theAlphaCutoff = 0.5f)
{
myAlphaMode = theMode;
myAlphaCutoff = theAlphaCutoff;
}
//! Return interior color.
const Quantity_Color& InteriorColor() const { return myInteriorColor.GetRGB(); }
//! Return interior color.
const Quantity_ColorRGBA& InteriorColorRGBA() const { return myInteriorColor; }
//! Modifies the color of the interior of the face
void SetInteriorColor (const Quantity_Color& theColor) { myInteriorColor.SetRGB (theColor); }
//! Modifies the color of the interior of the face
void SetInteriorColor (const Quantity_ColorRGBA& theColor) { myInteriorColor = theColor; }
//! Return back interior color.
const Quantity_Color& BackInteriorColor() const { return myBackInteriorColor.GetRGB(); }
//! Return back interior color.
const Quantity_ColorRGBA& BackInteriorColorRGBA() const { return myBackInteriorColor; }
//! Modifies the color of the interior of the back face
void SetBackInteriorColor (const Quantity_Color& theColor) { myBackInteriorColor.SetRGB (theColor); }
//! Modifies the color of the interior of the back face
void SetBackInteriorColor (const Quantity_ColorRGBA& theColor) { myBackInteriorColor = theColor; }
//! Returns the surface material of external faces
const Graphic3d_MaterialAspect& FrontMaterial() const { return myFrontMaterial; }
//! Returns the surface material of external faces
Graphic3d_MaterialAspect& ChangeFrontMaterial() { return myFrontMaterial; }
//! Modifies the surface material of external faces
void SetFrontMaterial (const Graphic3d_MaterialAspect& theMaterial) { myFrontMaterial = theMaterial; }
//! Returns the surface material of internal faces
const Graphic3d_MaterialAspect& BackMaterial() const { return myBackMaterial; }
//! Returns the surface material of internal faces
Graphic3d_MaterialAspect& ChangeBackMaterial() { return myBackMaterial; }
//! Modifies the surface material of internal faces
void SetBackMaterial (const Graphic3d_MaterialAspect& theMaterial) { myBackMaterial = theMaterial; }
//! Returns true if back faces should be suppressed (true by default).
bool ToSuppressBackFaces() const { return myToSuppressBackFaces; }
//! Assign back faces culling flag.
void SetSuppressBackFaces (bool theToSuppress) { myToSuppressBackFaces = theToSuppress; }
//! Returns true if back faces should be suppressed (true by default).
bool BackFace() const { return myToSuppressBackFaces; }
//! Allows the display of back-facing filled polygons.
void AllowBackFace() { myToSuppressBackFaces = false; }
//! Suppress the display of back-facing filled polygons.
//! A back-facing polygon is defined as a polygon whose
//! vertices are in a clockwise order with respect to screen coordinates.
void SuppressBackFace() { myToSuppressBackFaces = true; }
//! Returns true if material properties should be distinguished for back and front faces (false by default).
bool Distinguish() const { return myToDistinguishMaterials; }
//! Set material distinction between front and back faces.
void SetDistinguish (bool toDistinguish) { myToDistinguishMaterials = toDistinguish; }
//! Allows material distinction between front and back faces.
void SetDistinguishOn() { myToDistinguishMaterials = true; }
//! Forbids material distinction between front and back faces.
void SetDistinguishOff() { myToDistinguishMaterials = false; }
//! Return shader program.
const Handle(Graphic3d_ShaderProgram)& ShaderProgram() const { return myProgram; }
//! Sets up OpenGL/GLSL shader program.
void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram) { myProgram = theProgram; }
//! Return texture array to be mapped.
const Handle(Graphic3d_TextureSet)& TextureSet() const { return myTextureSet; }
//! Setup texture array to be mapped.
void SetTextureSet (const Handle(Graphic3d_TextureSet)& theTextures) { myTextureSet = theTextures; }
//! Return texture to be mapped.
//Standard_DEPRECATED("Deprecated method, TextureSet() should be used instead")
Handle(Graphic3d_TextureMap) TextureMap() const
{
return !myTextureSet.IsNull() && !myTextureSet->IsEmpty()
? myTextureSet->First()
: Handle(Graphic3d_TextureMap)();
}
//! Assign texture to be mapped.
//! See also SetTextureMapOn() to actually activate texture mapping.
//Standard_DEPRECATED("Deprecated method, SetTextureSet() should be used instead")
Standard_EXPORT void SetTextureMap (const Handle(Graphic3d_TextureMap)& theTexture);
//! Return true if texture mapping is enabled (false by default).
bool ToMapTexture() const { return myToMapTexture; }
//! Return true if texture mapping is enabled (false by default).
bool TextureMapState() const { return myToMapTexture; }
//! Enable or disable texture mapping (has no effect if texture is not set).
void SetTextureMapOn (bool theToMap) { myToMapTexture = theToMap; }
//! Enable texture mapping (has no effect if texture is not set).
void SetTextureMapOn() { myToMapTexture = true; }
//! Disable texture mapping.
void SetTextureMapOff() { myToMapTexture = false; }
//! Returns current polygon offsets settings.
const Graphic3d_PolygonOffset& PolygonOffset() const { return myPolygonOffset; }
//! Sets polygon offsets settings.
void SetPolygonOffset (const Graphic3d_PolygonOffset& theOffset) { myPolygonOffset = theOffset; }
//! Returns current polygon offsets settings.
void PolygonOffsets (Standard_Integer& theMode,
Standard_ShortReal& theFactor,
Standard_ShortReal& theUnits) const
{
theMode = myPolygonOffset.Mode;
theFactor = myPolygonOffset.Factor;
theUnits = myPolygonOffset.Units;
}
//! Sets up OpenGL polygon offsets mechanism.
//! <aMode> parameter can contain various combinations of
//! Aspect_PolygonOffsetMode enumeration elements (Aspect_POM_None means
//! that polygon offsets are not changed).
//! If <aMode> is different from Aspect_POM_Off and Aspect_POM_None, then <aFactor> and <aUnits>
//! arguments are used by graphic renderer to calculate a depth offset value:
//!
//! offset = <aFactor> * m + <aUnits> * r, where
//! m - maximum depth slope for the polygon currently being displayed,
//! r - minimum window coordinates depth resolution (implementation-specific)
//!
//! Default settings for OCC 3D viewer: mode = Aspect_POM_Fill, factor = 1., units = 0.
//!
//! Negative offset values move polygons closer to the viewport,
//! while positive values shift polygons away.
//! Consult OpenGL reference for details (glPolygonOffset function description).
void SetPolygonOffsets (const Standard_Integer theMode,
const Standard_ShortReal theFactor = 1.0f,
const Standard_ShortReal theUnits = 0.0f)
{
myPolygonOffset.Mode = (Aspect_PolygonOffsetMode )(theMode & Aspect_POM_Mask);
myPolygonOffset.Factor = theFactor;
myPolygonOffset.Units = theUnits;
}
public:
Standard_DEPRECATED("Deprecated method, ToDrawEdges() should be used instead")
//! Returns true if edges should be drawn (false by default).
bool ToDrawEdges() const { return myToDrawEdges && myEdgeType != Aspect_TOL_EMPTY; }
//! Set if edges should be drawn or not.
void SetDrawEdges (bool theToDraw)
{
myToDrawEdges = theToDraw;
if (myEdgeType == Aspect_TOL_EMPTY)
{
myEdgeType = Aspect_TOL_SOLID;
}
}
//! Returns true if edges should be drawn.
bool Edge() const { return ToDrawEdges(); }
//! The edges of FillAreas are drawn.
void SetEdgeOn() { SetDrawEdges (true); }
//! The edges of FillAreas are not drawn.
void SetEdgeOff() { SetDrawEdges (false); }
//! Return color of edges.
const Quantity_Color& EdgeColor() const { return myEdgeColor.GetRGB(); }
//! Return color of edges.
const Quantity_ColorRGBA& EdgeColorRGBA() const { return myEdgeColor; }
//! Modifies the color of the edge of the face
void SetEdgeColor (const Quantity_Color& theColor) { myEdgeColor.SetRGB (theColor); }
//! Modifies the color of the edge of the face
void SetEdgeColor (const Quantity_ColorRGBA& theColor) { myEdgeColor = theColor; }
//! Return edges line type.
Aspect_TypeOfLine EdgeLineType() const { return myEdgeType; }
//! Modifies the edge line type
void SetEdgeLineType (const Aspect_TypeOfLine theType) { myEdgeType = theType; }
//! Return width for edges in pixels.
Standard_ShortReal EdgeWidth() const { return myEdgeWidth; }
//! Modifies the edge thickness
//! Warning: Raises AspectFillAreaDefinitionError if the width is a negative value.
void SetEdgeWidth (const Standard_Real theWidth)
{
if (theWidth <= 0.0)
{
throw Aspect_AspectFillAreaDefinitionError("Bad value for EdgeLineWidth");
}
myEdgeWidth = (float )theWidth;
}
//! Returns TRUE if drawing element edges should discard first edge in triangle; FALSE by default.
//! Graphics hardware works mostly with triangles, so that wireframe presentation will draw triangle edges by default.
//! This flag allows rendering wireframe presentation of quad-only array split into triangles.
//! For this, quads should be split in specific order, so that the quad diagonal (to be NOT rendered) goes first:
//! 1------2
//! / / Triangle #1: 2-0-1; Triangle #2: 0-2-3
//! 0------3
bool ToSkipFirstEdge() const { return myToSkipFirstEdge; }
//! Set skip first triangle edge flag for drawing wireframe presentation of quads array split into triangles.
void SetSkipFirstEdge (bool theToSkipFirstEdge) { myToSkipFirstEdge = theToSkipFirstEdge; }
//! Returns TRUE if silhouette (outline) should be drawn (with edge color and width); FALSE by default.
bool ToDrawSilhouette() const { return myToDrawSilhouette; }
//! Enables/disables drawing silhouette (outline).
void SetDrawSilhouette (bool theToDraw) { myToDrawSilhouette = theToDraw; }
public:
//! Returns the hatch type used when InteriorStyle is IS_HATCH
const Handle(Graphic3d_HatchStyle)& HatchStyle() const { return myHatchStyle; }
//! Modifies the hatch type used when InteriorStyle is IS_HATCH
void SetHatchStyle (const Handle(Graphic3d_HatchStyle)& theStyle) { myHatchStyle = theStyle; }
//! Modifies the hatch type used when InteriorStyle is IS_HATCH
//! @warning This method always creates a new handle for a given hatch style
void SetHatchStyle (const Aspect_HatchStyle theStyle)
{
if (theStyle == Aspect_HS_SOLID)
{
myHatchStyle.Nullify();
return;
}
myHatchStyle = new Graphic3d_HatchStyle (theStyle);
}
//! Returns the current values.
Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters")
void Values (Aspect_InteriorStyle& theStyle,
Quantity_Color& theIntColor,
Quantity_Color& theEdgeColor,
Aspect_TypeOfLine& theType,
Standard_Real& theWidth) const
{
theStyle = myInteriorStyle;
theIntColor = myInteriorColor.GetRGB();
theEdgeColor= myEdgeColor.GetRGB();
theType = myEdgeType;
theWidth = myEdgeWidth;
}
//! Returns the current values.
Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters")
void Values (Aspect_InteriorStyle& theStyle,
Quantity_Color& theIntColor,
Quantity_Color& theBackIntColor,
Quantity_Color& theEdgeColor,
Aspect_TypeOfLine& theType,
Standard_Real& theWidth) const
{
theStyle = myInteriorStyle;
theIntColor = myInteriorColor.GetRGB();
theBackIntColor= myBackInteriorColor.GetRGB();
theEdgeColor = myEdgeColor.GetRGB();
theType = myEdgeType;
theWidth = myEdgeWidth;
}
protected:
Handle(Graphic3d_ShaderProgram) myProgram;
Handle(Graphic3d_TextureSet) myTextureSet;
Graphic3d_MaterialAspect myFrontMaterial;
Graphic3d_MaterialAspect myBackMaterial;
Quantity_ColorRGBA myInteriorColor;
Quantity_ColorRGBA myBackInteriorColor;
Quantity_ColorRGBA myEdgeColor;
Aspect_InteriorStyle myInteriorStyle;
Graphic3d_TypeOfShadingModel myShadingModel;
Graphic3d_AlphaMode myAlphaMode;
Standard_ShortReal myAlphaCutoff;
Aspect_TypeOfLine myEdgeType;
Standard_ShortReal myEdgeWidth;
Handle(Graphic3d_HatchStyle) myHatchStyle;
Graphic3d_PolygonOffset myPolygonOffset;
bool myToSkipFirstEdge;
bool myToDistinguishMaterials;
bool myToDrawEdges;
bool myToDrawSilhouette;
bool myToSuppressBackFaces;
bool myToMapTexture;
};
DEFINE_STANDARD_HANDLE(Graphic3d_AspectFillArea3d, Graphic3d_Aspects)
DEFINE_STANDARD_HANDLE(Graphic3d_AspectFillArea3d, Standard_Transient)
#endif // _Graphic3d_AspectFillArea3d_HeaderFile

View File

@@ -15,30 +15,33 @@
#include <Graphic3d_AspectLine3d.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectLine3d, Graphic3d_Aspects)
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectLine3d, Standard_Transient)
// =======================================================================
// function : Graphic3d_AspectLine3d
// purpose :
// =======================================================================
Graphic3d_AspectLine3d::Graphic3d_AspectLine3d()
: myColor (Quantity_NOC_YELLOW),
myType (Aspect_TOL_SOLID),
myWidth (1.0f)
{
myShadingModel = Graphic3d_TOSM_UNLIT;
myInteriorColor.SetRGB (Quantity_NOC_YELLOW);
myLineType = Aspect_TOL_SOLID;
myLineWidth = 1.0f;
//
}
// =======================================================================
// function : Graphic3d_AspectLine3d
// purpose :
// =======================================================================
Graphic3d_AspectLine3d::Graphic3d_AspectLine3d (const Quantity_Color& theColor,
Aspect_TypeOfLine theType,
Standard_Real theWidth)
Graphic3d_AspectLine3d::Graphic3d_AspectLine3d (const Quantity_Color& theColor,
const Aspect_TypeOfLine theType,
const Standard_Real theWidth)
: myColor (theColor),
myType (theType),
myWidth ((float )theWidth)
{
myShadingModel = Graphic3d_TOSM_UNLIT;
myInteriorColor.SetRGB (theColor);
myLineType = theType;
SetLineWidth ((float)theWidth);
if (myWidth <= 0.0f)
{
throw Aspect_AspectLineDefinitionError("Graphic3d_AspectLine3d, Bad value for LineWidth");
}
}

View File

@@ -16,13 +16,19 @@
#ifndef _Graphic3d_AspectLine3d_HeaderFile
#define _Graphic3d_AspectLine3d_HeaderFile
#include <Graphic3d_Aspects.hxx>
#include <Aspect_AspectLineDefinitionError.hxx>
#include <Aspect_TypeOfLine.hxx>
#include <Graphic3d_ShaderProgram.hxx>
#include <Standard.hxx>
#include <Standard_Real.hxx>
#include <Standard_Type.hxx>
#include <Quantity_ColorRGBA.hxx>
//! Creates and updates a group of attributes for 3d line primitives.
//! This group contains the color, the type of line, and its thickness.
class Graphic3d_AspectLine3d : public Graphic3d_Aspects
class Graphic3d_AspectLine3d : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectLine3d, Graphic3d_Aspects)
DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectLine3d, Standard_Transient)
public:
//! Creates a context table for line primitives
@@ -38,32 +44,85 @@ public:
//! The nominal line width is 1 pixel.
//! The width of the line is determined by applying the line width scale factor to this nominal line width.
//! The supported line widths vary by 1-pixel units.
Standard_EXPORT Graphic3d_AspectLine3d (const Quantity_Color& theColor,
Aspect_TypeOfLine theType,
Standard_Real theWidth);
Standard_EXPORT Graphic3d_AspectLine3d (const Quantity_Color& theColor,
const Aspect_TypeOfLine theType,
const Standard_Real theWidth);
//! Return color.
const Quantity_ColorRGBA& ColorRGBA() const { return myColor; }
//! Return color.
const Quantity_Color& Color() const { return myColor.GetRGB(); }
//! Modifies the color.
void SetColor (const Quantity_Color& theColor) { myColor.SetRGB (theColor); }
//! Return line type.
Aspect_TypeOfLine Type() const { return myLineType; }
Aspect_TypeOfLine Type() const { return myType; }
//! Modifies the type of line.
void SetType (const Aspect_TypeOfLine theType) { myLineType = theType; }
void SetType (const Aspect_TypeOfLine theType) { myType = theType; }
//! Return line width.
Standard_ShortReal Width() const { return myLineWidth; }
Standard_ShortReal Width() const { return myWidth; }
//! Modifies the line thickness.
//! Warning: Raises Standard_OutOfRange if the width is a negative value.
//! Warning: Raises AspectLineDefinitionError if the width is a negative value.
void SetWidth (const Standard_Real theWidth) { SetWidth ((float )theWidth); }
//! Modifies the line thickness.
//! Warning: Raises Standard_OutOfRange if the width is a negative value.
void SetWidth (Standard_ShortReal theWidth)
//! Warning: Raises AspectLineDefinitionError if the width is a negative value.
void SetWidth (const Standard_ShortReal theWidth)
{
SetLineWidth (theWidth);
if (theWidth <= 0.0f)
{
throw Aspect_AspectLineDefinitionError("Graphic3d_AspectLine3d, Bad value for LineWidth");
}
myWidth = theWidth;
}
//! Return shader program.
const Handle(Graphic3d_ShaderProgram)& ShaderProgram() const { return myProgram; }
//! Sets up OpenGL/GLSL shader program.
void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram) { myProgram = theProgram; }
//! Check for equality with another line aspect.
bool IsEqual (const Graphic3d_AspectLine3d& theOther)
{
if (this == &theOther)
{
return true;
}
return myProgram == theOther.myProgram
&& myType == theOther.myType
&& myColor == theOther.myColor
&& myWidth == theOther.myWidth;
}
public:
//! Returns the current values of the group.
Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters")
void Values (Quantity_Color& theColor,
Aspect_TypeOfLine& theType,
Standard_Real& theWidth) const
{
theColor = myColor.GetRGB();
theType = myType;
theWidth = myWidth;
}
protected:
Handle(Graphic3d_ShaderProgram) myProgram;
Quantity_ColorRGBA myColor;
Aspect_TypeOfLine myType;
Standard_ShortReal myWidth;
};
DEFINE_STANDARD_HANDLE(Graphic3d_AspectLine3d, Graphic3d_Aspects)
DEFINE_STANDARD_HANDLE(Graphic3d_AspectLine3d, Standard_Transient)
#endif // _Graphic3d_AspectLine3d_HeaderFile

View File

@@ -15,18 +15,18 @@
#include <Graphic3d_AspectMarker3d.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectMarker3d, Graphic3d_Aspects)
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectMarker3d, Standard_Transient)
// =======================================================================
// function : Graphic3d_AspectMarker3d
// purpose :
// =======================================================================
Graphic3d_AspectMarker3d::Graphic3d_AspectMarker3d()
: myColor (Quantity_NOC_YELLOW),
myType (Aspect_TOM_X),
myScale (1.0f)
{
myShadingModel = Graphic3d_TOSM_UNLIT;
myInteriorColor.SetRGB (Quantity_NOC_YELLOW);
myMarkerType = Aspect_TOM_X;
myMarkerScale = 1.0f;
//
}
// =======================================================================
@@ -36,11 +36,14 @@ Graphic3d_AspectMarker3d::Graphic3d_AspectMarker3d()
Graphic3d_AspectMarker3d::Graphic3d_AspectMarker3d (const Aspect_TypeOfMarker theType,
const Quantity_Color& theColor,
const Standard_Real theScale)
: myColor (theColor),
myType (theType),
myScale ((float )theScale)
{
myShadingModel = Graphic3d_TOSM_UNLIT;
myInteriorColor.SetRGB (theColor);
myMarkerType = theType;
SetMarkerScale ((float )theScale);
if (theScale <= 0.0)
{
throw Aspect_AspectMarkerDefinitionError("Bad value for MarkerScale");
}
}
// =======================================================================
@@ -51,12 +54,12 @@ Graphic3d_AspectMarker3d::Graphic3d_AspectMarker3d (const Quantity_Color& theCo
const Standard_Integer theWidth,
const Standard_Integer theHeight,
const Handle(TColStd_HArray1OfByte)& theTextureBitMap)
: myMarkerImage (new Graphic3d_MarkerImage (theTextureBitMap, theWidth, theHeight)),
myColor (theColor),
myType (Aspect_TOM_USERDEFINED),
myScale (1.0f)
{
myShadingModel = Graphic3d_TOSM_UNLIT;
myMarkerImage = new Graphic3d_MarkerImage(theTextureBitMap, theWidth, theHeight);
myInteriorColor.SetRGB (theColor),
myMarkerType = Aspect_TOM_USERDEFINED;
myMarkerScale = 1.0f;
//
}
// =======================================================================
@@ -64,12 +67,12 @@ Graphic3d_AspectMarker3d::Graphic3d_AspectMarker3d (const Quantity_Color& theCo
// purpose :
// =======================================================================
Graphic3d_AspectMarker3d::Graphic3d_AspectMarker3d (const Handle(Image_PixMap)& theTextureImage)
: myMarkerImage (new Graphic3d_MarkerImage (theTextureImage)),
myColor (Quantity_NOC_YELLOW),
myType (Aspect_TOM_USERDEFINED),
myScale (1.0f)
{
myShadingModel = Graphic3d_TOSM_UNLIT;
myMarkerImage = new Graphic3d_MarkerImage (theTextureImage);
myInteriorColor.SetRGB (Quantity_NOC_YELLOW);
myMarkerType = Aspect_TOM_USERDEFINED;
myMarkerScale = 1.0f;
//
}
// =======================================================================

View File

@@ -16,13 +16,23 @@
#ifndef _Graphic3d_AspectMarker3d_HeaderFile
#define _Graphic3d_AspectMarker3d_HeaderFile
#include <Graphic3d_Aspects.hxx>
#include <Aspect_AspectMarkerDefinitionError.hxx>
#include <Aspect_TypeOfMarker.hxx>
#include <Graphic3d_MarkerImage.hxx>
#include <Graphic3d_ShaderProgram.hxx>
#include <Image_PixMap.hxx>
#include <Standard.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Real.hxx>
#include <Standard_Type.hxx>
#include <TColStd_HArray1OfByte.hxx>
#include <Quantity_ColorRGBA.hxx>
//! Creates and updates an attribute group for marker type primitives.
//! This group contains the type of marker, its color, and its scale factor.
class Graphic3d_AspectMarker3d : public Graphic3d_Aspects
class Graphic3d_AspectMarker3d : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectMarker3d, Graphic3d_Aspects)
DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectMarker3d, Standard_Transient)
public:
//! Creates a context table for marker primitives
@@ -43,26 +53,39 @@ public:
//! defined with the specified values.
Standard_EXPORT Graphic3d_AspectMarker3d(const Handle(Image_PixMap)& theTextureImage);
//! Return color.
const Quantity_ColorRGBA& ColorRGBA() const { return myColor; }
//! Return the color.
const Quantity_Color& Color() const { return myColor.GetRGB(); }
//! Modifies the color.
void SetColor (const Quantity_Color& theColor) { myColor.SetRGB (theColor); }
//! Return scale factor.
Standard_ShortReal Scale() const { return myMarkerScale; }
Standard_ShortReal Scale() const { return myScale; }
//! Modifies the scale factor.
//! Marker type Aspect_TOM_POINT is not affected by the marker size scale factor.
//! It is always the smallest displayable dot.
//! Warning: Raises Standard_OutOfRange if the scale is a negative value.
//! Warning: Raises AspectMarkerDefinitionError if the scale is a negative value.
void SetScale (const Standard_ShortReal theScale)
{
SetMarkerScale (theScale);
if (theScale <= 0.0f)
{
throw Aspect_AspectMarkerDefinitionError("Bad value for MarkerScale");
}
myScale = theScale;
}
//! Assign scale factor.
void SetScale (const Standard_Real theScale) { SetScale ((float )theScale); }
//! Return marker type.
Aspect_TypeOfMarker Type() const { return myMarkerType; }
Aspect_TypeOfMarker Type() const { return myType; }
//! Modifies the type of marker.
void SetType (const Aspect_TypeOfMarker theType) { myMarkerType = theType; }
void SetType (const Aspect_TypeOfMarker theType) { myType = theType; }
//! Returns marker's texture size.
Standard_EXPORT void GetTextureSize (Standard_Integer& theWidth, Standard_Integer& theHeight) const;
@@ -71,10 +94,40 @@ public:
//! Could be null handle if marker aspect has been initialized as default type of marker.
const Handle(Graphic3d_MarkerImage)& GetMarkerImage() const { return myMarkerImage; }
//! Set marker's image texture.
void SetMarkerImage (const Handle(Graphic3d_MarkerImage)& theImage) { myMarkerImage = theImage; }
Standard_EXPORT void SetBitMap (const Standard_Integer theWidth, const Standard_Integer theHeight, const Handle(TColStd_HArray1OfByte)& theTexture);
//! Return the program.
const Handle(Graphic3d_ShaderProgram)& ShaderProgram() const { return myProgram; }
//! Sets up OpenGL/GLSL shader program.
void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram) { myProgram = theProgram; }
public:
//! Returns the current values of the group.
Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters")
void Values (Quantity_Color& theColor,
Aspect_TypeOfMarker& theType,
Standard_Real& theScale) const
{
theColor = myColor.GetRGB();
theType = myType;
theScale = myScale;
}
protected:
Handle(Graphic3d_ShaderProgram) myProgram;
Handle(Graphic3d_MarkerImage) myMarkerImage;
Quantity_ColorRGBA myColor;
Aspect_TypeOfMarker myType;
Standard_ShortReal myScale;
};
DEFINE_STANDARD_HANDLE(Graphic3d_AspectMarker3d, Graphic3d_Aspects)
DEFINE_STANDARD_HANDLE(Graphic3d_AspectMarker3d, Standard_Transient)
#endif // _Graphic3d_AspectMarker3d_HeaderFile

View File

@@ -15,43 +15,55 @@
#include <Graphic3d_AspectText3d.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectText3d, Graphic3d_Aspects)
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectText3d, Standard_Transient)
// =======================================================================
// function : Graphic3d_AspectText3d
// purpose :
// =======================================================================
Graphic3d_AspectText3d::Graphic3d_AspectText3d()
: myFont (Font_NOF_ASCII_MONO),
myColor (Quantity_NOC_YELLOW),
myFactor (1.0),
mySpace (0.0),
myStyle (Aspect_TOST_NORMAL),
myDisplayType (Aspect_TODT_NORMAL),
myColorSubTitle (Quantity_NOC_WHITE),
myTextZoomable (false),
myTextAngle (0.0),
myTextFontAspect(Font_FA_Regular)
{
// actually this should be a special state Graphic3d_AlphaMode_MaskBlend
// since text is drawn in usual order with normal opaque objects (thanks to alpha test),
// but blending is also enabled to smoothen boundaries
SetAlphaMode (Graphic3d_AlphaMode_Mask, 0.285f);
myShadingModel = Graphic3d_TOSM_UNLIT;
myInteriorColor.SetRGB (Quantity_NOC_YELLOW);
myEdgeColor.SetRGB (Quantity_NOC_WHITE);
//
}
// =======================================================================
// function : Graphic3d_AspectText3d
// purpose :
// =======================================================================
Graphic3d_AspectText3d::Graphic3d_AspectText3d (const Quantity_Color& theColor,
Standard_CString theFont,
Standard_Real ,
Standard_Real ,
Aspect_TypeOfStyleText theStyle,
Aspect_TypeOfDisplayText theDisplayType)
Graphic3d_AspectText3d::Graphic3d_AspectText3d (const Quantity_Color& theColor,
const Standard_CString theFont,
const Standard_Real theExpansionFactor,
const Standard_Real theSpace,
const Aspect_TypeOfStyleText theStyle,
const Aspect_TypeOfDisplayText theDisplayType)
: myFont (theFont),
myColor (theColor),
myFactor (theExpansionFactor),
mySpace (theSpace),
myStyle (theStyle),
myDisplayType (theDisplayType),
myColorSubTitle (Quantity_NOC_WHITE),
myTextZoomable (false),
myTextAngle (0.0),
myTextFontAspect(Font_FA_Regular)
{
SetAlphaMode (Graphic3d_AlphaMode_Mask, 0.285f);
myShadingModel = Graphic3d_TOSM_UNLIT;
myTextStyle = theStyle;
myTextDisplayType = theDisplayType;
myInteriorColor.SetRGB (theColor);
myEdgeColor.SetRGB (Quantity_NOC_WHITE);
if (theFont != NULL
&& *theFont != '\0')
if (myFont.IsEmpty())
{
myTextFont = new TCollection_HAsciiString (theFont);
myFont = Font_NOF_ASCII_MONO;
}
if (theExpansionFactor <= 0.0)
{
throw Graphic3d_AspectTextDefinitionError("Bad value for TextScaleFactor");
}
}

View File

@@ -16,69 +16,89 @@
#ifndef _Graphic3d_AspectText3d_HeaderFile
#define _Graphic3d_AspectText3d_HeaderFile
#include <Graphic3d_Aspects.hxx>
#include <Aspect_TypeOfStyleText.hxx>
#include <Aspect_TypeOfDisplayText.hxx>
#include <Graphic3d_AspectTextDefinitionError.hxx>
#include <Graphic3d_ShaderProgram.hxx>
#include <Font_FontAspect.hxx>
#include <Font_NameOfFont.hxx>
#include <Standard_Transient.hxx>
#include <Standard.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_Real.hxx>
#include <Standard_Type.hxx>
#include <TCollection_AsciiString.hxx>
#include <Quantity_ColorRGBA.hxx>
//! Creates and updates a group of attributes for text primitives.
class Graphic3d_AspectText3d : public Graphic3d_Aspects
//! Creates and updates a group of attributes for
//! text primitives. This group contains the color,
//! font, expansion factor (height/width ratio), and
//! inter-character space.
//!
//! NOTE: The font name is stored in the aspect instance
//! so it is safe to pass it as const char* to OpenGl package
//! without copying the string. However, the aspect should not
//! be deleted until the text drawn using this aspect is no longer
//! visible. The best practice is to keep the aspect in the object's drawer.
class Graphic3d_AspectText3d : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectText3d, Graphic3d_Aspects)
DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectText3d, Standard_Transient)
public:
//! Creates a context table for text primitives defined with the following default values:
//! Color : Quantity_NOC_YELLOW
//! Font : Font_NOF_ASCII_MONO
//! The style : Aspect_TOST_NORMAL
//! The display type : Aspect_TODT_NORMAL
//! Creates a context table for text primitives
//! defined with the following default values:
//!
//! Color : NOC_YELLOW
//! Font : NOF_ASCII_MONO
//! Expansion factor : 1.
//! Space between characters : 0.
//! The style : TOST_NORMAL
//! The display type : TODT_NORMAL
Standard_EXPORT Graphic3d_AspectText3d();
//! Creates a context table for text primitives defined with the specified values.
//! @param theColor [in] text color
//! @param theFont [in] font family name or alias like Font_NOF_ASCII_MONO
//! @param theExpansionFactor [in] deprecated parameter, has no effect
//! @param theSpace [in] deprecated parameter, has no effect
//! @param theStyle [in] font style
//! @param theDisplayType [in] display mode
Standard_EXPORT Graphic3d_AspectText3d (const Quantity_Color& theColor,
Standard_CString theFont,
Standard_Real theExpansionFactor,
Standard_Real theSpace,
Aspect_TypeOfStyleText theStyle = Aspect_TOST_NORMAL,
Aspect_TypeOfDisplayText theDisplayType = Aspect_TODT_NORMAL);
//! Creates a context table for text primitives
//! defined with the specified values.
//! AFont may be to take means from User(example "Courier New")
//! or Font name defined in Font_NameOfFont(example Font_NOF_ASCII_MONO)
//! or use default font("Courier")
Standard_EXPORT Graphic3d_AspectText3d (const Quantity_Color& theColor,
const Standard_CString theFont,
const Standard_Real theExpansionFactor,
const Standard_Real theSpace,
const Aspect_TypeOfStyleText theStyle = Aspect_TOST_NORMAL,
const Aspect_TypeOfDisplayText theDisplayType = Aspect_TODT_NORMAL);
//! Return the text color.
const Quantity_Color& Color() const { return myInteriorColor.GetRGB(); }
const Quantity_Color& Color() const { return myColor.GetRGB(); }
//! Return the text color.
const Quantity_ColorRGBA& ColorRGBA() const { return myInteriorColor; }
const Quantity_ColorRGBA& ColorRGBA() const { return myColor; }
//! Modifies the color.
void SetColor (const Quantity_Color& theColor) { myInteriorColor.SetRGB (theColor); }
void SetColor (const Quantity_Color& theColor) { myColor.SetRGB (theColor); }
//! Modifies the color.
void SetColor (const Quantity_ColorRGBA& theColor) { myInteriorColor = theColor; }
void SetColor (const Quantity_ColorRGBA& theColor) { myColor = theColor; }
//! Modifies the expansion factor (height/width ratio)
//! If the factor is less than 1, the characters will
//! be higher than they are wide.
void SetExpansionFactor (const Standard_Real theFactor)
{
if (theFactor <= 0.0)
{
throw Graphic3d_AspectTextDefinitionError("Bad value for TextScaleFactor");
}
myFactor = theFactor;
}
//! Return the font.
const TCollection_AsciiString& Font() const
{
if (myTextFont.IsNull())
{
static const TCollection_AsciiString anEmpty;
return anEmpty;
}
return myTextFont->String();
}
const TCollection_AsciiString& Font() const { return myFont; }
//! Modifies the font.
void SetFont (const TCollection_AsciiString& theFont)
{
if (!theFont.IsEmpty())
{
myTextFont = new TCollection_HAsciiString (theFont);
}
else
{
myTextFont.Nullify();
}
myFont = !theFont.IsEmpty() ? theFont : TCollection_AsciiString (Font_NOF_ASCII_MONO);
}
//! Modifies the font.
@@ -87,32 +107,174 @@ public:
SetFont (TCollection_AsciiString (theFont));
}
//! Return the space between characters.
Standard_Real Space() const { return mySpace; }
//! Modifies the space between the characters.
void SetSpace (const Standard_Real theSpace) { mySpace = theSpace; }
//! Return the text style.
Aspect_TypeOfStyleText Style() const { return myTextStyle; }
Aspect_TypeOfStyleText Style() const { return myStyle; }
//! Modifies the style of the text.
void SetStyle (Aspect_TypeOfStyleText theStyle) { myTextStyle = theStyle; }
//! * TOST_NORMAL
//! Default text. The text is displayed like any other graphic object.
//! This text can be hidden by another object that is nearest from the point of view.
//! * TOST_ANNOTATION
//! The text is always visible.
//! The text is displayed over the other object according to the priority.
void SetStyle (const Aspect_TypeOfStyleText theStyle) { myStyle = theStyle; }
//! Return display type.
Aspect_TypeOfDisplayText DisplayType() const { return myTextDisplayType; }
Aspect_TypeOfDisplayText DisplayType() const { return myDisplayType; }
//! Define the display type of the text.
void SetDisplayType (Aspect_TypeOfDisplayText theDisplayType) { myTextDisplayType = theDisplayType; }
//!
//! TODT_NORMAL Default display. Text only.
//! TODT_SUBTITLE There is a subtitle under the text.
//! TODT_DEKALE The text is displayed with a 3D style.
//! TODT_BLEND The text is displayed in XOR.
//! TODT_DIMENSION Dimension line under text will be invisible.
void SetDisplayType (const Aspect_TypeOfDisplayText theDisplayType) { myDisplayType = theDisplayType; }
//! Return subtitle color.
const Quantity_ColorRGBA& ColorSubTitleRGBA() const { return myColorSubTitle; }
//! Return subtitle color.
const Quantity_Color& ColorSubTitle() const { return myColorSubTitle.GetRGB(); }
//! Modifies the color of the subtitle for the TODT_SUBTITLE TextDisplayType
//! and the color of background for the TODT_DEKALE TextDisplayType.
void SetColorSubTitle (const Quantity_Color& theColor) { myColorSubTitle.SetRGB (theColor); }
//! Modifies the color of the subtitle for the TODT_SUBTITLE TextDisplayType
//! and the color of background for the TODT_DEKALE TextDisplayType.
void SetColorSubTitle (const Quantity_ColorRGBA& theColor) { myColorSubTitle = theColor; }
//! Returns TRUE when the Text Zoomable is on.
bool GetTextZoomable() const { return myIsTextZoomable; }
bool GetTextZoomable() const { return myTextZoomable; }
//! Turns usage of text zoomable on/off
void SetTextZoomable (const bool theFlag) { myTextZoomable = theFlag; }
//! Returns Angle of degree
Standard_ShortReal GetTextAngle() const { return myTextAngle; }
Standard_Real GetTextAngle() const { return myTextAngle; }
//! Turns usage of text rotated
void SetTextAngle (const Standard_Real theAngle) { myTextAngle = (Standard_ShortReal )theAngle; }
void SetTextAngle (const Standard_Real theAngle) { myTextAngle = theAngle; }
//! Returns text FontAspect
Font_FontAspect GetTextFontAspect() const { return myTextFontAspect; }
//! Turns usage of Aspect text
void SetTextFontAspect (const Font_FontAspect theFontAspect) { myTextFontAspect = theFontAspect; }
//! Return the shader program.
const Handle(Graphic3d_ShaderProgram)& ShaderProgram() const { return myProgram; }
//! Sets up OpenGL/GLSL shader program.
void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram) { myProgram = theProgram; }
public:
//! Returns the current values of the group.
Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters")
void Values (Quantity_Color& theColor,
Standard_CString& theFont,
Standard_Real& theExpansionFactor,
Standard_Real& theSpace) const
{
theColor = myColor.GetRGB();
theFont = myFont.ToCString();
theExpansionFactor = myFactor;
theSpace = mySpace;
}
//! Returns the current values of the group.
Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters")
void Values (Quantity_Color& theColor,
Standard_CString& theFont,
Standard_Real& theExpansionFactor,
Standard_Real& theSpace,
Aspect_TypeOfStyleText& theStyle,
Aspect_TypeOfDisplayText& theDisplayType,
Quantity_Color& theColorSubTitle) const
{
theColor = myColor.GetRGB();
theFont = myFont.ToCString();
theExpansionFactor= myFactor;
theSpace = mySpace;
theStyle = myStyle;
theDisplayType = myDisplayType;
theColorSubTitle = myColorSubTitle.GetRGB();
}
//! Returns the current values of the group.
Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters")
void Values (Quantity_Color& theColor,
Standard_CString& theFont,
Standard_Real& theExpansionFactor,
Standard_Real& theSpace,
Aspect_TypeOfStyleText& theStyle,
Aspect_TypeOfDisplayText& theDisplayType,
Quantity_Color& theColorSubTitle,
Standard_Boolean& theTextZoomable,
Standard_Real& theTextAngle) const
{
theColor = myColor.GetRGB();
theFont = myFont.ToCString();
theExpansionFactor= myFactor;
theSpace = mySpace;
theStyle = myStyle;
theDisplayType = myDisplayType;
theColorSubTitle = myColorSubTitle.GetRGB();
theTextZoomable = myTextZoomable;
theTextAngle = myTextAngle;
}
//! Returns the current values of the group.
Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters")
void Values (Quantity_Color& theColor,
Standard_CString& theFont,
Standard_Real& theExpansionFactor,
Standard_Real& theSpace,
Aspect_TypeOfStyleText& theStyle,
Aspect_TypeOfDisplayText& theDisplayType,
Quantity_Color& theColorSubTitle,
Standard_Boolean& theTextZoomable,
Standard_Real& theTextAngle,
Font_FontAspect& theTextFontAspect) const
{
theColor = myColor.GetRGB();
theFont = myFont.ToCString();
theExpansionFactor= myFactor;
theSpace = mySpace;
theStyle = myStyle;
theDisplayType = myDisplayType;
theColorSubTitle = myColorSubTitle.GetRGB();
theTextZoomable = myTextZoomable;
theTextAngle = myTextAngle;
theTextFontAspect = myTextFontAspect;
}
protected:
TCollection_AsciiString myFont;
Quantity_ColorRGBA myColor;
Standard_Real myFactor;
Standard_Real mySpace;
Aspect_TypeOfStyleText myStyle;
Aspect_TypeOfDisplayText myDisplayType;
Quantity_ColorRGBA myColorSubTitle;
bool myTextZoomable;
Standard_Real myTextAngle;
Font_FontAspect myTextFontAspect;
Handle(Graphic3d_ShaderProgram) myProgram;
};
DEFINE_STANDARD_HANDLE(Graphic3d_AspectText3d, Graphic3d_Aspects)
DEFINE_STANDARD_HANDLE(Graphic3d_AspectText3d, Standard_Transient)
#endif // _Graphic3d_AspectText3d_HeaderFile

View File

@@ -0,0 +1,37 @@
// Created on: 1993-03-31
// Created by: NW,JPB,CAL
// Copyright (c) 1993-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 _Graphic3d_AspectTextDefinitionError_HeaderFile
#define _Graphic3d_AspectTextDefinitionError_HeaderFile
#include <Standard_Type.hxx>
#include <Standard_DefineException.hxx>
#include <Standard_SStream.hxx>
#include <Standard_OutOfRange.hxx>
class Graphic3d_AspectTextDefinitionError;
DEFINE_STANDARD_HANDLE(Graphic3d_AspectTextDefinitionError, Standard_OutOfRange)
#if !defined No_Exception && !defined No_Graphic3d_AspectTextDefinitionError
#define Graphic3d_AspectTextDefinitionError_Raise_if(CONDITION, MESSAGE) \
if (CONDITION) throw Graphic3d_AspectTextDefinitionError(MESSAGE);
#else
#define Graphic3d_AspectTextDefinitionError_Raise_if(CONDITION, MESSAGE)
#endif
DEFINE_STANDARD_EXCEPTION(Graphic3d_AspectTextDefinitionError, Standard_OutOfRange)
#endif // _Graphic3d_AspectTextDefinitionError_HeaderFile

View File

@@ -1,62 +0,0 @@
// Copyright (c) 2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Graphic3d_Aspects.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Aspects, Standard_Transient)
// =======================================================================
// function : Graphic3d_Aspects
// purpose :
// =======================================================================
Graphic3d_Aspects::Graphic3d_Aspects()
: myInteriorColor (Quantity_NOC_CYAN1),
myBackInteriorColor (Quantity_NOC_CYAN1),
myEdgeColor (Quantity_NOC_WHITE),
myInteriorStyle (Aspect_IS_SOLID),
myShadingModel (Graphic3d_TOSM_DEFAULT),
myAlphaMode (Graphic3d_AlphaMode_BlendAuto),
myAlphaCutoff (0.5f),
myLineType (Aspect_TOL_SOLID),
myLineWidth (1.0f),
myMarkerType (Aspect_TOM_POINT),
myMarkerScale (1.0f),
myTextStyle (Aspect_TOST_NORMAL),
myTextDisplayType (Aspect_TODT_NORMAL),
myTextFontAspect (Font_FontAspect_Regular),
myTextAngle (0.0f),
myToSkipFirstEdge (false),
myToDistinguishMaterials (false),
myToDrawEdges (false),
myToDrawSilhouette (false),
myToSuppressBackFaces (true),
myToMapTexture (false),
myIsTextZoomable (false)
{
//
}
// =======================================================================
// function : SetTextureMap
// purpose :
// =======================================================================
void Graphic3d_Aspects::SetTextureMap (const Handle(Graphic3d_TextureMap)& theTexture)
{
if (theTexture.IsNull())
{
myTextureSet.Nullify();
return;
}
myTextureSet = new Graphic3d_TextureSet (theTexture);
}

View File

@@ -1,510 +0,0 @@
// Copyright (c) 2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _Graphic3d_Aspects_HeaderFile
#define _Graphic3d_Aspects_HeaderFile
#include <Aspect_PolygonOffsetMode.hxx>
#include <Aspect_InteriorStyle.hxx>
#include <Aspect_TypeOfDisplayText.hxx>
#include <Aspect_TypeOfLine.hxx>
#include <Aspect_TypeOfMarker.hxx>
#include <Aspect_TypeOfStyleText.hxx>
#include <Font_FontAspect.hxx>
#include <Font_NameOfFont.hxx>
#include <Graphic3d_AlphaMode.hxx>
#include <Graphic3d_MarkerImage.hxx>
#include <Graphic3d_HatchStyle.hxx>
#include <Graphic3d_MaterialAspect.hxx>
#include <Graphic3d_PolygonOffset.hxx>
#include <Graphic3d_ShaderProgram.hxx>
#include <Graphic3d_TextureMap.hxx>
#include <Graphic3d_TextureSet.hxx>
#include <Graphic3d_TypeOfShadingModel.hxx>
#include <TCollection_HAsciiString.hxx>
//! This class defines graphic attributes.
class Graphic3d_Aspects : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(Graphic3d_Aspects, Standard_Transient)
public:
//! Creates a context table for drawing primitives defined with the following default values:
Standard_EXPORT Graphic3d_Aspects();
//! Return interior rendering style; Aspect_IS_SOLID by default.
Aspect_InteriorStyle InteriorStyle() const { return myInteriorStyle; }
//! Modifies the interior type used for rendering
void SetInteriorStyle (const Aspect_InteriorStyle theStyle) { myInteriorStyle = theStyle; }
//! Returns shading model; Graphic3d_TOSM_DEFAULT by default.
//! Graphic3d_TOSM_DEFAULT means that Shading Model set as default for entire Viewer will be used.
Graphic3d_TypeOfShadingModel ShadingModel() const { return myShadingModel; }
//! Sets shading model
void SetShadingModel (const Graphic3d_TypeOfShadingModel theShadingModel) { myShadingModel = theShadingModel; }
//! Returns the way how alpha value should be treated (Graphic3d_AlphaMode_BlendAuto by default, for backward compatibility).
Graphic3d_AlphaMode AlphaMode() const { return myAlphaMode; }
//! Returns alpha cutoff threshold, for discarding fragments within Graphic3d_AlphaMode_Mask mode (0.5 by default).
//! If the alpha value is greater than or equal to this value then it is rendered as fully opaque, otherwise, it is rendered as fully transparent.
Standard_ShortReal AlphaCutoff() const { return myAlphaCutoff; }
//! Defines the way how alpha value should be treated.
void SetAlphaMode (Graphic3d_AlphaMode theMode, Standard_ShortReal theAlphaCutoff = 0.5f)
{
myAlphaMode = theMode;
myAlphaCutoff = theAlphaCutoff;
}
//! Return color
const Quantity_ColorRGBA& ColorRGBA() const { return myInteriorColor; }
//! Return the color.
const Quantity_Color& Color() const { return myInteriorColor.GetRGB(); }
//! Modifies the color.
void SetColor (const Quantity_Color& theColor) { myInteriorColor.SetRGB(theColor); }
//! Return interior color.
const Quantity_Color& InteriorColor() const { return myInteriorColor.GetRGB(); }
//! Return interior color.
const Quantity_ColorRGBA& InteriorColorRGBA() const { return myInteriorColor; }
//! Modifies the color of the interior of the face
void SetInteriorColor (const Quantity_Color& theColor) { myInteriorColor.SetRGB (theColor); }
//! Modifies the color of the interior of the face
void SetInteriorColor (const Quantity_ColorRGBA& theColor) { myInteriorColor = theColor; }
//! Return back interior color.
const Quantity_Color& BackInteriorColor() const { return myBackInteriorColor.GetRGB(); }
//! Return back interior color.
const Quantity_ColorRGBA& BackInteriorColorRGBA() const { return myBackInteriorColor; }
//! Modifies the color of the interior of the back face
void SetBackInteriorColor (const Quantity_Color& theColor) { myBackInteriorColor.SetRGB (theColor); }
//! Modifies the color of the interior of the back face
void SetBackInteriorColor (const Quantity_ColorRGBA& theColor) { myBackInteriorColor = theColor; }
//! Returns the surface material of external faces
const Graphic3d_MaterialAspect& FrontMaterial() const { return myFrontMaterial; }
//! Returns the surface material of external faces
Graphic3d_MaterialAspect& ChangeFrontMaterial() { return myFrontMaterial; }
//! Modifies the surface material of external faces
void SetFrontMaterial (const Graphic3d_MaterialAspect& theMaterial) { myFrontMaterial = theMaterial; }
//! Returns the surface material of internal faces
const Graphic3d_MaterialAspect& BackMaterial() const { return myBackMaterial; }
//! Returns the surface material of internal faces
Graphic3d_MaterialAspect& ChangeBackMaterial() { return myBackMaterial; }
//! Modifies the surface material of internal faces
void SetBackMaterial (const Graphic3d_MaterialAspect& theMaterial) { myBackMaterial = theMaterial; }
//! Returns true if back faces should be suppressed (true by default).
bool ToSuppressBackFaces() const { return myToSuppressBackFaces; }
//! Assign back faces culling flag.
void SetSuppressBackFaces (bool theToSuppress) { myToSuppressBackFaces = theToSuppress; }
//! Returns true if back faces should be suppressed (true by default).
bool BackFace() const { return myToSuppressBackFaces; }
//! Allows the display of back-facing filled polygons.
void AllowBackFace() { myToSuppressBackFaces = false; }
//! Suppress the display of back-facing filled polygons.
//! A back-facing polygon is defined as a polygon whose
//! vertices are in a clockwise order with respect to screen coordinates.
void SuppressBackFace() { myToSuppressBackFaces = true; }
//! Returns true if material properties should be distinguished for back and front faces (false by default).
bool Distinguish() const { return myToDistinguishMaterials; }
//! Set material distinction between front and back faces.
void SetDistinguish (bool toDistinguish) { myToDistinguishMaterials = toDistinguish; }
//! Allows material distinction between front and back faces.
void SetDistinguishOn() { myToDistinguishMaterials = true; }
//! Forbids material distinction between front and back faces.
void SetDistinguishOff() { myToDistinguishMaterials = false; }
//! Return shader program.
const Handle(Graphic3d_ShaderProgram)& ShaderProgram() const { return myProgram; }
//! Sets up OpenGL/GLSL shader program.
void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram) { myProgram = theProgram; }
//! Return texture array to be mapped.
const Handle(Graphic3d_TextureSet)& TextureSet() const { return myTextureSet; }
//! Setup texture array to be mapped.
void SetTextureSet (const Handle(Graphic3d_TextureSet)& theTextures) { myTextureSet = theTextures; }
//! Return texture to be mapped.
//Standard_DEPRECATED("Deprecated method, TextureSet() should be used instead")
Handle(Graphic3d_TextureMap) TextureMap() const
{
return !myTextureSet.IsNull() && !myTextureSet->IsEmpty()
? myTextureSet->First()
: Handle(Graphic3d_TextureMap)();
}
//! Assign texture to be mapped.
//! See also SetTextureMapOn() to actually activate texture mapping.
//Standard_DEPRECATED("Deprecated method, SetTextureSet() should be used instead")
Standard_EXPORT void SetTextureMap (const Handle(Graphic3d_TextureMap)& theTexture);
//! Return true if texture mapping is enabled (false by default).
bool ToMapTexture() const { return myToMapTexture; }
//! Return true if texture mapping is enabled (false by default).
bool TextureMapState() const { return myToMapTexture; }
//! Enable or disable texture mapping (has no effect if texture is not set).
void SetTextureMapOn (bool theToMap) { myToMapTexture = theToMap; }
//! Enable texture mapping (has no effect if texture is not set).
void SetTextureMapOn() { myToMapTexture = true; }
//! Disable texture mapping.
void SetTextureMapOff() { myToMapTexture = false; }
//! Returns current polygon offsets settings.
const Graphic3d_PolygonOffset& PolygonOffset() const { return myPolygonOffset; }
//! Sets polygon offsets settings.
void SetPolygonOffset (const Graphic3d_PolygonOffset& theOffset) { myPolygonOffset = theOffset; }
//! Returns current polygon offsets settings.
void PolygonOffsets (Standard_Integer& theMode,
Standard_ShortReal& theFactor,
Standard_ShortReal& theUnits) const
{
theMode = myPolygonOffset.Mode;
theFactor = myPolygonOffset.Factor;
theUnits = myPolygonOffset.Units;
}
//! Sets up OpenGL polygon offsets mechanism.
//! <aMode> parameter can contain various combinations of
//! Aspect_PolygonOffsetMode enumeration elements (Aspect_POM_None means
//! that polygon offsets are not changed).
//! If <aMode> is different from Aspect_POM_Off and Aspect_POM_None, then <aFactor> and <aUnits>
//! arguments are used by graphic renderer to calculate a depth offset value:
//!
//! offset = <aFactor> * m + <aUnits> * r, where
//! m - maximum depth slope for the polygon currently being displayed,
//! r - minimum window coordinates depth resolution (implementation-specific)
//!
//! Default settings for OCC 3D viewer: mode = Aspect_POM_Fill, factor = 1., units = 0.
//!
//! Negative offset values move polygons closer to the viewport,
//! while positive values shift polygons away.
//! Consult OpenGL reference for details (glPolygonOffset function description).
void SetPolygonOffsets (const Standard_Integer theMode,
const Standard_ShortReal theFactor = 1.0f,
const Standard_ShortReal theUnits = 0.0f)
{
myPolygonOffset.Mode = (Aspect_PolygonOffsetMode )(theMode & Aspect_POM_Mask);
myPolygonOffset.Factor = theFactor;
myPolygonOffset.Units = theUnits;
}
//! @name parameters specific to Line primitive rendering
public:
//! Return line type; Aspect_TOL_SOLID by default.
Aspect_TypeOfLine LineType() const { return myLineType; }
//! Modifies the line type
void SetLineType (Aspect_TypeOfLine theType) { myLineType = theType; }
//! Return width for edges in pixels; 1.0 by default.
Standard_ShortReal LineWidth() const { return myLineWidth; }
//! Modifies the line thickness
//! Warning: Raises Standard_OutOfRange if the width is a negative value.
void SetLineWidth (Standard_ShortReal theWidth)
{
if (theWidth <= 0.0f)
{
throw Standard_OutOfRange ("Bad value for EdgeLineWidth");
}
myLineWidth = theWidth;
}
//! @name parameters specific to Point (Marker) primitive rendering
public:
//! Return marker type; Aspect_TOM_POINT by default.
Aspect_TypeOfMarker MarkerType() const { return myMarkerType; }
//! Modifies the type of marker.
void SetMarkerType (Aspect_TypeOfMarker theType) { myMarkerType = theType; }
//! Return marker scale factor; 1.0 by default.
Standard_ShortReal MarkerScale() const { return myMarkerScale; }
//! Modifies the scale factor.
//! Marker type Aspect_TOM_POINT is not affected by the marker size scale factor.
//! It is always the smallest displayable dot.
//! Warning: Raises Standard_OutOfRange if the scale is a negative value.
void SetMarkerScale (const Standard_ShortReal theScale)
{
if (theScale <= 0.0f)
{
throw Standard_OutOfRange ("Bad value for MarkerScale");
}
myMarkerScale = theScale;
}
//! Returns marker's image texture.
//! Could be null handle if marker aspect has been initialized as default type of marker.
const Handle(Graphic3d_MarkerImage)& MarkerImage() const { return myMarkerImage; }
//! Set marker's image texture.
void SetMarkerImage (const Handle(Graphic3d_MarkerImage)& theImage) { myMarkerImage = theImage; }
//! @name parameters specific to text rendering
public:
//! Returns the font; NULL string by default.
const Handle(TCollection_HAsciiString)& TextFont() const { return myTextFont; }
//! Modifies the font.
void SetTextFont (const Handle(TCollection_HAsciiString)& theFont) { myTextFont = theFont; }
//! Returns text FontAspect
Font_FontAspect TextFontAspect() const { return myTextFontAspect; }
//! Turns usage of Aspect text
void SetTextFontAspect (Font_FontAspect theFontAspect) { myTextFontAspect = theFontAspect; }
//! Returns display type; Aspect_TODT_NORMAL by default.
Aspect_TypeOfDisplayText TextDisplayType() const { return myTextDisplayType; }
//! Sets display type.
void SetTextDisplayType (Aspect_TypeOfDisplayText theType) { myTextDisplayType = theType; }
//! Returns text background/shadow color; equals to EdgeColor() property.
const Quantity_ColorRGBA& ColorSubTitleRGBA() const { return myEdgeColor; }
//! Return text background/shadow color; equals to EdgeColor() property.
const Quantity_Color& ColorSubTitle() const { return myEdgeColor.GetRGB(); }
//! Modifies text background/shadow color; equals to EdgeColor() property.
void SetColorSubTitle (const Quantity_Color& theColor) { myEdgeColor.SetRGB (theColor); }
//! Modifies text background/shadow color; equals to EdgeColor() property.
void SetColorSubTitle (const Quantity_ColorRGBA& theColor) { myEdgeColor = theColor; }
//! Returns TRUE when the Text Zoomable is on.
bool IsTextZoomable() const { return myIsTextZoomable; }
//! Turns usage of text zoomable on/off
void SetTextZoomable (bool theFlag) { myIsTextZoomable = theFlag; }
//! Returns the text style; Aspect_TOST_NORMAL by default.
Aspect_TypeOfStyleText TextStyle() const { return myTextStyle; }
//! Modifies the style of the text.
void SetTextStyle (Aspect_TypeOfStyleText theStyle) { myTextStyle = theStyle; }
//! Returns Angle of degree
Standard_ShortReal TextAngle() const { return myTextAngle; }
//! Turns usage of text rotated
void SetTextAngle (Standard_ShortReal theAngle) { myTextAngle = (Standard_ShortReal )theAngle; }
//! @name parameters specific to Mesh Edges (of triangulation primitive) rendering
public:
//! Returns true if mesh edges should be drawn (false by default).
bool ToDrawEdges() const { return myToDrawEdges && myLineType != Aspect_TOL_EMPTY; }
//! Set if mesh edges should be drawn or not.
void SetDrawEdges (bool theToDraw)
{
myToDrawEdges = theToDraw;
if (myLineType == Aspect_TOL_EMPTY)
{
myLineType = Aspect_TOL_SOLID;
}
}
//! The edges of FillAreas are drawn.
void SetEdgeOn() { SetDrawEdges (true); }
//! The edges of FillAreas are not drawn.
void SetEdgeOff() { SetDrawEdges (false); }
//! Return color of edges.
const Quantity_Color& EdgeColor() const { return myEdgeColor.GetRGB(); }
//! Return color of edges.
const Quantity_ColorRGBA& EdgeColorRGBA() const { return myEdgeColor; }
//! Modifies the color of the edge of the face
void SetEdgeColor (const Quantity_Color& theColor) { myEdgeColor.SetRGB (theColor); }
//! Modifies the color of the edge of the face
void SetEdgeColor (const Quantity_ColorRGBA& theColor) { myEdgeColor = theColor; }
//! Return edges line type (same as LineType()).
Aspect_TypeOfLine EdgeLineType() const { return myLineType; }
//! Modifies the edge line type (same as SetLineType())
void SetEdgeLineType (Aspect_TypeOfLine theType) { myLineType = theType; }
//! Return width for edges in pixels (same as LineWidth()).
Standard_ShortReal EdgeWidth() const { return myLineWidth; }
//! Modifies the edge thickness (same as SetLineWidth())
void SetEdgeWidth (Standard_Real theWidth) { SetLineWidth ((Standard_ShortReal )theWidth); }
//! Returns TRUE if drawing element edges should discard first edge in triangle; FALSE by default.
//! Graphics hardware works mostly with triangles, so that wireframe presentation will draw triangle edges by default.
//! This flag allows rendering wireframe presentation of quad-only array split into triangles.
//! For this, quads should be split in specific order, so that the quad diagonal (to be NOT rendered) goes first:
//! 1------2
//! / / Triangle #1: 2-0-1; Triangle #2: 0-2-3
//! 0------3
bool ToSkipFirstEdge() const { return myToSkipFirstEdge; }
//! Set skip first triangle edge flag for drawing wireframe presentation of quads array split into triangles.
void SetSkipFirstEdge (bool theToSkipFirstEdge) { myToSkipFirstEdge = theToSkipFirstEdge; }
//! Returns TRUE if silhouette (outline) should be drawn (with edge color and width); FALSE by default.
bool ToDrawSilhouette() const { return myToDrawSilhouette; }
//! Enables/disables drawing silhouette (outline).
void SetDrawSilhouette (bool theToDraw) { myToDrawSilhouette = theToDraw; }
public:
//! Returns the hatch type used when InteriorStyle is IS_HATCH
const Handle(Graphic3d_HatchStyle)& HatchStyle() const { return myHatchStyle; }
//! Modifies the hatch type used when InteriorStyle is IS_HATCH
void SetHatchStyle (const Handle(Graphic3d_HatchStyle)& theStyle) { myHatchStyle = theStyle; }
//! Modifies the hatch type used when InteriorStyle is IS_HATCH
//! @warning This method always creates a new handle for a given hatch style
void SetHatchStyle (const Aspect_HatchStyle theStyle)
{
if (theStyle == Aspect_HS_SOLID)
{
myHatchStyle.Nullify();
return;
}
myHatchStyle = new Graphic3d_HatchStyle (theStyle);
}
public:
//! Check for equality with another aspects.
bool IsEqual (const Graphic3d_Aspects& theOther)
{
if (this == &theOther)
{
return true;
}
return myProgram == theOther.myProgram
&& myTextureSet == theOther.myTextureSet
&& myMarkerImage == theOther.myMarkerImage
&& myInteriorColor == theOther.myInteriorColor
&& myBackInteriorColor == theOther.myBackInteriorColor
&& myFrontMaterial == theOther.myFrontMaterial
&& myBackMaterial == theOther.myBackMaterial
&& myInteriorStyle == theOther.myInteriorStyle
&& myShadingModel == theOther.myShadingModel
&& myAlphaMode == theOther.myAlphaMode
&& myAlphaCutoff == theOther.myAlphaCutoff
&& myLineType == theOther.myLineType
&& myEdgeColor == theOther.myEdgeColor
&& myLineWidth == theOther.myLineWidth
&& myMarkerType == theOther.myMarkerType
&& myMarkerScale == theOther.myMarkerScale
&& myHatchStyle == theOther.myHatchStyle
&& myTextFont == theOther.myTextFont
&& myPolygonOffset == theOther.myPolygonOffset
&& myTextStyle == theOther.myTextStyle
&& myTextDisplayType == theOther.myTextDisplayType
&& myTextFontAspect == theOther.myTextFontAspect
&& myTextAngle == theOther.myTextAngle
&& myToSkipFirstEdge == theOther.myToSkipFirstEdge
&& myToDistinguishMaterials == theOther.myToDistinguishMaterials
&& myToDrawEdges == theOther.myToDrawEdges
&& myToDrawSilhouette == theOther.myToDrawSilhouette
&& myToSuppressBackFaces == theOther.myToSuppressBackFaces
&& myToMapTexture == theOther.myToMapTexture
&& myIsTextZoomable == theOther.myIsTextZoomable;
}
protected:
Handle(Graphic3d_ShaderProgram) myProgram;
Handle(Graphic3d_TextureSet) myTextureSet;
Handle(Graphic3d_MarkerImage) myMarkerImage;
Handle(Graphic3d_HatchStyle) myHatchStyle;
Handle(TCollection_HAsciiString) myTextFont;
Graphic3d_MaterialAspect myFrontMaterial;
Graphic3d_MaterialAspect myBackMaterial;
Quantity_ColorRGBA myInteriorColor;
Quantity_ColorRGBA myBackInteriorColor;
Quantity_ColorRGBA myEdgeColor;
Graphic3d_PolygonOffset myPolygonOffset;
Aspect_InteriorStyle myInteriorStyle;
Graphic3d_TypeOfShadingModel myShadingModel;
Graphic3d_AlphaMode myAlphaMode;
Standard_ShortReal myAlphaCutoff;
Aspect_TypeOfLine myLineType;
Standard_ShortReal myLineWidth;
Aspect_TypeOfMarker myMarkerType;
Standard_ShortReal myMarkerScale;
Aspect_TypeOfStyleText myTextStyle;
Aspect_TypeOfDisplayText myTextDisplayType;
Font_FontAspect myTextFontAspect;
Standard_ShortReal myTextAngle;
bool myToSkipFirstEdge;
bool myToDistinguishMaterials;
bool myToDrawEdges;
bool myToDrawSilhouette;
bool myToSuppressBackFaces;
bool myToMapTexture;
bool myIsTextZoomable;
};
DEFINE_STANDARD_HANDLE(Graphic3d_Aspects, Standard_Transient)
#endif // _Graphic3d_Aspects_HeaderFile

View File

@@ -211,6 +211,68 @@ void Graphic3d_Group::Update() const
myStructure->StructureManager()->Update();
}
// =======================================================================
// function : IsGroupPrimitivesAspectSet
// purpose :
// =======================================================================
Standard_Boolean Graphic3d_Group::IsGroupPrimitivesAspectSet (const Graphic3d_GroupAspect theAspect) const
{
switch (theAspect)
{
case Graphic3d_ASPECT_LINE: return !LineAspect().IsNull();
case Graphic3d_ASPECT_TEXT: return !TextAspect().IsNull();
case Graphic3d_ASPECT_MARKER: return !MarkerAspect().IsNull();
case Graphic3d_ASPECT_FILL_AREA: return !FillAreaAspect().IsNull();
default: return Standard_False;
}
}
// =======================================================================
// function : GroupPrimitivesAspect
// purpose :
// =======================================================================
void Graphic3d_Group::GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine,
const Handle(Graphic3d_AspectText3d)& theAspText,
const Handle(Graphic3d_AspectMarker3d)& theAspMarker,
const Handle(Graphic3d_AspectFillArea3d)& theAspFill) const
{
if (!theAspLine.IsNull())
{
Handle(Graphic3d_AspectLine3d) aLineAspect = LineAspect();
if (!aLineAspect.IsNull())
{
*theAspLine.operator->() = *aLineAspect;
}
}
if (!theAspText.IsNull())
{
Handle(Graphic3d_AspectText3d) aTextAspect = TextAspect();
if (!aTextAspect.IsNull())
{
*theAspText.operator->() = *aTextAspect;
}
}
if (!theAspMarker.IsNull())
{
Handle(Graphic3d_AspectMarker3d) aMarkerAspect = MarkerAspect();
if (!aMarkerAspect.IsNull())
{
*theAspMarker.operator->() = *aMarkerAspect;
}
}
if (!theAspFill.IsNull())
{
Handle(Graphic3d_AspectFillArea3d) aFillAspect = FillAreaAspect();
if (!aFillAspect.IsNull())
{
*theAspFill.operator->() = *aFillAspect;
}
}
}
// =======================================================================
// function : AddPrimitiveArray
// purpose :

View File

@@ -17,12 +17,17 @@
#ifndef _Graphic3d_Group_HeaderFile
#define _Graphic3d_Group_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <Graphic3d_BndBox4f.hxx>
#include <Standard_Boolean.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_AspectText3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_MapOfAspectsToAspects.hxx>
#include <Standard_Transient.hxx>
#include <Standard_Real.hxx>
#include <Standard_CString.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Graphic3d_TextPath.hxx>
@@ -32,6 +37,8 @@
#include <Graphic3d_IndexBuffer.hxx>
#include <Graphic3d_Buffer.hxx>
#include <Graphic3d_BoundBuffer.hxx>
#include <Standard_Address.hxx>
#include <Graphic3d_GroupAspect.hxx>
#include <gp_Ax2.hxx>
#include <TCollection_ExtendedString.hxx>
@@ -95,20 +102,70 @@ public:
public:
//! Return line aspect.
virtual Handle(Graphic3d_AspectLine3d) LineAspect() const = 0;
//! Assign line aspect to the group.
virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspect) = 0;
//! Return fill area aspect.
virtual Handle(Graphic3d_Aspects) Aspects() const = 0;
virtual Handle(Graphic3d_AspectFillArea3d) FillAreaAspect() const = 0;
//! Modifies the context for all the face primitives of the group.
virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect) = 0;
virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect) = 0;
//! 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;
//! Return text aspect.
virtual Handle(Graphic3d_AspectText3d) TextAspect() const = 0;
//! Modifies the context for all the text primitives of the group.
virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspect) = 0;
//! Return marker aspect.
virtual Handle(Graphic3d_AspectMarker3d) MarkerAspect() const = 0;
//! Modifies the context for all the marker primitives of the group.
virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspect) = 0;
//! Modifies the current context of the group to give
//! another aspect for all the line primitives created
//! after this call in the group.
virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspect) = 0;
//! Modifies the current context of the group to give
//! another aspect for all the face primitives created
//! after this call in the group.
virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect) = 0;
//! Modifies the current context of the group to give
//! another aspect for all the text primitives created
//! after this call in the group.
virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspect) = 0;
//! Modifies the current context of the group to give
//! another aspect for all the marker primitives created
//! after this call in the group.
virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspect) = 0;
//! Update presentation aspects after their modification.
virtual void SynchronizeAspects() = 0;
//! Replace aspects specified in the replacement map.
virtual void ReplaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap) = 0;
//! Returns TRUE if aspect is set for the group.
Standard_EXPORT Standard_Boolean IsGroupPrimitivesAspectSet (const Graphic3d_GroupAspect theAspect) const;
//! Returns the context of all the primitives of the group.
Standard_EXPORT void GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine,
const Handle(Graphic3d_AspectText3d)& theAspText,
const Handle(Graphic3d_AspectMarker3d)& theAspMarker,
const Handle(Graphic3d_AspectFillArea3d)& theAspFill) const;
//! Returns the last inserted context in the group for each kind of primitives.
void PrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine,
const Handle(Graphic3d_AspectText3d)& theAspText,
const Handle(Graphic3d_AspectMarker3d)& theAspMarker,
const Handle(Graphic3d_AspectFillArea3d)& theAspFill) const
{
GroupPrimitivesAspect (theAspLine, theAspText, theAspMarker, theAspFill);
}
public:

View File

@@ -1,23 +0,0 @@
// Copyright (c) 2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _Graphic3d_MapOfAspectsToAspects_Header
#define _Graphic3d_MapOfAspectsToAspects_Header
#include <NCollection_DataMap.hxx>
#include <Standard_Transient.hxx>
class Graphic3d_Aspects;
typedef NCollection_DataMap<Handle(Graphic3d_Aspects), Handle(Graphic3d_Aspects)> Graphic3d_MapOfAspectsToAspects;
#endif // _Graphic3d_MapOfAspectsToAspects_Header

View File

@@ -25,14 +25,6 @@ struct Graphic3d_PolygonOffset
//! Empty constructor.
Graphic3d_PolygonOffset() : Mode(Aspect_POM_Fill), Factor (1.0f), Units (0.0f) {}
//! Equality comparison.
bool operator== (const Graphic3d_PolygonOffset& theOther) const
{
return Mode == theOther.Mode
&& Factor == theOther.Factor
&& Units == theOther.Units;
}
};
#endif // _Graphic3d_PolygonOffset_HeaderFile

View File

@@ -1,12 +1,18 @@
Image_AlienPixMap.cxx
Image_AlienPixMap.hxx
Image_AlienPixMapI.cxx
Image_AlienPixMapI.hxx
Image_Color.hxx
Image_Diff.cxx
Image_Diff.hxx
Image_Format.hxx
Image_FreeImage.cxx
Image_FreeImage.hxx
Image_PixMap.cxx
Image_PixMap.hxx
Image_PixMapData.hxx
Image_PixMapTypedData.hxx
Image_VideoRecorder.cxx
Image_VideoRecorder.hxx
Image_WinCodec.cxx
Image_WinCodec.hxx

File diff suppressed because it is too large Load Diff

View File

@@ -16,28 +16,29 @@
#ifndef _Image_AlienPixMap_H__
#define _Image_AlienPixMap_H__
#include <Image_PixMap.hxx>
class TCollection_AsciiString;
struct FIBITMAP;
#include <Image_AlienPixMapI.hxx>
//! Image class that support file reading/writing operations using auxiliary image library.
//! Supported image formats:
//! - *.bmp - bitmap image, lossless format without compression.
//! - *.ppm - PPM (Portable Pixmap Format), lossless format without compression.
//! - *.png - PNG (Portable Network Graphics) lossless format with compression.
//! - *.jpg, *.jpe, *.jpeg - JPEG/JIFF (Joint Photographic Experts Group) lossy format (compressed with quality losses). YUV color space used (automatically converted from/to RGB).
//! - *.tif, *.tiff - TIFF (Tagged Image File Format).
//! - *.tga - TGA (Truevision Targa Graphic), lossless format.
//! - *.gif - GIF (Graphical Interchange Format), lossy format. Color stored using palette (up to 256 distinct colors).
//! - *.exr - OpenEXR high dynamic-range format (supports float pixel formats).
class Image_AlienPixMap : public Image_PixMap
//! This is a wrapper over Image_FreeImage or Image_WinCodec basing on availability.
class Image_AlienPixMap : public Image_AlienPixMapI
{
DEFINE_STANDARD_RTTIEXT(Image_AlienPixMap, Image_PixMap)
DEFINE_STANDARD_RTTIEXT(Image_AlienPixMap, Image_AlienPixMapI)
public:
//! Return default rows order used by underlying image library.
Standard_EXPORT static bool IsTopDownDefault();
//! Create default instance of available image library or NULL if no library available.
Standard_EXPORT static Handle(Image_AlienPixMapI) CreateDefault();
//! Setup default image library to be used as factory.
//! Note that access to the factory is not protected by mutex,
//! make sure to call this method at the early application startup stage before using.
//! In this way, application might provide image library replacement implementing
//! image reading/writing operations which will be used by standard image tools within OCCT
//! (like image dump or texture loads).
Standard_EXPORT static void SetDefaultFactory (const Handle(Image_AlienPixMapI)& theLibrary);
public:
//! Empty constructor.
@@ -46,67 +47,64 @@ public:
//! Destructor
Standard_EXPORT virtual ~Image_AlienPixMap();
//! Read image data from file.
bool Load (const TCollection_AsciiString& theFileName)
{
return Load (NULL, 0, theFileName);
}
using Image_AlienPixMapI::Load;
//! Read image data from stream.
Standard_EXPORT bool Load (std::istream& theStream,
const TCollection_AsciiString& theFileName);
Standard_EXPORT virtual bool Load (std::istream& theStream,
const TCollection_AsciiString& theFileName) Standard_OVERRIDE;
//! Read image data from memory buffer.
//! @param theData memory pointer to read from;
//! when NULL, function will attempt to open theFileName file
//! @param theLength memory buffer length
//! @param theFileName optional file name
Standard_EXPORT bool Load (const Standard_Byte* theData,
Standard_Size theLength,
const TCollection_AsciiString& theFileName);
Standard_EXPORT virtual bool Load (const Standard_Byte* theData,
Standard_Size theLength,
const TCollection_AsciiString& theFileName) Standard_OVERRIDE;
//! Write image data to file using file extension to determine compression format.
Standard_EXPORT bool Save (const TCollection_AsciiString& theFileName);
Standard_EXPORT virtual bool Save (const TCollection_AsciiString& theFileName) Standard_OVERRIDE;
//! Initialize image plane with required dimensions.
//! thePixelFormat - if specified pixel format doesn't supported by image library
//! than nearest supported will be used instead!
//! theSizeRowBytes - may be ignored by this class and required alignemnt will be used instead!
//! @param thePixelFormat if specified pixel format doesn't supported by image library
//! than nearest supported will be used instead!
//! @param theSizeX image width
//! @param theSizeY image height
//! @param theSizeRowBytes may be ignored by this class and required alignment will be used instead!
Standard_EXPORT virtual bool InitTrash (Image_Format thePixelFormat,
const Standard_Size theSizeX,
const Standard_Size theSizeY,
const Standard_Size theSizeRowBytes = 0) Standard_OVERRIDE;
//! Initialize by copying data.
Standard_EXPORT virtual bool InitCopy (const Image_PixMap& theCopy) Standard_OVERRIDE;
//! Method correctly deallocate internal buffer.
Standard_EXPORT virtual void Clear() Standard_OVERRIDE;
//! Performs gamma correction on image.
//! theGamma - gamma value to use; a value of 1.0 leaves the image alone
Standard_EXPORT bool AdjustGamma (const Standard_Real theGammaCorr);
Standard_EXPORT virtual bool AdjustGamma (Standard_Real theGammaCorr) Standard_OVERRIDE;
//! Setup scanlines order in memory - top-down or bottom-up.
virtual void SetTopDown (bool theIsTopDown) Standard_OVERRIDE
{
if (!myLibImage.IsNull())
{
myLibImage->SetTopDown (theIsTopDown);
}
base_type::SetTopDown (theIsTopDown);
}
private:
FIBITMAP* myLibImage;
private:
//! Return NULL.
Handle(Image_AlienPixMapI) createDefault() const Standard_OVERRIDE { return Handle(Image_AlienPixMapI)(); }
//! Copying allowed only within Handles
Image_AlienPixMap (const Image_AlienPixMap& );
Image_AlienPixMap& operator= (const Image_AlienPixMap& );
//! Wrapper initialization is disallowed for this class (will return false in any case)!
//! Use only copying and allocation initializers.
Standard_EXPORT virtual bool InitWrapper (Image_Format thePixelFormat,
Standard_Byte* theDataPtr,
const Standard_Size theSizeX,
const Standard_Size theSizeY,
const Standard_Size theSizeRowBytes) Standard_OVERRIDE;
private:
//! Built-in PPM export
Standard_EXPORT bool savePPM (const TCollection_AsciiString& theFileName) const;
Handle(Image_AlienPixMapI) myLibImage;
};

View File

@@ -0,0 +1,151 @@
// Created on: 2010-09-16
// Created by: KGV
// Copyright (c) 2010-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.
#include <Image_AlienPixMapI.hxx>
#include <gp.hxx>
#include <Message.hxx>
#include <Message_Messenger.hxx>
#include <NCollection_Array1.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <OSD_OpenFile.hxx>
#include <fstream>
#include <algorithm>
IMPLEMENT_STANDARD_RTTIEXT(Image_AlienPixMapI, Image_PixMap)
// =======================================================================
// function : InitWrapper
// purpose :
// =======================================================================
bool Image_AlienPixMapI::InitWrapper (Image_Format,
Standard_Byte*,
const Standard_Size,
const Standard_Size,
const Standard_Size)
{
Clear();
return false;
}
// =======================================================================
// function : InitCopy
// purpose :
// =======================================================================
bool Image_AlienPixMapI::InitCopy (const Image_PixMap& theCopy)
{
if (&theCopy == this)
{
// self-copying disallowed
return false;
}
if (!InitTrash (theCopy.Format(), theCopy.SizeX(), theCopy.SizeY(), theCopy.SizeRowBytes()))
{
return false;
}
if (myImgFormat == theCopy.Format())
{
if (SizeRowBytes() == theCopy.SizeRowBytes()
&& TopDownInc() == theCopy.TopDownInc())
{
// copy with one call
memcpy (ChangeData(), theCopy.Data(), std::min (SizeBytes(), theCopy.SizeBytes()));
return true;
}
// copy row-by-row
const Standard_Size aRowSizeBytes = std::min (SizeRowBytes(), theCopy.SizeRowBytes());
for (Standard_Size aRow = 0; aRow < myData.SizeY; ++aRow)
{
memcpy (ChangeRow (aRow), theCopy.Row (aRow), aRowSizeBytes);
}
return true;
}
// pixel format conversion required
Clear();
return false;
}
// =======================================================================
// function : loadStreamToBuffer
// purpose :
// =======================================================================
bool Image_AlienPixMapI::loadStreamToBuffer (std::istream& theStream,
const TCollection_AsciiString& theFileName)
{
Clear();
const std::streamoff aStart = theStream.tellg();
theStream.seekg (0, std::ios::end);
const Standard_Integer aLen = Standard_Integer(theStream.tellg() - aStart);
theStream.seekg (aStart);
if (aLen <= 0)
{
Message::DefaultMessenger()->Send ("Error: empty stream", Message_Fail);
return false;
}
NCollection_Array1<Standard_Byte> aBuff (1, aLen);
if (!theStream.read ((char* )&aBuff.ChangeFirst(), aBuff.Size()))
{
Message::DefaultMessenger()->Send ("Error: unable to read stream", Message_Fail);
return false;
}
return Load (&aBuff.ChangeFirst(), aBuff.Size(), theFileName);
}
// =======================================================================
// function : savePPM
// purpose :
// =======================================================================
bool Image_AlienPixMapI::savePPM (const TCollection_AsciiString& theFileName) const
{
if (IsEmpty())
{
return false;
}
// Open file
FILE* aFile = OSD_OpenFile (theFileName.ToCString(), "wb");
if (aFile == NULL)
{
return false;
}
// Write header
fprintf (aFile, "P6\n%d %d\n255\n", (int )SizeX(), (int )SizeY());
fprintf (aFile, "# Image stored by OpenCASCADE framework in linear RGB colorspace\n");
// Write pixel data
Standard_Byte aByte;
for (Standard_Size aRow = 0; aRow < SizeY(); ++aRow)
{
for (Standard_Size aCol = 0; aCol < SizeX(); ++aCol)
{
// extremely SLOW but universal (implemented for all supported pixel formats)
const Quantity_ColorRGBA aColor = PixelColor ((Standard_Integer )aCol, (Standard_Integer )aRow);
aByte = Standard_Byte(aColor.GetRGB().Red() * 255.0); fwrite (&aByte, 1, 1, aFile);
aByte = Standard_Byte(aColor.GetRGB().Green() * 255.0); fwrite (&aByte, 1, 1, aFile);
aByte = Standard_Byte(aColor.GetRGB().Blue() * 255.0); fwrite (&aByte, 1, 1, aFile);
}
}
// Close file
fclose (aFile);
return true;
}

View File

@@ -0,0 +1,98 @@
// Created on: 2012-07-18
// Created by: Kirill GAVRILOV
// Copyright (c) 2012-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 _Image_AlienPixMapI_HeaderFile
#define _Image_AlienPixMapI_HeaderFile
#include <Image_PixMap.hxx>
#include <TCollection_AsciiString.hxx>
//! Interface for reading/writing image files.
class Image_AlienPixMapI : public Image_PixMap
{
DEFINE_STANDARD_RTTIEXT(Image_AlienPixMapI, Image_PixMap)
public:
//! Empty constructor.
Image_AlienPixMapI() {}
//! Read image data from file.
bool Load (const TCollection_AsciiString& theFileName)
{
return Load (NULL, 0, theFileName);
}
//! Read image data from stream.
virtual bool Load (std::istream& theStream,
const TCollection_AsciiString& theFileName) = 0;
//! Read image data from memory buffer.
//! @param theData memory pointer to read from;
//! when NULL, function will attempt to open theFileName file
//! @param theLength memory buffer length
//! @param theFileName optional file name
virtual bool Load (const Standard_Byte* theData,
Standard_Size theLength,
const TCollection_AsciiString& theFileName) = 0;
//! Write image data to file using file extension to determine compression format.
virtual bool Save (const TCollection_AsciiString& theFileName) = 0;
//! Performs gamma correction on image.
//! theGamma - gamma value to use; a value of 1.0 leaves the image alone
virtual bool AdjustGamma (Standard_Real theGammaCorr) { (void )theGammaCorr; return false; }
//! Initializes image data as copy of another image.
Standard_EXPORT virtual bool InitCopy (const Image_PixMap& theCopy) Standard_OVERRIDE;
public:
//! Create default instance of this class.
virtual Handle(Image_AlienPixMapI) createDefault() const = 0;
protected:
//! Fallback copying stream data into transient buffer
Standard_EXPORT bool loadStreamToBuffer (std::istream& theStream,
const TCollection_AsciiString& theFileName);
//! Built-in PPM export
Standard_EXPORT bool savePPM (const TCollection_AsciiString& theFileName) const;
//! Wrapper initialization for sub-classes.
bool initWrapper (Image_Format thePixelFormat,
Standard_Byte* theDataPtr,
Standard_Size theSizeX,
Standard_Size theSizeY,
Standard_Size theSizeRowBytes)
{
return Image_PixMap::InitWrapper (thePixelFormat, theDataPtr, theSizeX, theSizeY, theSizeRowBytes);
}
private:
//! Wrapper initialization by user is disallowed for this class (will return false in any case)!
//! Use only copying and allocation initializers.
Standard_EXPORT virtual bool InitWrapper (Image_Format thePixelFormat,
Standard_Byte* theDataPtr,
const Standard_Size theSizeX,
const Standard_Size theSizeY,
const Standard_Size theSizeRowBytes) Standard_OVERRIDE;
};
DEFINE_STANDARD_HANDLE(Image_AlienPixMapI, Image_PixMap)
#endif // _Image_AlienPixMapI_HeaderFile

View File

@@ -0,0 +1,655 @@
// Copyright (c) 2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifdef HAVE_FREEIMAGE
#include <FreeImage.h>
#ifdef _MSC_VER
#pragma comment( lib, "FreeImage.lib" )
#endif
#endif
#include <Image_FreeImage.hxx>
#include <gp.hxx>
#include <Message.hxx>
#include <Message_Messenger.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <OSD_OpenFile.hxx>
#include <fstream>
#include <algorithm>
IMPLEMENT_STANDARD_RTTIEXT(Image_FreeImage, Image_AlienPixMapI)
namespace
{
#ifdef HAVE_FREEIMAGE
static Image_Format convertFromFreeFormat (FREE_IMAGE_TYPE theFormatFI,
FREE_IMAGE_COLOR_TYPE theColorTypeFI,
unsigned theBitsPerPixel)
{
switch (theFormatFI)
{
case FIT_RGBF: return Image_Format_RGBF;
case FIT_RGBAF: return Image_Format_RGBAF;
case FIT_FLOAT: return Image_Format_GrayF;
case FIT_BITMAP:
{
switch (theColorTypeFI)
{
case FIC_MINISBLACK:
{
return Image_Format_Gray;
}
case FIC_RGB:
{
if (Image_PixMap::IsBigEndianHost())
{
return (theBitsPerPixel == 32) ? Image_Format_RGB32 : Image_Format_RGB;
}
else
{
return (theBitsPerPixel == 32) ? Image_Format_BGR32 : Image_Format_BGR;
}
}
case FIC_RGBALPHA:
{
return Image_PixMap::IsBigEndianHost() ? Image_Format_RGBA : Image_Format_BGRA;
}
default:
return Image_Format_UNKNOWN;
}
}
default:
return Image_Format_UNKNOWN;
}
}
static FREE_IMAGE_TYPE convertToFreeFormat (Image_Format theFormat)
{
switch (theFormat)
{
case Image_Format_GrayF:
case Image_Format_AlphaF:
return FIT_FLOAT;
case Image_Format_RGBAF:
return FIT_RGBAF;
case Image_Format_RGBF:
return FIT_RGBF;
case Image_Format_RGBA:
case Image_Format_BGRA:
case Image_Format_RGB32:
case Image_Format_BGR32:
case Image_Format_RGB:
case Image_Format_BGR:
case Image_Format_Gray:
case Image_Format_Alpha:
return FIT_BITMAP;
default:
return FIT_UNKNOWN;
}
}
//! Wrapper for accessing C++ stream from FreeImage.
class Image_FreeImageStream
{
public:
//! Construct wrapper over input stream.
Image_FreeImageStream (std::istream& theStream)
: myIStream (&theStream), myOStream (NULL), myInitPos (theStream.tellg()) {}
//! Get io object.
FreeImageIO GetFiIO() const
{
FreeImageIO anIo;
memset (&anIo, 0, sizeof(anIo));
if (myIStream != NULL)
{
anIo.read_proc = readProc;
anIo.seek_proc = seekProc;
anIo.tell_proc = tellProc;
}
if (myOStream != NULL)
{
anIo.write_proc = writeProc;
}
return anIo;
}
public:
//! Simulate fread().
static unsigned int DLL_CALLCONV readProc (void* theBuffer, unsigned int theSize, unsigned int theCount, fi_handle theHandle)
{
Image_FreeImageStream* aThis = (Image_FreeImageStream* )theHandle;
if (aThis->myIStream == NULL)
{
return 0;
}
if (!aThis->myIStream->read ((char* )theBuffer, std::streamsize(theSize) * std::streamsize(theCount)))
{
//aThis->myIStream->clear();
}
const std::streamsize aNbRead = aThis->myIStream->gcount();
return (unsigned int )(aNbRead / theSize);
}
//! Simulate fwrite().
static unsigned int DLL_CALLCONV writeProc (void* theBuffer, unsigned int theSize, unsigned int theCount, fi_handle theHandle)
{
Image_FreeImageStream* aThis = (Image_FreeImageStream* )theHandle;
if (aThis->myOStream != NULL
&& aThis->myOStream->write ((const char* )theBuffer, std::streamsize(theSize) * std::streamsize(theCount)))
{
return theCount;
}
return 0;
}
//! Simulate fseek().
static int DLL_CALLCONV seekProc (fi_handle theHandle, long theOffset, int theOrigin)
{
Image_FreeImageStream* aThis = (Image_FreeImageStream* )theHandle;
if (aThis->myIStream == NULL)
{
return -1;
}
bool isSeekDone = false;
switch (theOrigin)
{
case SEEK_SET:
if (aThis->myIStream->seekg ((std::streamoff )aThis->myInitPos + theOffset, std::ios::beg))
{
isSeekDone = true;
}
break;
case SEEK_CUR:
if (aThis->myIStream->seekg (theOffset, std::ios::cur))
{
isSeekDone = true;
}
break;
case SEEK_END:
if (aThis->myIStream->seekg (theOffset, std::ios::end))
{
isSeekDone = true;
}
break;
}
return isSeekDone ? 0 : -1;
}
//! Simulate ftell().
static long DLL_CALLCONV tellProc (fi_handle theHandle)
{
Image_FreeImageStream* aThis = (Image_FreeImageStream* )theHandle;
const long aPos = aThis->myIStream != NULL ? (long )(aThis->myIStream->tellg() - aThis->myInitPos) : 0;
return aPos;
}
private:
std::istream* myIStream;
std::ostream* myOStream;
std::streampos myInitPos;
};
#endif
}
// =======================================================================
// function : IsAvailable
// purpose :
// =======================================================================
bool Image_FreeImage::IsAvailable()
{
#if defined(HAVE_FREEIMAGE)
return true;
#else
return false;
#endif
}
// =======================================================================
// function : Image_FreeImage
// purpose :
// =======================================================================
Image_FreeImage::Image_FreeImage()
: myLibImage (NULL)
{
SetTopDown (false);
}
// =======================================================================
// function : ~Image_FreeImage
// purpose :
// =======================================================================
Image_FreeImage::~Image_FreeImage()
{
Clear();
}
// =======================================================================
// function : InitTrash
// purpose :
// =======================================================================
bool Image_FreeImage::InitTrash (Image_Format thePixelFormat,
const Standard_Size theSizeX,
const Standard_Size theSizeY,
const Standard_Size theSizeRowBytes)
{
Clear();
#ifdef HAVE_FREEIMAGE
(void )theSizeRowBytes;
FREE_IMAGE_TYPE aFormatFI = convertToFreeFormat (thePixelFormat);
int aBitsPerPixel = (int )Image_PixMap::SizePixelBytes (thePixelFormat) * 8;
if (aFormatFI == FIT_UNKNOWN)
{
aFormatFI = FIT_BITMAP;
aBitsPerPixel = 24;
}
FIBITMAP* anImage = FreeImage_AllocateT (aFormatFI, (int )theSizeX, (int )theSizeY, aBitsPerPixel);
Image_Format aFormat = convertFromFreeFormat (FreeImage_GetImageType(anImage),
FreeImage_GetColorType(anImage),
FreeImage_GetBPP (anImage));
if (thePixelFormat == Image_Format_BGR32
|| thePixelFormat == Image_Format_RGB32)
{
//FreeImage_SetTransparent (anImage, FALSE);
aFormat = (aFormat == Image_Format_BGRA) ? Image_Format_BGR32 : Image_Format_RGB32;
}
initWrapper (aFormat, FreeImage_GetBits (anImage),
FreeImage_GetWidth (anImage), FreeImage_GetHeight (anImage), FreeImage_GetPitch (anImage));
SetTopDown (false);
// assign image after wrapper initialization (virtual Clear() called inside)
myLibImage = anImage;
return true;
#else
return base_type::InitTrash (thePixelFormat, theSizeX, theSizeY, theSizeRowBytes);
#endif
}
// =======================================================================
// function : Clear
// purpose :
// =======================================================================
void Image_FreeImage::Clear()
{
base_type::Clear();
#ifdef HAVE_FREEIMAGE
if (myLibImage != NULL)
{
FreeImage_Unload (myLibImage);
myLibImage = NULL;
}
#endif
}
// =======================================================================
// function : Load
// purpose :
// =======================================================================
bool Image_FreeImage::Load (const Standard_Byte* theData,
Standard_Size theLength,
const TCollection_AsciiString& theImagePath)
{
Clear();
#ifdef HAVE_FREEIMAGE
#ifdef _WIN32
const TCollection_ExtendedString aFileNameW (theImagePath);
#endif
FREE_IMAGE_FORMAT aFIF = FIF_UNKNOWN;
FIMEMORY* aFiMem = NULL;
if (theData != NULL)
{
aFiMem = FreeImage_OpenMemory ((BYTE* )theData, (DWORD )theLength);
aFIF = FreeImage_GetFileTypeFromMemory (aFiMem, 0);
}
else
{
#ifdef _WIN32
aFIF = FreeImage_GetFileTypeU (aFileNameW.ToWideString(), 0);
#else
aFIF = FreeImage_GetFileType (theImagePath.ToCString(), 0);
#endif
}
if (aFIF == FIF_UNKNOWN)
{
// no signature? try to guess the file format from the file extension
aFIF = FreeImage_GetFIFFromFilename (theImagePath.ToCString());
}
if ((aFIF == FIF_UNKNOWN) || !FreeImage_FIFSupportsReading (aFIF))
{
::Message::DefaultMessenger()->Send (TCollection_AsciiString ("Error: image '") + theImagePath + "' has unsupported file format.",
Message_Fail);
if (aFiMem != NULL)
{
FreeImage_CloseMemory (aFiMem);
}
return false;
}
int aLoadFlags = 0;
if (aFIF == FIF_GIF)
{
// 'Play' the GIF to generate each frame (as 32bpp) instead of returning raw frame data when loading
aLoadFlags = GIF_PLAYBACK;
}
else if (aFIF == FIF_ICO)
{
// convert to 32bpp and create an alpha channel from the AND-mask when loading
aLoadFlags = ICO_MAKEALPHA;
}
FIBITMAP* anImage = NULL;
if (theData != NULL)
{
anImage = FreeImage_LoadFromMemory (aFIF, aFiMem, aLoadFlags);
FreeImage_CloseMemory (aFiMem);
aFiMem = NULL;
}
else
{
#ifdef _WIN32
anImage = FreeImage_LoadU (aFIF, aFileNameW.ToWideString(), aLoadFlags);
#else
anImage = FreeImage_Load (aFIF, theImagePath.ToCString(), aLoadFlags);
#endif
}
if (anImage == NULL)
{
TCollection_AsciiString aMessage = "Error: image file '";
aMessage.AssignCat (theImagePath);
aMessage.AssignCat ("' is missing or invalid.");
::Message::DefaultMessenger()->Send (aMessage, Message_Fail);
return false;
}
Image_Format aFormat = convertFromFreeFormat (FreeImage_GetImageType(anImage),
FreeImage_GetColorType(anImage),
FreeImage_GetBPP (anImage));
if (aFormat == Image_Format_UNKNOWN)
{
//anImage = FreeImage_ConvertTo24Bits (anImage);
::Message::DefaultMessenger()->Send ( TCollection_AsciiString ("Error: image '") + theImagePath + "' has unsupported pixel format.",
Message_Fail);
return false;
}
initWrapper (aFormat, FreeImage_GetBits (anImage),
FreeImage_GetWidth (anImage), FreeImage_GetHeight (anImage), FreeImage_GetPitch (anImage));
SetTopDown (false);
// assign image after wrapper initialization (virtual Clear() called inside)
myLibImage = anImage;
return true;
#else
(void )theData;
(void )theLength;
(void )theImagePath;
Message::DefaultMessenger()->Send ("Error: FreeImage library is unavailable", Message_Fail);
return false;
#endif
}
// =======================================================================
// function : Load
// purpose :
// =======================================================================
bool Image_FreeImage::Load (std::istream& theStream,
const TCollection_AsciiString& theFileName)
{
Clear();
#ifdef HAVE_FREEIMAGE
Image_FreeImageStream aStream (theStream);
FreeImageIO aFiIO = aStream.GetFiIO();
FREE_IMAGE_FORMAT aFIF = FreeImage_GetFileTypeFromHandle (&aFiIO, &aStream, 0);
if (aFIF == FIF_UNKNOWN)
{
// no signature? try to guess the file format from the file extension
aFIF = FreeImage_GetFIFFromFilename (theFileName.ToCString());
}
if ((aFIF == FIF_UNKNOWN) || !FreeImage_FIFSupportsReading (aFIF))
{
::Message::DefaultMessenger()->Send (TCollection_AsciiString ("Error: image stream '") + theFileName + "' has unsupported file format.",
Message_Fail);
return false;
}
int aLoadFlags = 0;
if (aFIF == FIF_GIF)
{
// 'Play' the GIF to generate each frame (as 32bpp) instead of returning raw frame data when loading
aLoadFlags = GIF_PLAYBACK;
}
else if (aFIF == FIF_ICO)
{
// convert to 32bpp and create an alpha channel from the AND-mask when loading
aLoadFlags = ICO_MAKEALPHA;
}
FIBITMAP* anImage = FreeImage_LoadFromHandle (aFIF, &aFiIO, &aStream, aLoadFlags);
if (anImage == NULL)
{
::Message::DefaultMessenger()->Send (TCollection_AsciiString ("Error: image stream '") + theFileName + "' is missing or invalid.",
Message_Fail);
return false;
}
Image_Format aFormat = convertFromFreeFormat (FreeImage_GetImageType(anImage),
FreeImage_GetColorType(anImage),
FreeImage_GetBPP (anImage));
if (aFormat == Image_Format_UNKNOWN)
{
::Message::DefaultMessenger()->Send (TCollection_AsciiString ("Error: image stream '") + theFileName + "' has unsupported pixel format.",
Message_Fail);
return false;
}
initWrapper (aFormat, FreeImage_GetBits (anImage),
FreeImage_GetWidth (anImage), FreeImage_GetHeight (anImage), FreeImage_GetPitch (anImage));
SetTopDown (false);
// assign image after wrapper initialization (virtual Clear() called inside)
myLibImage = anImage;
return true;
#else
(void )theStream;
(void )theFileName;
Message::DefaultMessenger()->Send ("Error: FreeImage library is unavailable", Message_Fail);
return false;
#endif
}
// =======================================================================
// function : Save
// purpose :
// =======================================================================
bool Image_FreeImage::Save (const TCollection_AsciiString& theFileName)
{
#ifdef HAVE_FREEIMAGE
if (myLibImage == NULL)
{
return false;
}
#ifdef _WIN32
const TCollection_ExtendedString aFileNameW (theFileName.ToCString(), Standard_True);
FREE_IMAGE_FORMAT anImageFormat = FreeImage_GetFIFFromFilenameU (aFileNameW.ToWideString());
#else
FREE_IMAGE_FORMAT anImageFormat = FreeImage_GetFIFFromFilename (theFileName.ToCString());
#endif
if (anImageFormat == FIF_UNKNOWN)
{
#ifdef OCCT_DEBUG
std::cerr << "Image_FreeImage, image format doesn't supported!\n";
#endif
return false;
}
if (IsTopDown())
{
FreeImage_FlipVertical (myLibImage);
SetTopDown (false);
}
// FreeImage doesn't provide flexible format conversion API
// so we should perform multiple conversions in some cases!
FIBITMAP* anImageToDump = myLibImage;
switch (anImageFormat)
{
case FIF_PNG:
case FIF_BMP:
{
if (Format() == Image_Format_BGR32
|| Format() == Image_Format_RGB32)
{
// stupid FreeImage treats reserved byte as alpha if some bytes not set to 0xFF
for (Standard_Size aRow = 0; aRow < SizeY(); ++aRow)
{
for (Standard_Size aCol = 0; aCol < SizeX(); ++aCol)
{
myData.ChangeValue (aRow, aCol)[3] = 0xFF;
}
}
}
else if (FreeImage_GetImageType (myLibImage) != FIT_BITMAP)
{
anImageToDump = FreeImage_ConvertToType (myLibImage, FIT_BITMAP);
}
break;
}
case FIF_GIF:
{
FIBITMAP* aTmpBitmap = myLibImage;
if (FreeImage_GetImageType (myLibImage) != FIT_BITMAP)
{
aTmpBitmap = FreeImage_ConvertToType (myLibImage, FIT_BITMAP);
if (aTmpBitmap == NULL)
{
return false;
}
}
if (FreeImage_GetBPP (aTmpBitmap) != 24)
{
FIBITMAP* aTmpBitmap24 = FreeImage_ConvertTo24Bits (aTmpBitmap);
if (aTmpBitmap != myLibImage)
{
FreeImage_Unload (aTmpBitmap);
}
if (aTmpBitmap24 == NULL)
{
return false;
}
aTmpBitmap = aTmpBitmap24;
}
// need conversion to image with palette (requires 24bit bitmap)
anImageToDump = FreeImage_ColorQuantize (aTmpBitmap, FIQ_NNQUANT);
if (aTmpBitmap != myLibImage)
{
FreeImage_Unload (aTmpBitmap);
}
break;
}
case FIF_HDR:
case FIF_EXR:
{
if (Format() == Image_Format_Gray
|| Format() == Image_Format_Alpha)
{
anImageToDump = FreeImage_ConvertToType (myLibImage, FIT_FLOAT);
}
else if (Format() == Image_Format_RGBA
|| Format() == Image_Format_BGRA)
{
anImageToDump = FreeImage_ConvertToType (myLibImage, FIT_RGBAF);
}
else
{
FREE_IMAGE_TYPE aImgTypeFI = FreeImage_GetImageType (myLibImage);
if (aImgTypeFI != FIT_RGBF
&& aImgTypeFI != FIT_RGBAF
&& aImgTypeFI != FIT_FLOAT)
{
anImageToDump = FreeImage_ConvertToType (myLibImage, FIT_RGBF);
}
}
break;
}
default:
{
if (FreeImage_GetImageType (myLibImage) != FIT_BITMAP)
{
anImageToDump = FreeImage_ConvertToType (myLibImage, FIT_BITMAP);
if (anImageToDump == NULL)
{
return false;
}
}
if (FreeImage_GetBPP (anImageToDump) != 24)
{
FIBITMAP* aTmpBitmap24 = FreeImage_ConvertTo24Bits (anImageToDump);
if (anImageToDump != myLibImage)
{
FreeImage_Unload (anImageToDump);
}
if (aTmpBitmap24 == NULL)
{
return false;
}
anImageToDump = aTmpBitmap24;
}
break;
}
}
if (anImageToDump == NULL)
{
return false;
}
#ifdef _WIN32
bool isSaved = (FreeImage_SaveU (anImageFormat, anImageToDump, aFileNameW.ToWideString()) != FALSE);
#else
bool isSaved = (FreeImage_Save (anImageFormat, anImageToDump, theFileName.ToCString()) != FALSE);
#endif
if (anImageToDump != myLibImage)
{
FreeImage_Unload (anImageToDump);
}
return isSaved;
#else
(void )theFileName;
Message::DefaultMessenger()->Send ("Error: FreeImage library is unavailable", Message_Fail);
return false;
#endif
}
// =======================================================================
// function : AdjustGamma
// purpose :
// =======================================================================
bool Image_FreeImage::AdjustGamma (const Standard_Real theGammaCorr)
{
#ifdef HAVE_FREEIMAGE
return FreeImage_AdjustGamma (myLibImage, theGammaCorr) != FALSE;
#else
(void )theGammaCorr;
return false;
#endif
}

View File

@@ -0,0 +1,107 @@
// Copyright (c) 2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _Image_FreeImage_HeaderFile
#define _Image_FreeImage_HeaderFile
#include <Image_AlienPixMapI.hxx>
struct FIBITMAP;
//! Image class that implements file reading/writing operations using FreeImage library.
//! Supported image formats:
//! - *.bmp - bitmap image, lossless format without compression.
//! - *.ppm - PPM (Portable Pixmap Format), lossless format without compression.
//! - *.png - PNG (Portable Network Graphics) lossless format with compression.
//! - *.jpg, *.jpe, *.jpeg - JPEG/JIFF (Joint Photographic Experts Group) lossy format (compressed with quality losses). YUV color space used (automatically converted from/to RGB).
//! - *.tif, *.tiff - TIFF (Tagged Image File Format).
//! - *.tga - TGA (Truevision Targa Graphic), lossless format.
//! - *.gif - GIF (Graphical Interchange Format), lossy format. Color stored using palette (up to 256 distinct colors).
//! - *.exr - OpenEXR high dynamic-range format (supports float pixel formats).
class Image_FreeImage : public Image_AlienPixMapI
{
DEFINE_STANDARD_RTTIEXT(Image_FreeImage, Image_AlienPixMapI)
public:
//! Return TRUE if FreeImage library is available.
Standard_EXPORT static bool IsAvailable();
//! Return default rows order used by FreeImage library, which is Bottom-Up.
static bool IsTopDownDefault() { return false; }
public:
//! Empty constructor.
Standard_EXPORT Image_FreeImage();
//! Destructor
Standard_EXPORT virtual ~Image_FreeImage();
using Image_AlienPixMapI::Load;
//! Read image data from stream.
Standard_EXPORT virtual bool Load (std::istream& theStream,
const TCollection_AsciiString& theFileName) Standard_OVERRIDE;
//! Read image data from memory buffer.
//! @param theData memory pointer to read from;
//! when NULL, function will attempt to open theFileName file
//! @param theLength memory buffer length
//! @param theFileName optional file name
Standard_EXPORT virtual bool Load (const Standard_Byte* theData,
Standard_Size theLength,
const TCollection_AsciiString& theFileName) Standard_OVERRIDE;
//! Write image data to file using file extension to determine compression format.
Standard_EXPORT virtual bool Save (const TCollection_AsciiString& theFileName) Standard_OVERRIDE;
//! Initialize image plane with required dimensions.
//! @param thePixelFormat if specified pixel format doesn't supported by image library
//! than nearest supported will be used instead!
//! @param theSizeX image width
//! @param theSizeY image height
//! @param theSizeRowBytes ignored parameter, 4-bytes alignment is enforced by FreeImage library
Standard_EXPORT virtual bool InitTrash (Image_Format thePixelFormat,
const Standard_Size theSizeX,
const Standard_Size theSizeY,
const Standard_Size theSizeRowBytes = 0) Standard_OVERRIDE;
//! Method correctly deallocate internal buffer.
Standard_EXPORT virtual void Clear() Standard_OVERRIDE;
//! Performs gamma correction on image.
//! theGamma - gamma value to use; a value of 1.0 leaves the image alone
Standard_EXPORT virtual bool AdjustGamma (Standard_Real theGammaCorr) Standard_OVERRIDE;
public:
//! Create default instance of this class.
virtual Handle(Image_AlienPixMapI) createDefault() const Standard_OVERRIDE
{
return new Image_FreeImage();
}
private:
//! Copying allowed only within Handles
Image_FreeImage (const Image_FreeImage& );
Image_FreeImage& operator= (const Image_FreeImage& );
private:
FIBITMAP* myLibImage;
};
DEFINE_STANDARD_HANDLE(Image_FreeImage, Image_AlienPixMapI)
#endif // _Image_FreeImage_HeaderFile

View File

@@ -174,7 +174,7 @@ public: //! @name low-level API for batch-processing (pixels reading / compariso
//! Setup scanlines order in memory - top-down or bottom-up.
//! Drawers should explicitly specify this value if current state IsTopDown() was ignored!
//! @param theIsTopDown top-down flag
inline void SetTopDown (const bool theIsTopDown)
virtual void SetTopDown (bool theIsTopDown)
{
myData.SetTopDown (theIsTopDown);
}

View File

@@ -0,0 +1,451 @@
// Copyright (c) 2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#if !defined(HAVE_FREEIMAGE) && defined(_WIN32)
#define HAVE_WINCODEC
#endif
#if defined(HAVE_WINCODEC)
//#include <initguid.h>
#include <wincodec.h>
#undef min
#undef max
#ifdef _MSC_VER
#pragma comment( lib, "Ole32.lib" )
#endif
#endif
#include <Image_WinCodec.hxx>
#include <Message.hxx>
#include <Message_Messenger.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <OSD_OpenFile.hxx>
#include <fstream>
#include <algorithm>
IMPLEMENT_STANDARD_RTTIEXT(Image_WinCodec, Image_AlienPixMapI)
namespace
{
#if defined(HAVE_WINCODEC)
//! Return a zero GUID
static GUID getNullGuid()
{
GUID aGuid = { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } };
return aGuid;
}
//! Sentry over IUnknown pointer.
template<class T> class Image_ComPtr
{
public:
//! Empty constructor.
Image_ComPtr()
: myPtr (NULL) {}
//! Destructor.
~Image_ComPtr()
{
Nullify();
}
//! Return TRUE if pointer is NULL.
bool IsNull() const { return myPtr == NULL; }
//! Release the pointer.
void Nullify()
{
if (myPtr != NULL)
{
myPtr->Release();
myPtr = NULL;
}
}
//! Return pointer for initialization.
T*& ChangePtr()
{
Standard_ASSERT_RAISE (myPtr == NULL, "Pointer cannot be initialized twice!");
return myPtr;
}
//! Return pointer.
T* get() { return myPtr; }
//! Return pointer.
T* operator->() { return get(); }
//! Cast handle to contained type
T& operator*() { return *get(); }
private:
T* myPtr;
};
//! Convert WIC GUID to Image_Format.
static Image_Format convertFromWicFormat (const WICPixelFormatGUID& theFormat)
{
if (theFormat == GUID_WICPixelFormat32bppBGRA)
{
return Image_Format_BGRA;
}
else if (theFormat == GUID_WICPixelFormat32bppBGR)
{
return Image_Format_BGR32;
}
else if (theFormat == GUID_WICPixelFormat24bppRGB)
{
return Image_Format_RGB;
}
else if (theFormat == GUID_WICPixelFormat24bppBGR)
{
return Image_Format_BGR;
}
else if (theFormat == GUID_WICPixelFormat8bppGray)
{
return Image_Format_Gray;
}
return Image_Format_UNKNOWN;
}
//! Convert Image_Format to WIC GUID.
static WICPixelFormatGUID convertToWicFormat (Image_Format theFormat)
{
switch (theFormat)
{
case Image_Format_BGRA: return GUID_WICPixelFormat32bppBGRA;
case Image_Format_BGR32: return GUID_WICPixelFormat32bppBGR;
case Image_Format_RGB: return GUID_WICPixelFormat24bppRGB;
case Image_Format_BGR: return GUID_WICPixelFormat24bppBGR;
case Image_Format_Gray: return GUID_WICPixelFormat8bppGray;
case Image_Format_Alpha: return GUID_WICPixelFormat8bppGray; // GUID_WICPixelFormat8bppAlpha
case Image_Format_GrayF: // GUID_WICPixelFormat32bppGrayFloat
case Image_Format_AlphaF:
case Image_Format_RGBAF: // GUID_WICPixelFormat128bppRGBAFloat
case Image_Format_RGBF: // GUID_WICPixelFormat96bppRGBFloat
case Image_Format_RGBA: // GUID_WICPixelFormat32bppRGBA
case Image_Format_RGB32: // GUID_WICPixelFormat32bppRGB
default:
return getNullGuid();
}
}
#endif
}
// =======================================================================
// function : IsAvailable
// purpose :
// =======================================================================
bool Image_WinCodec::IsAvailable()
{
#if defined(HAVE_WINCODEC)
return true;
#else
return false;
#endif
}
// =======================================================================
// function : Image_WinCodec
// purpose :
// =======================================================================
Image_WinCodec::Image_WinCodec()
{
SetTopDown (true);
}
// =======================================================================
// function : ~Image_WinCodec
// purpose :
// =======================================================================
Image_WinCodec::~Image_WinCodec()
{
Clear();
}
// =======================================================================
// function : InitTrash
// purpose :
// =======================================================================
bool Image_WinCodec::InitTrash (Image_Format thePixelFormat,
const Standard_Size theSizeX,
const Standard_Size theSizeY,
const Standard_Size theSizeRowBytes)
{
Clear();
Image_Format aFormat = thePixelFormat;
switch (aFormat)
{
case Image_Format_RGB:
aFormat = Image_Format_BGR;
break;
case Image_Format_RGB32:
aFormat = Image_Format_BGR32;
break;
case Image_Format_RGBA:
aFormat = Image_Format_BGRA;
break;
default:
break;
}
if (!base_type::InitTrash (aFormat, theSizeX, theSizeY, theSizeRowBytes))
{
return false;
}
SetTopDown (true);
return true;
}
// =======================================================================
// function : Load
// purpose :
// =======================================================================
bool Image_WinCodec::Load (const Standard_Byte* theData,
Standard_Size theLength,
const TCollection_AsciiString& theFileName)
{
Clear();
#if defined(HAVE_WINCODEC)
Image_ComPtr<IWICImagingFactory> aWicImgFactory;
CoInitializeEx (NULL, COINIT_MULTITHREADED);
if (CoCreateInstance (CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&aWicImgFactory.ChangePtr())) != S_OK)
{
Message::DefaultMessenger()->Send ("Error: cannot initialize WIC Imaging Factory", Message_Fail);
return false;
}
Image_ComPtr<IWICBitmapDecoder> aWicDecoder;
Image_ComPtr<IWICStream> aWicStream;
if (theData != NULL)
{
if (aWicImgFactory->CreateStream (&aWicStream.ChangePtr()) != S_OK
|| aWicStream->InitializeFromMemory ((BYTE* )theData, (DWORD )theLength) != S_OK)
{
Message::DefaultMessenger()->Send ("Error: cannot initialize WIC Stream", Message_Fail);
return false;
}
if (aWicImgFactory->CreateDecoderFromStream (aWicStream.get(), NULL, WICDecodeMetadataCacheOnDemand, &aWicDecoder.ChangePtr()) != S_OK)
{
Message::DefaultMessenger()->Send ("Error: cannot create WIC Image Decoder", Message_Fail);
return false;
}
}
else
{
const TCollection_ExtendedString aFileNameW (theFileName);
if (aWicImgFactory->CreateDecoderFromFilename (aFileNameW.ToWideString(), NULL, GENERIC_READ, WICDecodeMetadataCacheOnDemand, &aWicDecoder.ChangePtr()) != S_OK)
{
Message::DefaultMessenger()->Send ("Error: cannot create WIC Image Decoder", Message_Fail);
return false;
}
}
UINT aFrameCount = 0, aFrameSizeX = 0, aFrameSizeY = 0;
WICPixelFormatGUID aWicPixelFormat = getNullGuid();
Image_ComPtr<IWICBitmapFrameDecode> aWicFrameDecode;
if (aWicDecoder->GetFrameCount (&aFrameCount) != S_OK
|| aFrameCount < 1
|| aWicDecoder->GetFrame (0, &aWicFrameDecode.ChangePtr()) != S_OK
|| aWicFrameDecode->GetSize (&aFrameSizeX, &aFrameSizeY) != S_OK
|| aWicFrameDecode->GetPixelFormat (&aWicPixelFormat))
{
Message::DefaultMessenger()->Send ("Error: cannot get WIC Image Frame", Message_Fail);
return false;
}
Image_ComPtr<IWICFormatConverter> aWicConvertedFrame;
Image_Format aPixelFormat = convertFromWicFormat (aWicPixelFormat);
if (aPixelFormat == Image_Format_UNKNOWN)
{
aPixelFormat = Image_Format_RGB;
if (aWicImgFactory->CreateFormatConverter (&aWicConvertedFrame.ChangePtr()) != S_OK
|| aWicConvertedFrame->Initialize (aWicFrameDecode.get(), convertToWicFormat (aPixelFormat), WICBitmapDitherTypeNone, NULL, 0.0f, WICBitmapPaletteTypeCustom) != S_OK)
{
Message::DefaultMessenger()->Send ("Error: cannot convert WIC Image Frame to RGB format", Message_Fail);
return false;
}
aWicFrameDecode.Nullify();
}
if (!base_type::InitTrash (aPixelFormat, aFrameSizeX, aFrameSizeY))
{
Message::DefaultMessenger()->Send ("Error: cannot initialize memory for image", Message_Fail);
return false;
}
IWICBitmapSource* aWicSrc = aWicFrameDecode.get();
if(!aWicConvertedFrame.IsNull())
{
aWicSrc = aWicConvertedFrame.get();
}
if (aWicSrc->CopyPixels (NULL, (UINT )SizeRowBytes(), (UINT )SizeBytes(), ChangeData()) != S_OK)
{
Message::DefaultMessenger()->Send ("Error: cannot copy pixels from WIC Image", Message_Fail);
return false;
}
SetTopDown (true);
return true;
#else
(void )theData;
(void )theLength;
(void )theFileName;
Message::DefaultMessenger()->Send ("Error: WinCodec image library is unavailable", Message_Fail);
return false;
#endif
}
// =======================================================================
// function : Load
// purpose :
// =======================================================================
bool Image_WinCodec::Load (std::istream& theStream,
const TCollection_AsciiString& theFilePath)
{
return loadStreamToBuffer (theStream, theFilePath);
}
// =======================================================================
// function : Save
// purpose :
// =======================================================================
bool Image_WinCodec::Save (const TCollection_AsciiString& theFileName)
{
#if defined(HAVE_WINCODEC)
TCollection_AsciiString aFileNameLower = theFileName;
aFileNameLower.LowerCase();
GUID aFileFormat = getNullGuid();
if (aFileNameLower.EndsWith (".ppm"))
{
return savePPM (theFileName);
}
else if (aFileNameLower.EndsWith (".bmp"))
{
aFileFormat = GUID_ContainerFormatBmp;
}
else if (aFileNameLower.EndsWith (".png"))
{
aFileFormat = GUID_ContainerFormatPng;
}
else if (aFileNameLower.EndsWith (".jpg")
|| aFileNameLower.EndsWith (".jpeg"))
{
aFileFormat = GUID_ContainerFormatJpeg;
}
else if (aFileNameLower.EndsWith (".tiff"))
{
aFileFormat = GUID_ContainerFormatTiff;
}
else if (aFileNameLower.EndsWith (".gif"))
{
aFileFormat = GUID_ContainerFormatGif;
}
if (aFileFormat == getNullGuid())
{
Message::DefaultMessenger()->Send ("Error: unsupported image format", Message_Fail);
return false;
}
Image_ComPtr<IWICImagingFactory> aWicImgFactory;
CoInitializeEx (NULL, COINIT_MULTITHREADED);
if (CoCreateInstance (CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&aWicImgFactory.ChangePtr())) != S_OK)
{
Message::DefaultMessenger()->Send ("Error: cannot initialize WIC Imaging Factory", Message_Fail);
return false;
}
Image_ComPtr<IWICStream> aWicFileStream;
Image_ComPtr<IWICBitmapEncoder> aWicEncoder;
const TCollection_ExtendedString aFileNameW (theFileName);
if (aWicImgFactory->CreateStream (&aWicFileStream.ChangePtr()) != S_OK
|| aWicFileStream->InitializeFromFilename (aFileNameW.ToWideString(), GENERIC_WRITE) != S_OK)
{
Message::DefaultMessenger()->Send ("Error: cannot create WIC File Stream", Message_Fail);
return false;
}
if (aWicImgFactory->CreateEncoder (aFileFormat, NULL, &aWicEncoder.ChangePtr()) != S_OK
|| aWicEncoder->Initialize (aWicFileStream.get(), WICBitmapEncoderNoCache) != S_OK)
{
Message::DefaultMessenger()->Send ("Error: cannot create WIC Encoder", Message_Fail);
return false;
}
const WICPixelFormatGUID aWicPixelFormat = convertToWicFormat (myImgFormat);
if (aWicPixelFormat == getNullGuid())
{
Message::DefaultMessenger()->Send ("Error: unsupported pixel format", Message_Fail);
return false;
}
WICPixelFormatGUID aWicPixelFormatRes = aWicPixelFormat;
Image_ComPtr<IWICBitmapFrameEncode> aWicFrameEncode;
if (aWicEncoder->CreateNewFrame (&aWicFrameEncode.ChangePtr(), NULL) != S_OK
|| aWicFrameEncode->Initialize (NULL) != S_OK
|| aWicFrameEncode->SetSize ((UINT )SizeX(), (UINT )SizeY()) != S_OK
|| aWicFrameEncode->SetPixelFormat (&aWicPixelFormatRes) != S_OK)
{
Message::DefaultMessenger()->Send ("Error: cannot create WIC Frame", Message_Fail);
return false;
}
if (aWicPixelFormatRes != aWicPixelFormat)
{
Message::DefaultMessenger()->Send ("Error: pixel format is unsupported by image format", Message_Fail);
return false;
}
if (IsTopDown())
{
if (aWicFrameEncode->WritePixels ((UINT )SizeY(), (UINT )SizeRowBytes(), (UINT )SizeBytes(), (BYTE* )Data()) != S_OK)
{
Message::DefaultMessenger()->Send ("Error: cannot write pixels to WIC Frame", Message_Fail);
return false;
}
}
else
{
for (Standard_Size aRow = 0; aRow < SizeY(); ++aRow)
{
if (aWicFrameEncode->WritePixels (1, (UINT )SizeRowBytes(), (UINT )SizeRowBytes(), (BYTE* )Row (aRow)) != S_OK)
{
Message::DefaultMessenger()->Send ("Error: cannot write pixels to WIC Frame", Message_Fail);
return false;
}
}
}
if (aWicFrameEncode->Commit() != S_OK
|| aWicEncoder->Commit() != S_OK)
{
Message::DefaultMessenger()->Send ("Error: cannot commit data to WIC Frame", Message_Fail);
return false;
}
if (aWicFileStream->Commit (STGC_DEFAULT) != S_OK)
{
//Message::DefaultMessenger()->Send ("Error: cannot commit data to WIC File Stream", Message_Fail);
//return false;
}
return true;
#else
(void )theFileName;
Message::DefaultMessenger()->Send ("Error: WinCodec image library is unavailable", Message_Fail);
return false;
#endif
}

View File

@@ -0,0 +1,87 @@
// Copyright (c) 2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _Image_WinCodec_HeaderFile
#define _Image_WinCodec_HeaderFile
#include <Image_AlienPixMapI.hxx>
//! Image class that implements file reading/writing operations using WinCodec image library.
//! Supported image formats:
//! - *.bmp, *.png, *.jpg, *.tiff, *.gif.
class Image_WinCodec : public Image_AlienPixMapI
{
DEFINE_STANDARD_RTTIEXT(Image_WinCodec, Image_AlienPixMapI)
public:
//! Return TRUE if WinCodec library is available.
Standard_EXPORT static bool IsAvailable();
//! Return default rows order used by WinCodec library, which is Top-Down.
static bool IsTopDownDefault() { return true; }
public:
//! Empty constructor.
Standard_EXPORT Image_WinCodec();
//! Destructor
Standard_EXPORT virtual ~Image_WinCodec();
using Image_AlienPixMapI::Load;
//! Read image data from stream.
Standard_EXPORT virtual bool Load (std::istream& theStream,
const TCollection_AsciiString& theFileName) Standard_OVERRIDE;
//! Read image data from memory buffer.
//! @param theData memory pointer to read from;
//! when NULL, function will attempt to open theFileName file
//! @param theLength memory buffer length
//! @param theFileName optional file name
Standard_EXPORT virtual bool Load (const Standard_Byte* theData,
Standard_Size theLength,
const TCollection_AsciiString& theFileName) Standard_OVERRIDE;
//! Write image data to file using file extension to determine compression format.
Standard_EXPORT virtual bool Save (const TCollection_AsciiString& theFileName) Standard_OVERRIDE;
//! Initialize image plane with required dimensions.
//! @param thePixelFormat if specified pixel format doesn't supported by image library
//! than nearest supported will be used instead!
//! @param theSizeX image width
//! @param theSizeY image height
//! @param theSizeRowBytes may be ignored by this class and required alignment will be used instead!
Standard_EXPORT virtual bool InitTrash (Image_Format thePixelFormat,
const Standard_Size theSizeX,
const Standard_Size theSizeY,
const Standard_Size theSizeRowBytes = 0) Standard_OVERRIDE;
public:
//! Create default instance of this class.
virtual Handle(Image_AlienPixMapI) createDefault() const Standard_OVERRIDE
{
return new Image_WinCodec();
}
private:
//! Copying allowed only within Handles
Image_WinCodec (const Image_WinCodec& );
Image_WinCodec& operator= (const Image_WinCodec& );
};
DEFINE_STANDARD_HANDLE(Image_WinCodec, Image_AlienPixMapI)
#endif // _Image_WinCodec_HeaderFile

View File

@@ -159,10 +159,15 @@ void MeshVS_TextPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs,
!aDrawer->GetDouble ( MeshVS_DA_TextHeight, aHeight ) )
return;
Handle(Graphic3d_Group) aTextGroup = Prs->NewGroup();
Prs3d_Root::NewGroup ( Prs );
Handle (Graphic3d_Group) aTextGroup = Prs3d_Root::CurrentGroup ( Prs );
Quantity_Color AColor = Quantity_NOC_YELLOW;
Standard_CString AFont = Font_NOF_ASCII_MONO;
#ifdef _WIN32
Standard_CString AFont = "Courier New";
#else
Standard_CString AFont = "Courier";
#endif
Standard_Real AExpansionFactor = 1.0;
Standard_Real ASpace = 0.0;
Aspect_TypeOfStyleText ATextStyle = Aspect_TOST_ANNOTATION;
@@ -191,7 +196,10 @@ void MeshVS_TextPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs,
Handle (Graphic3d_AspectText3d) aTextAspect = new Graphic3d_AspectText3d ( AColor, AFont, AExpansionFactor, ASpace,
ATextStyle, ADisplayType );
aTextAspect->SetTextFontAspect( AFontAspectType );
aTextGroup->SetGroupPrimitivesAspect( aTextAspect );
Handle (Graphic3d_AspectMarker3d) anAspectMarker3d =
new Graphic3d_AspectMarker3d( Aspect_TOM_POINT, Quantity_NOC_GRAY, 1. );
aTextGroup->SetPrimitivesAspect( aTextAspect );
aTextGroup->SetPrimitivesAspect( anAspectMarker3d );
MeshVS_Buffer aCoordsBuf (3*aMaxFaceNodes*sizeof(Standard_Real));
TColStd_Array1OfReal aCoords (aCoordsBuf, 1, 3*aMaxFaceNodes);
@@ -213,8 +221,8 @@ void MeshVS_TextPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs,
}
anIDs.Subtract( IDsToExclude );
NCollection_Sequence<Graphic3d_Vec3> aPnts;
for (TColStd_MapIteratorOfPackedMapOfInteger it (anIDs); it.More(); it.Next())
TColStd_MapIteratorOfPackedMapOfInteger it (anIDs);
for( ; it.More(); it.Next() )
{
Standard_Integer aKey = it.Key();
if( GetText ( IsElement, aKey, aStr ) )
@@ -250,27 +258,15 @@ void MeshVS_TextPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs,
continue;
}
aPnts.Append (Graphic3d_Vec3 ((float )X, (float )Y, (float )Z));
Graphic3d_Vertex aPoint (X, Y, Z);
Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
anArrayOfPoints->AddVertex (X, Y, Z);
aTextGroup->AddPrimitiveArray (anArrayOfPoints);
aTextGroup->Text (aStr.ToCString(), aPoint, aHeight);
}
}
}
if (!aPnts.IsEmpty())
{
Handle(Graphic3d_Group) aMarkerGroup = Prs->NewGroup();
Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (aPnts.Size());
for (NCollection_Sequence<Graphic3d_Vec3>::Iterator aPntIter (aPnts); aPntIter.More(); aPntIter.Next())
{
const Graphic3d_Vec3& aPnt = aPntIter.Value();
anArrayOfPoints->AddVertex (aPnt.x(), aPnt.y(), aPnt.z());
}
Handle (Graphic3d_AspectMarker3d) anAspectMarker3d = new Graphic3d_AspectMarker3d (Aspect_TOM_POINT, Quantity_NOC_GRAY, 1.0);
aMarkerGroup->SetGroupPrimitivesAspect (anAspectMarker3d);
aMarkerGroup->AddPrimitiveArray (anArrayOfPoints);
}
if (!aCustomElements.IsEmpty())
CustomBuild ( Prs, aCustomElements, IDsToExclude, theDisplayMode );
}

View File

@@ -59,32 +59,6 @@ public:
return myPtr;
}
//! Move assignment.
//! This array will borrow all the data from theOther.
NCollection_LocalArray& Move (NCollection_LocalArray& theOther)
{
if (&theOther == this)
{
return *this;
}
Deallocate();
mySize = theOther.mySize;
if (theOther.myPtr == theOther.myBuffer)
{
// deep copy
myPtr = myBuffer;
memcpy (myPtr, theOther.myPtr, sizeof(theItem) * theOther.mySize);
memset (theOther.myPtr, 0, sizeof(theItem) * theOther.mySize);
}
else
{
myPtr = theOther.myPtr;
theOther.myPtr = theOther.myBuffer;
}
return *this;
}
private:
NCollection_LocalArray (const NCollection_LocalArray& );

View File

@@ -5,14 +5,14 @@ OpenGl_ArbIns.hxx
OpenGl_ArbSamplerObject.hxx
OpenGl_ArbTBO.hxx
OpenGl_ArbTexBindless.hxx
OpenGl_Aspects.cxx
OpenGl_Aspects.hxx
OpenGl_AspectsProgram.cxx
OpenGl_AspectsProgram.hxx
OpenGl_AspectsSprite.cxx
OpenGl_AspectsSprite.hxx
OpenGl_AspectsTextureSet.cxx
OpenGl_AspectsTextureSet.hxx
OpenGl_AspectFace.cxx
OpenGl_AspectFace.hxx
OpenGl_AspectLine.cxx
OpenGl_AspectLine.hxx
OpenGl_AspectMarker.cxx
OpenGl_AspectMarker.hxx
OpenGl_AspectText.cxx
OpenGl_AspectText.hxx
OpenGl_FrameStats.cxx
OpenGl_FrameStats.hxx
OpenGl_FrameStatsPrs.cxx

View File

@@ -1,4 +1,6 @@
// Copyright (c) 2019 OPEN CASCADE SAS
// Created on: 2011-07-13
// Created by: Sergey ZERCHANINOV
// Copyright (c) 2011-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
@@ -11,27 +13,136 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <OpenGl_AspectsTextureSet.hxx>
#include <Aspect_PolygonOffsetMode.hxx>
#include <NCollection_Vec3.hxx>
#include <OpenGl_AspectFace.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_Sampler.hxx>
#include <OpenGl_ShaderManager.hxx>
#include <OpenGl_ShaderProgram.hxx>
#include <OpenGl_Texture.hxx>
#include <OpenGl_TextureSet.hxx>
#include <OpenGl_Workspace.hxx>
#include <Graphic3d_ShaderProgram.hxx>
#include <Graphic3d_TextureMap.hxx>
#include <Graphic3d_TextureParams.hxx>
#include <Graphic3d_TypeOfReflection.hxx>
#include <Graphic3d_MaterialAspect.hxx>
#include <Image_PixMap.hxx>
namespace
{
static const TCollection_AsciiString THE_EMPTY_KEY;
//! Initialize default material in this way for backward compatibility.
inline Graphic3d_MaterialAspect initDefaultMaterial()
{
Graphic3d_MaterialAspect aMat;
aMat.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
aMat.SetAmbient (0.2f);
aMat.SetDiffuse (0.8f);
aMat.SetSpecular (0.1f);
aMat.SetEmissive (0.0f);
aMat.SetAmbientColor (Quantity_NOC_WHITE);
aMat.SetDiffuseColor (Quantity_NOC_WHITE);
aMat.SetEmissiveColor(Quantity_NOC_WHITE);
aMat.SetSpecularColor(Quantity_NOC_WHITE);
aMat.SetShininess (10.0f / 128.0f);
aMat.SetRefractionIndex (1.0f);
return aMat;
}
static const TCollection_AsciiString THE_EMPTY_KEY;
static const Graphic3d_MaterialAspect THE_DEFAULT_MATERIAL = initDefaultMaterial();
}
// =======================================================================
// function : OpenGl_AspectFace
// purpose :
// =======================================================================
OpenGl_AspectFace::OpenGl_AspectFace()
: myAspect (new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID, Quantity_NOC_WHITE,
Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0,
THE_DEFAULT_MATERIAL, THE_DEFAULT_MATERIAL)),
myShadingModel (Graphic3d_TOSM_UNLIT)
{
myAspect->SetShadingModel (myShadingModel);
myAspect->SetHatchStyle (Handle(Graphic3d_HatchStyle)());
}
// =======================================================================
// function : OpenGl_AspectFace
// purpose :
// =======================================================================
OpenGl_AspectFace::OpenGl_AspectFace (const Handle(Graphic3d_AspectFillArea3d)& theAspect)
: myShadingModel (Graphic3d_TOSM_DEFAULT)
{
SetAspect (theAspect);
}
// =======================================================================
// function : SetAspect
// purpose :
// =======================================================================
void OpenGl_AspectFace::SetAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect)
{
myAspect = theAspect;
const Graphic3d_MaterialAspect& aMat = theAspect->FrontMaterial();
myShadingModel = theAspect->ShadingModel() != Graphic3d_TOSM_UNLIT
&& (aMat.ReflectionMode (Graphic3d_TOR_AMBIENT)
|| aMat.ReflectionMode (Graphic3d_TOR_DIFFUSE)
|| aMat.ReflectionMode (Graphic3d_TOR_SPECULAR)
|| aMat.ReflectionMode (Graphic3d_TOR_EMISSION))
? theAspect->ShadingModel()
: Graphic3d_TOSM_UNLIT;
myAspectEdge.Aspect()->SetColor (theAspect->EdgeColor());
myAspectEdge.Aspect()->SetType (theAspect->EdgeLineType());
myAspectEdge.Aspect()->SetWidth (theAspect->EdgeWidth());
// update texture binding
myResources.UpdateTexturesRediness (myAspect->TextureSet());
// update shader program binding
const TCollection_AsciiString& aShaderKey = myAspect->ShaderProgram().IsNull() ? THE_EMPTY_KEY : myAspect->ShaderProgram()->GetId();
if (aShaderKey.IsEmpty() || myResources.ShaderProgramId != aShaderKey)
{
myResources.ResetShaderReadiness();
}
}
// =======================================================================
// function : Render
// purpose :
// =======================================================================
void OpenGl_AspectFace::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
{
theWorkspace->SetAspectFace (this);
}
// =======================================================================
// function : Release
// purpose :
// =======================================================================
void OpenGl_AspectsTextureSet::Release (OpenGl_Context* theCtx)
void OpenGl_AspectFace::Release (OpenGl_Context* theContext)
{
myResources.ReleaseTextures (theContext);
if (!myResources.ShaderProgram.IsNull()
&& theContext)
{
theContext->ShaderManager()->Unregister (myResources.ShaderProgramId,
myResources.ShaderProgram);
}
myResources.ShaderProgramId.Clear();
myResources.ResetShaderReadiness();
}
// =======================================================================
// function : ReleaseTextures
// purpose :
// =======================================================================
void OpenGl_AspectFace::Resources::ReleaseTextures (OpenGl_Context* theCtx)
{
if (myTextures.IsNull())
{
@@ -65,10 +176,10 @@ void OpenGl_AspectsTextureSet::Release (OpenGl_Context* theCtx)
}
// =======================================================================
// function : UpdateRediness
// function : UpdateTexturesRediness
// purpose :
// =======================================================================
void OpenGl_AspectsTextureSet::UpdateRediness (const Handle(Graphic3d_TextureSet)& theTextures)
void OpenGl_AspectFace::Resources::UpdateTexturesRediness (const Handle(Graphic3d_TextureSet)& theTextures)
{
const Standard_Integer aNbTexturesOld = !myTextures.IsNull() ? myTextures->Size() : 0;
const Standard_Integer aNbTexturesNew = !theTextures.IsNull() ? theTextures->Size() : 0;
@@ -118,18 +229,18 @@ void OpenGl_AspectsTextureSet::UpdateRediness (const Handle(Graphic3d_TextureSet
}
// =======================================================================
// function : build
// function : BuildTextures
// purpose :
// =======================================================================
void OpenGl_AspectsTextureSet::build (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_TextureSet)& theTextures)
void OpenGl_AspectFace::Resources::BuildTextures (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_TextureSet)& theTextures)
{
// release old texture resources
const Standard_Integer aNbTexturesOld = !myTextures.IsNull() ? myTextures->Size() : 0;
const Standard_Integer aNbTexturesNew = !theTextures.IsNull() ? theTextures->Size() : 0;
if (aNbTexturesOld != aNbTexturesNew)
{
Release (theCtx.get());
ReleaseTextures (theCtx.get());
if (aNbTexturesNew > 0)
{
myTextures = new OpenGl_TextureSet (theTextures->Size());
@@ -202,3 +313,30 @@ void OpenGl_AspectsTextureSet::build (const Handle(OpenGl_Context)& theCtx,
}
}
}
// =======================================================================
// function : BuildShader
// purpose :
// =======================================================================
void OpenGl_AspectFace::Resources::BuildShader (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_ShaderProgram)& theShader)
{
if (theCtx->core20fwd == NULL)
{
return;
}
// release old shader program resources
if (!ShaderProgram.IsNull())
{
theCtx->ShaderManager()->Unregister (ShaderProgramId, ShaderProgram);
ShaderProgramId.Clear();
ShaderProgram.Nullify();
}
if (theShader.IsNull())
{
return;
}
theCtx->ShaderManager()->Create (theShader, ShaderProgramId, ShaderProgram);
}

View File

@@ -0,0 +1,152 @@
// Created on: 2011-07-13
// Created by: Sergey ZERCHANINOV
// Copyright (c) 2011-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 _OpenGl_AspectFace_Header
#define _OpenGl_AspectFace_Header
#include <OpenGl_AspectLine.hxx>
#include <OpenGl_TextureSet.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_ShaderProgram.hxx>
#include <Graphic3d_TextureMap.hxx>
#include <Graphic3d_BSDF.hxx>
class OpenGl_Texture;
//! The element holding Graphic3d_AspectFillArea3d.
class OpenGl_AspectFace : public OpenGl_Element
{
public:
//! Empty constructor.
Standard_EXPORT OpenGl_AspectFace();
//! Create and assign parameters.
Standard_EXPORT OpenGl_AspectFace (const Handle(Graphic3d_AspectFillArea3d)& theAspect);
//! Return aspect.
const Handle(Graphic3d_AspectFillArea3d)& Aspect() const { return myAspect; }
//! Assign parameters.
Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect);
//! Set edge aspect.
void SetAspectEdge (const OpenGl_AspectLine* theAspectEdge) { myAspectEdge = *theAspectEdge; }
//! @return edge aspect.
const OpenGl_AspectLine* AspectEdge() const { return &myAspectEdge; }
//! Returns Shading Model.
Graphic3d_TypeOfShadingModel ShadingModel() const { return myShadingModel; }
//! Set if lighting should be disabled or not.
void SetNoLighting() { myShadingModel = Graphic3d_TOSM_UNLIT; }
//! Returns textures map.
const Handle(OpenGl_TextureSet)& TextureSet (const Handle(OpenGl_Context)& theCtx) const
{
if (!myResources.IsTextureReady())
{
myResources.BuildTextures (theCtx, myAspect->TextureSet());
myResources.SetTextureReady();
}
return myResources.TextureSet();
}
//! Init and return OpenGl shader program resource.
//! @return shader program resource.
const Handle(OpenGl_ShaderProgram)& ShaderProgramRes (const Handle(OpenGl_Context)& theCtx) const
{
if (!myResources.IsShaderReady())
{
myResources.BuildShader (theCtx, myAspect->ShaderProgram());
myResources.SetShaderReady();
}
return myResources.ShaderProgram;
}
Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const Standard_OVERRIDE;
Standard_EXPORT virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE;
//! Update presentation aspects parameters after their modification.
virtual void SynchronizeAspects() Standard_OVERRIDE { SetAspect (myAspect); }
protected:
//! OpenGl resources
mutable struct Resources
{
public:
//! Empty constructor.
Resources()
: myIsTextureReady (Standard_False),
myIsShaderReady (Standard_False) {}
//! Return TRUE if texture resource is up-to-date.
Standard_Boolean IsTextureReady() const { return myIsTextureReady; }
//! Return TRUE if shader resource is up-to-date.
Standard_Boolean IsShaderReady () const { return myIsShaderReady; }
//! Set texture resource up-to-date state.
void SetTextureReady() { myIsTextureReady = Standard_True; }
//! Set shader resource up-to-date state.
void SetShaderReady () { myIsShaderReady = Standard_True; }
//! Reset shader resource up-to-date state.
void ResetShaderReadiness () { myIsShaderReady = Standard_False; }
//! Return textures array.
const Handle(OpenGl_TextureSet)& TextureSet() const { return myTextures; }
//! Update texture resource up-to-date state.
Standard_EXPORT void UpdateTexturesRediness (const Handle(Graphic3d_TextureSet)& theTextures);
//! Build texture resource.
Standard_EXPORT void BuildTextures (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_TextureSet)& theTextures);
//! Build shader resource.
Standard_EXPORT void BuildShader (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_ShaderProgram)& theShader);
//! Release texture resource.
Standard_EXPORT void ReleaseTextures (OpenGl_Context* theCtx);
Handle(OpenGl_ShaderProgram) ShaderProgram;
TCollection_AsciiString ShaderProgramId;
private:
Handle(OpenGl_TextureSet) myTextures;
Standard_Boolean myIsTextureReady;
Standard_Boolean myIsShaderReady;
} myResources;
Handle(Graphic3d_AspectFillArea3d) myAspect;
OpenGl_AspectLine myAspectEdge;
Graphic3d_TypeOfShadingModel myShadingModel;
public:
DEFINE_STANDARD_ALLOC
};
#endif //_OpenGl_AspectFace_Header

View File

@@ -0,0 +1,112 @@
// Created on: 2011-07-13
// Created by: Sergey ZERCHANINOV
// Copyright (c) 2011-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.
#include <Graphic3d_ShaderProgram.hxx>
#include <OpenGl_AspectLine.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_ShaderManager.hxx>
#include <OpenGl_ShaderProgram.hxx>
#include <OpenGl_Workspace.hxx>
namespace
{
static const TCollection_AsciiString THE_EMPTY_KEY;
}
// =======================================================================
// function : OpenGl_AspectLine
// purpose :
// =======================================================================
OpenGl_AspectLine::OpenGl_AspectLine()
: myAspect (new Graphic3d_AspectLine3d (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0))
{
//
}
// =======================================================================
// function : OpenGl_AspectLine
// purpose :
// =======================================================================
OpenGl_AspectLine::OpenGl_AspectLine (const Handle(Graphic3d_AspectLine3d)& theAspect)
{
SetAspect (theAspect);
}
// =======================================================================
// function : SetAspect
// purpose :
// =======================================================================
void OpenGl_AspectLine::SetAspect (const Handle(Graphic3d_AspectLine3d)& theAspect)
{
myAspect = theAspect;
const TCollection_AsciiString& aShaderKey = myAspect->ShaderProgram().IsNull() ? THE_EMPTY_KEY : myAspect->ShaderProgram()->GetId();
if (aShaderKey.IsEmpty() || myResources.ShaderProgramId != aShaderKey)
{
myResources.ResetShaderReadiness();
}
}
// =======================================================================
// function : Render
// purpose :
// =======================================================================
void OpenGl_AspectLine::Render (const Handle(OpenGl_Workspace) &theWorkspace) const
{
theWorkspace->SetAspectLine (this);
}
// =======================================================================
// function : Release
// purpose :
// =======================================================================
void OpenGl_AspectLine::Release (OpenGl_Context* theContext)
{
if (!myResources.ShaderProgram.IsNull()
&& theContext)
{
theContext->ShaderManager()->Unregister (myResources.ShaderProgramId,
myResources.ShaderProgram);
}
myResources.ShaderProgramId.Clear();
myResources.ResetShaderReadiness();
}
// =======================================================================
// function : BuildShader
// purpose :
// =======================================================================
void OpenGl_AspectLine::Resources::BuildShader (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_ShaderProgram)& theShader)
{
if (theCtx->core20fwd == NULL)
{
return;
}
// release old shader program resources
if (!ShaderProgram.IsNull())
{
theCtx->ShaderManager()->Unregister (ShaderProgramId, ShaderProgram);
ShaderProgramId.Clear();
ShaderProgram.Nullify();
}
if (theShader.IsNull())
{
return;
}
theCtx->ShaderManager()->Create (theShader, ShaderProgramId, ShaderProgram);
}

View File

@@ -0,0 +1,91 @@
// Created on: 2011-07-13
// Created by: Sergey ZERCHANINOV
// Copyright (c) 2011-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 _OpenGl_AspectLine_Header
#define _OpenGl_AspectLine_Header
#include <TCollection_AsciiString.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <OpenGl_Element.hxx>
class OpenGl_ShaderProgram;
//! The element holding Graphic3d_AspectLine3d.
class OpenGl_AspectLine : public OpenGl_Element
{
public:
//! Empty constructor.
Standard_EXPORT OpenGl_AspectLine();
//! Create and assign line aspect.
Standard_EXPORT OpenGl_AspectLine (const Handle(Graphic3d_AspectLine3d)& theAspect);
//! Return line aspect.
const Handle(Graphic3d_AspectLine3d)& Aspect() const { return myAspect; }
//! Assign line aspect.
Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectLine3d)& theAspect);
//! Init and return OpenGl shader program resource.
//! @return shader program resource.
const Handle(OpenGl_ShaderProgram)& ShaderProgramRes (const Handle(OpenGl_Context)& theCtx) const
{
if (!myResources.IsShaderReady())
{
myResources.BuildShader (theCtx, myAspect->ShaderProgram());
myResources.SetShaderReady();
}
return myResources.ShaderProgram;
}
Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const Standard_OVERRIDE;
Standard_EXPORT virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE;
//! Update presentation aspects parameters after their modification.
virtual void SynchronizeAspects() Standard_OVERRIDE { SetAspect (myAspect); }
protected:
//! OpenGl resources
mutable struct Resources
{
public:
Resources() : myIsShaderReady (Standard_False) {}
Standard_Boolean IsShaderReady() const { return myIsShaderReady; }
void SetShaderReady() { myIsShaderReady = Standard_True; }
void ResetShaderReadiness() { myIsShaderReady = Standard_False; }
Standard_EXPORT void BuildShader (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_ShaderProgram)& theShader);
Handle(OpenGl_ShaderProgram) ShaderProgram;
TCollection_AsciiString ShaderProgramId;
private:
Standard_Boolean myIsShaderReady;
} myResources;
Handle(Graphic3d_AspectLine3d) myAspect;
public:
DEFINE_STANDARD_ALLOC
};
#endif //_OpenGl_AspectLine_Header

View File

@@ -1,4 +1,6 @@
// Copyright (c) 2019 OPEN CASCADE SAS
// Created on: 2011-07-14
// Created by: Sergey ZERCHANINOV
// Copyright (c) 2011-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
@@ -11,14 +13,18 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <OpenGl_AspectsSprite.hxx>
#include <OpenGl_AspectMarker.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_GraphicDriver.hxx>
#include <OpenGl_PointSprite.hxx>
#include <OpenGl_TextureSet.hxx>
#include <OpenGl_ShaderManager.hxx>
#include <OpenGl_ShaderProgram.hxx>
#include <OpenGl_Workspace.hxx>
#include <Image_PixMap.hxx>
#include <Graphic3d_MarkerImage.hxx>
#include <Graphic3d_ShaderProgram.hxx>
#include <NCollection_Vec4.hxx>
#include <TColStd_HArray1OfByte.hxx>
namespace
@@ -1326,13 +1332,17 @@ static const Standard_Byte OpenGl_AspectMarker_myMarkerRaster[] =
0x00,0x00, 0x00,0x00 // CROSS 32x32 = 7.0
};
//! Returns a parameters for the marker of the specified type and scale.
static void GetMarkerBitMapParam (const Aspect_TypeOfMarker theMarkerType,
const Standard_ShortReal& theScale,
Standard_Integer& theWidth,
Standard_Integer& theHeight,
Standard_Integer& theOffset,
Standard_Integer& theNumOfBytes)
// =======================================================================
// function : GetMarkerBitMapArray
// purpose : Returns a parameters for the marker of the specified
// type and scale.
// =======================================================================
void GetMarkerBitMapParam (const Aspect_TypeOfMarker theMarkerType,
const Standard_ShortReal& theScale,
Standard_Integer& theWidth,
Standard_Integer& theHeight,
Standard_Integer& theOffset,
Standard_Integer& theNumOfBytes)
{
const Standard_Integer aType = (Standard_Integer )((theMarkerType > Aspect_TOM_O) ? Aspect_TOM_O : theMarkerType);
const Standard_Real anIndex = (Standard_Real )(TEL_NO_OF_SIZES - 1) * (theScale - (Standard_Real )TEL_PM_START_SIZE)
@@ -1354,9 +1364,13 @@ static void GetMarkerBitMapParam (const Aspect_TypeOfMarker theMarkerType,
theNumOfBytes = theHeight * aNumOfBytesInRow;
}
//! Returns a marker image for the marker of the specified type and scale.
static Handle(Graphic3d_MarkerImage) GetTextureImage (const Aspect_TypeOfMarker theMarkerType,
const Standard_ShortReal& theScale)
// =======================================================================
// function : GetTextureImage
// purpose : Returns a marker image for the marker of the specified
// type and scale.
// =======================================================================
Handle(Graphic3d_MarkerImage) GetTextureImage (const Aspect_TypeOfMarker theMarkerType,
const Standard_ShortReal& theScale)
{
Standard_Integer aWidth, aHeight, anOffset, aNumOfBytes;
GetMarkerBitMapParam (theMarkerType, theScale, aWidth, aHeight, anOffset, aNumOfBytes);
@@ -1371,10 +1385,15 @@ static Handle(Graphic3d_MarkerImage) GetTextureImage (const Aspect_TypeOfMarker
return aTexture;
}
//! Merge two image pixmap into one. Used for creating image for following markers:
//! Aspect_TOM_O_POINT, Aspect_TOM_O_PLUS, Aspect_TOM_O_STAR, Aspect_TOM_O_X, Aspect_TOM_RING1, Aspect_TOM_RING2, Aspect_TOM_RING3
static Handle(Image_PixMap) MergeImages (const Handle(Image_PixMap)& theImage1,
const Handle(Image_PixMap)& theImage2)
// =======================================================================
// function : MergeImages
// purpose : Merge two image pixmap into one. Used for creating image for
// following markers: Aspect_TOM_O_POINT, Aspect_TOM_O_PLUS,
// Aspect_TOM_O_STAR, Aspect_TOM_O_X, Aspect_TOM_RING1,
// Aspect_TOM_RING2, Aspect_TOM_RING3
// =======================================================================
Handle(Image_PixMap) MergeImages (const Handle(Image_PixMap)& theImage1,
const Handle(Image_PixMap)& theImage2)
{
if (theImage1.IsNull() && theImage2.IsNull())
{
@@ -1436,11 +1455,64 @@ static Handle(Image_PixMap) MergeImages (const Handle(Image_PixMap)& theImage1,
return aResultImage;
}
// =======================================================================
// function : OpenGl_AspectMarker
// purpose :
// =======================================================================
OpenGl_AspectMarker::OpenGl_AspectMarker()
: myAspect (new Graphic3d_AspectMarker3d (Aspect_TOM_PLUS, Quantity_Color (Quantity_NOC_WHITE), 1.0f)),
myMarkerSize (1.0f)
{
//
}
// =======================================================================
// function : OpenGl_AspectMarker
// purpose :
// =======================================================================
OpenGl_AspectMarker::OpenGl_AspectMarker (const Handle(Graphic3d_AspectMarker3d)& theAspect)
: myMarkerSize (1.0f)
{
SetAspect (theAspect);
}
// =======================================================================
// function : SetAspect
// purpose :
// =======================================================================
void OpenGl_AspectMarker::SetAspect (const Handle(Graphic3d_AspectMarker3d)& theAspect)
{
myAspect = theAspect;
// update resource bindings
myResources.UpdateTexturesRediness (theAspect, myMarkerSize);
myResources.UpdateShaderRediness (theAspect);
}
// =======================================================================
// function : Render
// purpose :
// =======================================================================
void OpenGl_AspectMarker::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
{
theWorkspace->SetAspectMarker (this);
}
// =======================================================================
// function : Release
// purpose :
// =======================================================================
void OpenGl_AspectsSprite::Release (OpenGl_Context* theCtx)
void OpenGl_AspectMarker::Release (OpenGl_Context* theCtx)
{
myResources.ReleaseTextures(theCtx);
myResources.ReleaseShaders (theCtx);
}
// =======================================================================
// function : ReleaseTextures
// purpose :
// =======================================================================
void OpenGl_AspectMarker::Resources::ReleaseTextures (OpenGl_Context* theCtx)
{
myIsSpriteReady = Standard_False;
if (mySprite.IsNull())
@@ -1475,34 +1547,64 @@ void OpenGl_AspectsSprite::Release (OpenGl_Context* theCtx)
}
// =======================================================================
// function : UpdateRediness
// function : ReleaseShaders
// purpose :
// =======================================================================
void OpenGl_AspectsSprite::UpdateRediness (const Handle(Graphic3d_Aspects)& theAspect)
void OpenGl_AspectMarker::Resources::ReleaseShaders (OpenGl_Context* theCtx)
{
if (!myShaderProgram.IsNull() && theCtx != NULL)
{
theCtx->ShaderManager()->Unregister (myShaderProgramId,
myShaderProgram);
}
myShaderProgramId.Clear();
myIsShaderReady = Standard_False;
}
// =======================================================================
// function : UpdateTexturesRediness
// purpose :
// =======================================================================
void OpenGl_AspectMarker::Resources::UpdateTexturesRediness (const Handle(Graphic3d_AspectMarker3d)& theAspect,
Standard_ShortReal& theMarkerSize)
{
// update sprite resource bindings
TCollection_AsciiString aSpriteKeyNew, aSpriteAKeyNew;
spriteKeys (theAspect->MarkerImage(), theAspect->MarkerType(), theAspect->MarkerScale(), theAspect->ColorRGBA(), aSpriteKeyNew, aSpriteAKeyNew);
spriteKeys (theAspect->GetMarkerImage(), theAspect->Type(), theAspect->Scale(), theAspect->ColorRGBA(), aSpriteKeyNew, aSpriteAKeyNew);
const TCollection_AsciiString& aSpriteKeyOld = !mySprite.IsNull() ? mySprite ->First()->ResourceId() : THE_EMPTY_KEY;
const TCollection_AsciiString& aSpriteAKeyOld = !mySpriteA.IsNull() ? mySpriteA->First()->ResourceId() : THE_EMPTY_KEY;
if (aSpriteKeyNew.IsEmpty() || aSpriteKeyOld != aSpriteKeyNew
|| aSpriteAKeyNew.IsEmpty() || aSpriteAKeyOld != aSpriteAKeyNew)
{
myIsSpriteReady = Standard_False;
myMarkerSize = theAspect->MarkerScale();
theMarkerSize = theAspect->Scale();
}
}
// =======================================================================
// function : build
// function : UpdateShaderRediness
// purpose :
// =======================================================================
void OpenGl_AspectsSprite::build (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_MarkerImage)& theMarkerImage,
Aspect_TypeOfMarker theType,
Standard_ShortReal theScale,
const Graphic3d_Vec4& theColor,
Standard_ShortReal& theMarkerSize)
void OpenGl_AspectMarker::Resources::UpdateShaderRediness (const Handle(Graphic3d_AspectMarker3d)& theAspect)
{
// update shader program resource bindings
const TCollection_AsciiString& aShaderKey = theAspect->ShaderProgram().IsNull() ? THE_EMPTY_KEY : theAspect->ShaderProgram()->GetId();
if (aShaderKey.IsEmpty() || myShaderProgramId != aShaderKey)
{
myIsShaderReady = Standard_False;
}
}
// =======================================================================
// function : BuildSprites
// purpose :
// =======================================================================
void OpenGl_AspectMarker::Resources::BuildSprites (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_MarkerImage)& theMarkerImage,
const Aspect_TypeOfMarker theType,
const Standard_ShortReal theScale,
const Graphic3d_Vec4& theColor,
Standard_ShortReal& theMarkerSize)
{
// generate key for shared resource
TCollection_AsciiString aNewKey, aNewKeyA;
@@ -1871,16 +1973,43 @@ void OpenGl_AspectsSprite::build (const Handle(OpenGl_Context)& theCtx,
}
}
// =======================================================================
// function : BuildShader
// purpose :
// =======================================================================
void OpenGl_AspectMarker::Resources::BuildShader (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_ShaderProgram)& theShader)
{
if (theCtx->core20fwd == NULL)
{
return;
}
// release old shader program resources
if (!myShaderProgram.IsNull())
{
theCtx->ShaderManager()->Unregister (myShaderProgramId, myShaderProgram);
myShaderProgramId.Clear();
myShaderProgram.Nullify();
}
if (theShader.IsNull())
{
return;
}
theCtx->ShaderManager()->Create (theShader, myShaderProgramId, myShaderProgram);
}
// =======================================================================
// function : spriteKeys
// purpose :
// =======================================================================
void OpenGl_AspectsSprite::spriteKeys (const Handle(Graphic3d_MarkerImage)& theMarkerImage,
Aspect_TypeOfMarker theType,
Standard_ShortReal theScale,
const Graphic3d_Vec4& theColor,
TCollection_AsciiString& theKey,
TCollection_AsciiString& theKeyA)
void OpenGl_AspectMarker::Resources::spriteKeys (const Handle(Graphic3d_MarkerImage)& theMarkerImage,
const Aspect_TypeOfMarker theType,
const Standard_ShortReal theScale,
const Graphic3d_Vec4& theColor,
TCollection_AsciiString& theKey,
TCollection_AsciiString& theKeyA)
{
// generate key for shared resource
if (theType == Aspect_TOM_USERDEFINED)

View File

@@ -0,0 +1,180 @@
// Created on: 2011-07-13
// Created by: Sergey ZERCHANINOV
// Copyright (c) 2011-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 OpenGl_AspectMarker_Header
#define OpenGl_AspectMarker_Header
#include <Aspect_TypeOfMarker.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <TCollection_AsciiString.hxx>
#include <OpenGl_Element.hxx>
#include <OpenGl_TextureSet.hxx>
class OpenGl_PointSprite;
class OpenGl_ShaderProgram;
//! The element holding Graphic3d_AspectMarker3d.
class OpenGl_AspectMarker : public OpenGl_Element
{
public:
//! Empty constructor.
Standard_EXPORT OpenGl_AspectMarker();
//! Create and assign parameters.
Standard_EXPORT OpenGl_AspectMarker (const Handle(Graphic3d_AspectMarker3d)& theAspect);
//! Return the aspect.
const Handle(Graphic3d_AspectMarker3d)& Aspect() const { return myAspect; }
//! Assign new aspect.
Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectMarker3d)& theAspect);
//! @return marker size
Standard_ShortReal MarkerSize() const { return myMarkerSize; }
//! Init and return OpenGl point sprite resource.
//! @return point sprite texture.
const Handle(OpenGl_TextureSet)& SpriteRes (const Handle(OpenGl_Context)& theCtx) const
{
if (!myResources.IsSpriteReady())
{
myResources.BuildSprites (theCtx,
myAspect->GetMarkerImage(),
myAspect->Type(),
myAspect->Scale(),
myAspect->ColorRGBA(),
myMarkerSize);
myResources.SetSpriteReady();
}
return myResources.Sprite();
}
//! Init and return OpenGl highlight point sprite resource.
//! @return point sprite texture for highlight.
const Handle(OpenGl_TextureSet)& SpriteHighlightRes (const Handle(OpenGl_Context)& theCtx) const
{
if (!myResources.IsSpriteReady())
{
myResources.BuildSprites (theCtx,
myAspect->GetMarkerImage(),
myAspect->Type(),
myAspect->Scale(),
myAspect->ColorRGBA(),
myMarkerSize);
myResources.SetSpriteReady();
}
return myResources.SpriteA();
}
//! Init and return OpenGl shader program resource.
//! @return shader program resource.
const Handle(OpenGl_ShaderProgram)& ShaderProgramRes (const Handle(OpenGl_Context)& theCtx) const
{
if (!myResources.IsShaderReady())
{
myResources.BuildShader (theCtx, myAspect->ShaderProgram());
myResources.SetShaderReady();
}
return myResources.ShaderProgram();
}
Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const Standard_OVERRIDE;
Standard_EXPORT virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE;
//! Update presentation aspects parameters after their modification.
virtual void SynchronizeAspects() Standard_OVERRIDE { SetAspect (myAspect); }
protected:
//! OpenGl resources
mutable struct Resources
{
public:
//! Empty constructor.
Resources()
: myIsSpriteReady (Standard_False),
myIsShaderReady (Standard_False) {}
const Handle(OpenGl_TextureSet)& Sprite() const { return mySprite; }
const Handle(OpenGl_TextureSet)& SpriteA() const { return mySpriteA; }
const Handle(OpenGl_ShaderProgram)& ShaderProgram() const { return myShaderProgram; }
Standard_Boolean IsSpriteReady() const { return myIsSpriteReady; }
Standard_Boolean IsShaderReady() const { return myIsShaderReady; }
void SetSpriteReady() { myIsSpriteReady = Standard_True; }
void SetShaderReady() { myIsShaderReady = Standard_True; }
//! Update texture resource up-to-date state.
Standard_EXPORT void UpdateTexturesRediness (const Handle(Graphic3d_AspectMarker3d)& theAspect,
Standard_ShortReal& theMarkerSize);
//! Update shader resource up-to-date state.
Standard_EXPORT void UpdateShaderRediness (const Handle(Graphic3d_AspectMarker3d)& theAspect);
//! Release texture resource.
Standard_EXPORT void ReleaseTextures (OpenGl_Context* theCtx);
//! Release shader resource.
Standard_EXPORT void ReleaseShaders (OpenGl_Context* theCtx);
//! Build texture resources.
Standard_EXPORT void BuildSprites (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_MarkerImage)& theMarkerImage,
const Aspect_TypeOfMarker theType,
const Standard_ShortReal theScale,
const Graphic3d_Vec4& theColor,
Standard_ShortReal& theMarkerSize);
//! Build shader resources.
Standard_EXPORT void BuildShader (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_ShaderProgram)& theShader);
private:
//! Generate resource keys for a sprite.
static void spriteKeys (const Handle(Graphic3d_MarkerImage)& theMarkerImage,
const Aspect_TypeOfMarker theType,
const Standard_ShortReal theScale,
const Graphic3d_Vec4& theColor,
TCollection_AsciiString& theKey,
TCollection_AsciiString& theKeyA);
private:
Handle(OpenGl_TextureSet) mySprite;
Handle(OpenGl_TextureSet) mySpriteA;
Handle(OpenGl_ShaderProgram) myShaderProgram;
TCollection_AsciiString myShaderProgramId;
Standard_Boolean myIsSpriteReady;
Standard_Boolean myIsShaderReady;
} myResources;
Handle(Graphic3d_AspectMarker3d) myAspect;
mutable Standard_ShortReal myMarkerSize;
public:
DEFINE_STANDARD_ALLOC
};
#endif // OpenGl_AspectMarker_Header

121
src/OpenGl/OpenGl_AspectText.cxx Executable file
View File

@@ -0,0 +1,121 @@
// Created on: 2011-07-13
// Created by: Sergey ZERCHANINOV
// Copyright (c) 2011-2013 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_ShaderProgram.hxx>
#include <OpenGl_AspectText.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_Workspace.hxx>
#include <OpenGl_ShaderManager.hxx>
#include <OpenGl_ShaderProgram.hxx>
namespace
{
static const TCollection_AsciiString THE_EMPTY_KEY;
}
// =======================================================================
// function : OpenGl_AspectText
// purpose :
// =======================================================================
OpenGl_AspectText::OpenGl_AspectText()
: myAspect (new Graphic3d_AspectText3d (Quantity_Color (Quantity_NOC_WHITE), "Courier", 1.0, 0.0))
{
//
}
// =======================================================================
// function : OpenGl_AspectText
// purpose :
// =======================================================================
OpenGl_AspectText::OpenGl_AspectText (const Handle(Graphic3d_AspectText3d)& theAspect)
{
SetAspect (theAspect);
}
// =======================================================================
// function : ~OpenGl_AspectText
// purpose :
// =======================================================================
OpenGl_AspectText::~OpenGl_AspectText()
{
//
}
// =======================================================================
// function : SetAspect
// purpose :
// =======================================================================
void OpenGl_AspectText::SetAspect (const Handle(Graphic3d_AspectText3d)& theAspect)
{
myAspect = theAspect;
const TCollection_AsciiString& aShaderKey = myAspect->ShaderProgram().IsNull() ? THE_EMPTY_KEY : myAspect->ShaderProgram()->GetId();
if (aShaderKey.IsEmpty() || myResources.ShaderProgramId != aShaderKey)
{
myResources.ResetShaderReadiness();
}
}
// =======================================================================
// function : Render
// purpose :
// =======================================================================
void OpenGl_AspectText::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
{
theWorkspace->SetAspectText (this);
}
// =======================================================================
// function : Release
// purpose :
// =======================================================================
void OpenGl_AspectText::Release (OpenGl_Context* theContext)
{
if (!myResources.ShaderProgram.IsNull()
&& theContext)
{
theContext->ShaderManager()->Unregister (myResources.ShaderProgramId,
myResources.ShaderProgram);
}
myResources.ShaderProgramId.Clear();
myResources.ResetShaderReadiness();
}
// =======================================================================
// function : BuildShader
// purpose :
// =======================================================================
void OpenGl_AspectText::Resources::BuildShader (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_ShaderProgram)& theShader)
{
if (theCtx->core20fwd == NULL)
{
return;
}
// release old shader program resources
if (!ShaderProgram.IsNull())
{
theCtx->ShaderManager()->Unregister (ShaderProgramId, ShaderProgram);
ShaderProgramId.Clear();
ShaderProgram.Nullify();
}
if (theShader.IsNull())
{
return;
}
theCtx->ShaderManager()->Create (theShader, ShaderProgramId, ShaderProgram);
}

100
src/OpenGl/OpenGl_AspectText.hxx Executable file
View File

@@ -0,0 +1,100 @@
// Created on: 2011-07-13
// Created by: Sergey ZERCHANINOV
// Copyright (c) 2011-2013 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 OpenGl_AspectText_Header
#define OpenGl_AspectText_Header
#include <Font_FontAspect.hxx>
#include <Graphic3d_AspectText3d.hxx>
#include <TCollection_AsciiString.hxx>
#include <OpenGl_Element.hxx>
class OpenGl_ShaderProgram;
//! Text representation parameters
class OpenGl_AspectText : public OpenGl_Element
{
public:
//! Empty constructor.
Standard_EXPORT OpenGl_AspectText();
//! Create and assign parameters.
Standard_EXPORT OpenGl_AspectText (const Handle(Graphic3d_AspectText3d)& theAspect);
//! Destructor.
Standard_EXPORT virtual ~OpenGl_AspectText();
//! Return text aspect.
const Handle(Graphic3d_AspectText3d)& Aspect() const { return myAspect; }
//! Assign new parameters.
Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectText3d)& theAspect);
//! Init and return OpenGl shader program resource.
//! @return shader program resource.
const Handle(OpenGl_ShaderProgram)& ShaderProgramRes (const Handle(OpenGl_Context)& theCtx) const
{
if (!myResources.IsShaderReady())
{
myResources.BuildShader (theCtx, myAspect->ShaderProgram());
myResources.SetShaderReady();
}
return myResources.ShaderProgram;
}
Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const Standard_OVERRIDE;
Standard_EXPORT virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE;
//! Update presentation aspects parameters after their modification.
virtual void SynchronizeAspects() Standard_OVERRIDE { SetAspect (myAspect); }
protected:
//! OpenGl resources
mutable struct Resources
{
public:
Resources() : myIsShaderReady (Standard_False) {}
Standard_Boolean IsShaderReady() const { return myIsShaderReady; }
void SetShaderReady() { myIsShaderReady = Standard_True; }
void ResetShaderReadiness() { myIsShaderReady = Standard_False; }
Standard_EXPORT void BuildShader (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_ShaderProgram)& theShader);
Handle(OpenGl_ShaderProgram) ShaderProgram;
TCollection_AsciiString ShaderProgramId;
private:
Standard_Boolean myIsShaderReady;
} myResources;
Handle(Graphic3d_AspectText3d) myAspect;
public:
DEFINE_STANDARD_ALLOC
};
#endif // OpenGl_AspectText_Header

View File

@@ -1,112 +0,0 @@
// Copyright (c) 2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <OpenGl_Aspects.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_Workspace.hxx>
#include <Graphic3d_TypeOfReflection.hxx>
#include <Graphic3d_MaterialAspect.hxx>
namespace
{
//! Initialize default material in this way for backward compatibility.
inline Graphic3d_MaterialAspect initDefaultMaterial()
{
Graphic3d_MaterialAspect aMat;
aMat.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
aMat.SetAmbient (0.2f);
aMat.SetDiffuse (0.8f);
aMat.SetSpecular (0.1f);
aMat.SetEmissive (0.0f);
aMat.SetAmbientColor (Quantity_NOC_WHITE);
aMat.SetDiffuseColor (Quantity_NOC_WHITE);
aMat.SetEmissiveColor(Quantity_NOC_WHITE);
aMat.SetSpecularColor(Quantity_NOC_WHITE);
aMat.SetShininess (10.0f / 128.0f);
aMat.SetRefractionIndex (1.0f);
return aMat;
}
static const Graphic3d_MaterialAspect THE_DEFAULT_MATERIAL = initDefaultMaterial();
}
// =======================================================================
// function : OpenGl_Aspects
// purpose :
// =======================================================================
OpenGl_Aspects::OpenGl_Aspects()
: myAspect (new Graphic3d_Aspects()),
myShadingModel (Graphic3d_TOSM_UNLIT)
{
myAspect->SetInteriorStyle (Aspect_IS_SOLID);
myAspect->SetInteriorColor (Quantity_NOC_WHITE);
myAspect->SetEdgeColor (Quantity_NOC_WHITE);
myAspect->SetFrontMaterial (THE_DEFAULT_MATERIAL);
myAspect->SetBackMaterial (THE_DEFAULT_MATERIAL);
myAspect->SetShadingModel (myShadingModel);
myAspect->SetHatchStyle (Handle(Graphic3d_HatchStyle)());
}
// =======================================================================
// function : OpenGl_Aspects
// purpose :
// =======================================================================
OpenGl_Aspects::OpenGl_Aspects (const Handle(Graphic3d_Aspects)& theAspect)
: myShadingModel (Graphic3d_TOSM_DEFAULT)
{
SetAspect (theAspect);
}
// =======================================================================
// function : SetAspect
// purpose :
// =======================================================================
void OpenGl_Aspects::SetAspect (const Handle(Graphic3d_Aspects)& theAspect)
{
myAspect = theAspect;
const Graphic3d_MaterialAspect& aMat = theAspect->FrontMaterial();
myShadingModel = theAspect->ShadingModel() != Graphic3d_TOSM_UNLIT
&& (aMat.ReflectionMode (Graphic3d_TOR_AMBIENT)
|| aMat.ReflectionMode (Graphic3d_TOR_DIFFUSE)
|| aMat.ReflectionMode (Graphic3d_TOR_SPECULAR)
|| aMat.ReflectionMode (Graphic3d_TOR_EMISSION))
? theAspect->ShadingModel()
: Graphic3d_TOSM_UNLIT;
// invalidate resources
myResTextureSet.UpdateRediness (myAspect->TextureSet());
myResSprite.UpdateRediness (myAspect);
myResProgram.UpdateRediness (myAspect);
}
// =======================================================================
// function : Render
// purpose :
// =======================================================================
void OpenGl_Aspects::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
{
theWorkspace->SetAspects (this);
}
// =======================================================================
// function : Release
// purpose :
// =======================================================================
void OpenGl_Aspects::Release (OpenGl_Context* theContext)
{
myResTextureSet.Release (theContext);
myResSprite.Release (theContext);
myResProgram.Release (theContext);
}

View File

@@ -1,99 +0,0 @@
// Copyright (c) 2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _OpenGl_Aspects_Header
#define _OpenGl_Aspects_Header
#include <OpenGl_Element.hxx>
#include <OpenGl_AspectsProgram.hxx>
#include <OpenGl_AspectsTextureSet.hxx>
#include <OpenGl_AspectsSprite.hxx>
#include <Graphic3d_Aspects.hxx>
#include <Graphic3d_BSDF.hxx>
//! The element holding Graphic3d_Aspects.
class OpenGl_Aspects : public OpenGl_Element
{
public:
//! Empty constructor.
Standard_EXPORT OpenGl_Aspects();
//! Create and assign parameters.
Standard_EXPORT OpenGl_Aspects (const Handle(Graphic3d_Aspects)& theAspect);
//! Return aspect.
const Handle(Graphic3d_Aspects)& Aspect() const { return myAspect; }
//! Assign parameters.
Standard_EXPORT void SetAspect (const Handle(Graphic3d_Aspects)& theAspect);
//! Returns Shading Model.
Graphic3d_TypeOfShadingModel ShadingModel() const { return myShadingModel; }
//! Set if lighting should be disabled or not.
void SetNoLighting() { myShadingModel = Graphic3d_TOSM_UNLIT; }
//! Returns textures map.
const Handle(OpenGl_TextureSet)& TextureSet (const Handle(OpenGl_Context)& theCtx) const
{
return myResTextureSet.TextureSet (theCtx, myAspect->TextureSet());
}
//! Init and return OpenGl shader program resource.
//! @return shader program resource.
const Handle(OpenGl_ShaderProgram)& ShaderProgramRes (const Handle(OpenGl_Context)& theCtx) const
{
return myResProgram.ShaderProgram (theCtx, myAspect->ShaderProgram());
}
//! @return marker size
Standard_ShortReal MarkerSize() const { return myResSprite.MarkerSize(); }
//! Init and return OpenGl point sprite resource.
//! @return point sprite texture.
const Handle(OpenGl_TextureSet)& SpriteRes (const Handle(OpenGl_Context)& theCtx) const
{
return myResSprite.Sprite (theCtx, myAspect);
}
//! Init and return OpenGl highlight point sprite resource.
//! @return point sprite texture for highlight.
const Handle(OpenGl_TextureSet)& SpriteHighlightRes (const Handle(OpenGl_Context)& theCtx) const
{
return myResSprite.SpriteA (theCtx, myAspect);
}
Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const Standard_OVERRIDE;
Standard_EXPORT virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE;
//! Update presentation aspects parameters after their modification.
virtual void SynchronizeAspects() Standard_OVERRIDE { SetAspect (myAspect); }
protected:
//! OpenGl resources
mutable OpenGl_AspectsProgram myResProgram;
mutable OpenGl_AspectsTextureSet myResTextureSet;
mutable OpenGl_AspectsSprite myResSprite;
Handle(Graphic3d_Aspects) myAspect;
Graphic3d_TypeOfShadingModel myShadingModel;
public:
DEFINE_STANDARD_ALLOC
};
#endif // _OpenGl_Aspects_Header

View File

@@ -1,78 +0,0 @@
// Copyright (c) 2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <OpenGl_AspectsProgram.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_ShaderManager.hxx>
#include <OpenGl_ShaderProgram.hxx>
namespace
{
static const TCollection_AsciiString THE_EMPTY_KEY;
}
// =======================================================================
// function : Release
// purpose :
// =======================================================================
void OpenGl_AspectsProgram::Release (OpenGl_Context* theCtx)
{
if (!myShaderProgram.IsNull() && theCtx != NULL)
{
theCtx->ShaderManager()->Unregister (myShaderProgramId,
myShaderProgram);
}
myShaderProgramId.Clear();
myIsShaderReady = Standard_False;
}
// =======================================================================
// function : UpdateRediness
// purpose :
// =======================================================================
void OpenGl_AspectsProgram::UpdateRediness (const Handle(Graphic3d_Aspects)& theAspect)
{
const TCollection_AsciiString& aShaderKey = theAspect->ShaderProgram().IsNull() ? THE_EMPTY_KEY : theAspect->ShaderProgram()->GetId();
if (aShaderKey.IsEmpty() || myShaderProgramId != aShaderKey)
{
myIsShaderReady = Standard_False;
}
}
// =======================================================================
// function : build
// purpose :
// =======================================================================
void OpenGl_AspectsProgram::build (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_ShaderProgram)& theShader)
{
if (theCtx->core20fwd == NULL)
{
return;
}
// release old shader program resources
if (!myShaderProgram.IsNull())
{
theCtx->ShaderManager()->Unregister (myShaderProgramId, myShaderProgram);
myShaderProgramId.Clear();
myShaderProgram.Nullify();
}
if (theShader.IsNull())
{
return;
}
theCtx->ShaderManager()->Create (theShader, myShaderProgramId, myShaderProgram);
}

View File

@@ -1,63 +0,0 @@
// Copyright (c) 2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _OpenGl_AspectsProgram_Header
#define _OpenGl_AspectsProgram_Header
#include <Graphic3d_ShaderProgram.hxx>
class Graphic3d_Aspects;
class OpenGl_Context;
class OpenGl_ShaderProgram;
//! OpenGl resources for custom shading program.
class OpenGl_AspectsProgram
{
public:
DEFINE_STANDARD_ALLOC
public:
//! Empty constructor.
OpenGl_AspectsProgram() : myIsShaderReady (false) {}
//! Return shading program.
const Handle(OpenGl_ShaderProgram)& ShaderProgram (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_ShaderProgram)& theShader)
{
if (!myIsShaderReady)
{
build (theCtx, theShader);
myIsShaderReady = true;
}
return myShaderProgram;
}
//! Update shader resource up-to-date state.
Standard_EXPORT void UpdateRediness (const Handle(Graphic3d_Aspects)& theAspect);
//! Release resource.
Standard_EXPORT void Release (OpenGl_Context* theCtx);
private:
//! Build shader resource.
Standard_EXPORT void build (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_ShaderProgram)& theShader);
private:
Handle(OpenGl_ShaderProgram) myShaderProgram;
TCollection_AsciiString myShaderProgramId;
Standard_Boolean myIsShaderReady;
};
#endif // _OpenGl_Aspects_Header

View File

@@ -1,91 +0,0 @@
// Copyright (c) 2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _OpenGl_AspectsSprite_Header
#define _OpenGl_AspectsSprite_Header
#include <Graphic3d_Aspects.hxx>
#include <Graphic3d_TextureMap.hxx>
class OpenGl_Context;
class OpenGl_TextureSet;
//! OpenGl resources for custom point sprites.
class OpenGl_AspectsSprite
{
public:
DEFINE_STANDARD_ALLOC
public:
//! Empty constructor.
OpenGl_AspectsSprite() : myMarkerSize (1.0f), myIsSpriteReady (Standard_False) {}
Standard_ShortReal MarkerSize() const { return myMarkerSize; }
//! Return RGB sprite.
const Handle(OpenGl_TextureSet)& Sprite (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_Aspects)& theAspecta)
{
if (!myIsSpriteReady)
{
build (theCtx, theAspecta->MarkerImage(), theAspecta->MarkerType(), theAspecta->MarkerScale(), theAspecta->ColorRGBA(), myMarkerSize);
myIsSpriteReady = true;
}
return mySprite;
}
//! Return Alpha sprite.
const Handle(OpenGl_TextureSet)& SpriteA (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_Aspects)& theAspecta)
{
if (!myIsSpriteReady)
{
build (theCtx, theAspecta->MarkerImage(), theAspecta->MarkerType(), theAspecta->MarkerScale(), theAspecta->ColorRGBA(), myMarkerSize);
myIsSpriteReady = true;
}
return mySpriteA;
}
//! Update texture resource up-to-date state.
Standard_EXPORT void UpdateRediness (const Handle(Graphic3d_Aspects)& theAspect);
//! Release texture resource.
Standard_EXPORT void Release (OpenGl_Context* theCtx);
private:
//! Build texture resources.
Standard_EXPORT void build (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_MarkerImage)& theMarkerImage,
Aspect_TypeOfMarker theType,
Standard_ShortReal theScale,
const Graphic3d_Vec4& theColor,
Standard_ShortReal& theMarkerSize);
//! Generate resource keys for a sprite.
static void spriteKeys (const Handle(Graphic3d_MarkerImage)& theMarkerImage,
Aspect_TypeOfMarker theType,
Standard_ShortReal theScale,
const Graphic3d_Vec4& theColor,
TCollection_AsciiString& theKey,
TCollection_AsciiString& theKeyA);
private:
Handle(OpenGl_TextureSet) mySprite;
Handle(OpenGl_TextureSet) mySpriteA;
Standard_ShortReal myMarkerSize;
Standard_Boolean myIsSpriteReady;
};
#endif // _OpenGl_Aspects_Header

View File

@@ -1,63 +0,0 @@
// Copyright (c) 2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _OpenGl_AspectsTextureSet_Header
#define _OpenGl_AspectsTextureSet_Header
#include <Graphic3d_TextureMap.hxx>
#include <Graphic3d_TextureSet.hxx>
class OpenGl_Context;
class OpenGl_TextureSet;
//! OpenGl resources for custom textures.
class OpenGl_AspectsTextureSet
{
public:
DEFINE_STANDARD_ALLOC
public:
//! Empty constructor.
OpenGl_AspectsTextureSet() : myIsTextureReady (Standard_False) {}
//! Return textures array.
const Handle(OpenGl_TextureSet)& TextureSet (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_TextureSet)& theTextures)
{
if (!myIsTextureReady)
{
build (theCtx, theTextures);
myIsTextureReady = true;
}
return myTextures;
}
//! Update texture resource up-to-date state.
Standard_EXPORT void UpdateRediness (const Handle(Graphic3d_TextureSet)& theTextures);
//! Release texture resource.
Standard_EXPORT void Release (OpenGl_Context* theCtx);
private:
//! Build texture resource.
Standard_EXPORT void build (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_TextureSet)& theTextures);
private:
Handle(OpenGl_TextureSet) myTextures;
Standard_Boolean myIsTextureReady;
};
#endif // _OpenGl_AspectsTextureSet_Header

View File

@@ -338,7 +338,7 @@ Standard_Boolean OpenGl_BackgroundArray::createTextureArray (const Handle(OpenGl
// Get texture parameters
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
const OpenGl_Aspects* anAspectFace = theWorkspace->Aspects();
const OpenGl_AspectFace* anAspectFace = theWorkspace->AspectFace();
GLfloat aTextureWidth = (GLfloat )anAspectFace->TextureSet (aCtx)->First()->SizeX();
GLfloat aTextureHeight = (GLfloat )anAspectFace->TextureSet (aCtx)->First()->SizeY();

View File

@@ -19,7 +19,7 @@
#include <Aspect_GradientFillMethod.hxx>
#include <Aspect_FillMethod.hxx>
#include <Graphic3d_TypeOfBackground.hxx>
#include <OpenGl_Aspects.hxx>
#include <OpenGl_AspectFace.hxx>
#include <OpenGl_PrimitiveArray.hxx>
#include <OpenGl_Vec.hxx>
#include <OpenGl_Workspace.hxx>

View File

@@ -104,9 +104,9 @@ namespace
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());
const OpenGl_AspectFace* anObjAspectFace = aRenderPlane->ToUseObjectProperties() ? aGroupIter.Value()->AspectFace() : NULL;
thePlane->Update (aContext, anObjAspectFace != NULL ? anObjAspectFace->Aspect() : Handle(Graphic3d_AspectFillArea3d)());
theWorkspace->SetAspectFace (thePlane->AspectFace());
theWorkspace->SetRenderFilter (aPrevFilter);
if (!theWorkspace->ShouldRender (&thePlane->Primitives()))
{
@@ -124,8 +124,8 @@ namespace
const bool aColorMaskBack = aContext->SetColorMask (false);
// override aspects, disable culling
theWorkspace->SetAspects (&theWorkspace->NoneCulling());
theWorkspace->ApplyAspects();
theWorkspace->SetAspectFace (&theWorkspace->NoneCulling());
theWorkspace->ApplyAspectFace();
// evaluate number of pair faces
if (theWorkspace->UseZBuffer())
@@ -156,8 +156,8 @@ namespace
}
// override material, cull back faces
theWorkspace->SetAspects (&theWorkspace->FrontCulling());
theWorkspace->ApplyAspects();
theWorkspace->SetAspectFace (&theWorkspace->FrontCulling());
theWorkspace->ApplyAspectFace();
// enable all clip plane except the rendered one
aContext->ChangeClipping().EnableAllExcept (theClipChain, theSubPlaneIndex);
@@ -176,7 +176,7 @@ namespace
glEnable (GL_DEPTH_TEST);
}
theWorkspace->SetAspects (thePlane->AspectFace());
theWorkspace->SetAspectFace (thePlane->AspectFace());
renderPlane (theWorkspace, thePlane);
// turn on the current plane to restore initial state
@@ -207,7 +207,7 @@ void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)& theWorks
}
// remember current aspect face defined in workspace
const OpenGl_Aspects* aFaceAsp = theWorkspace->Aspects();
const OpenGl_AspectFace* aFaceAsp = theWorkspace->AspectFace();
// only filled primitives should be rendered
const Standard_Integer aPrevFilter = theWorkspace->RenderFilter();
@@ -247,6 +247,6 @@ void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)& theWorks
}
// restore rendering aspects
theWorkspace->SetAspects (aFaceAsp);
theWorkspace->SetAspectFace (aFaceAsp);
theWorkspace->SetRenderFilter (aPrevFilter);
}

View File

@@ -100,7 +100,7 @@ OpenGl_CappingPlaneResource::~OpenGl_CappingPlaneResource()
// purpose :
// =======================================================================
void OpenGl_CappingPlaneResource::Update (const Handle(OpenGl_Context)& ,
const Handle(Graphic3d_Aspects)& theObjAspect)
const Handle(Graphic3d_AspectFillArea3d)& theObjAspect)
{
updateTransform();
updateAspect (theObjAspect);
@@ -122,11 +122,11 @@ void OpenGl_CappingPlaneResource::Release (OpenGl_Context* theContext)
// function : updateAspect
// purpose :
// =======================================================================
void OpenGl_CappingPlaneResource::updateAspect (const Handle(Graphic3d_Aspects)& theObjAspect)
void OpenGl_CappingPlaneResource::updateAspect (const Handle(Graphic3d_AspectFillArea3d)& theObjAspect)
{
if (myAspect == NULL)
{
myAspect = new OpenGl_Aspects();
myAspect = new OpenGl_AspectFace();
myAspectMod = myPlaneRoot->MCountAspect() - 1; // mark out of sync
}

View File

@@ -18,7 +18,7 @@
#include <OpenGl_PrimitiveArray.hxx>
#include <OpenGl_Resource.hxx>
#include <OpenGl_Aspects.hxx>
#include <OpenGl_AspectFace.hxx>
#include <OpenGl_Matrix.hxx>
#include <Graphic3d_ClipPlane.hxx>
@@ -48,7 +48,7 @@ public:
//! @param theContext [in] the context
//! @param theObjAspect [in] object aspect
Standard_EXPORT void Update (const Handle(OpenGl_Context)& theContext,
const Handle(Graphic3d_Aspects)& theObjAspect);
const Handle(Graphic3d_AspectFillArea3d)& theObjAspect);
//! Release associated OpenGl resources.
//! @param theContext [in] the resource context.
@@ -61,7 +61,7 @@ public:
const Handle(Graphic3d_ClipPlane)& Plane() const { return myPlaneRoot; }
//! @return aspect face for rendering capping surface.
inline const OpenGl_Aspects* AspectFace() const { return myAspect; }
inline const OpenGl_AspectFace* AspectFace() const { return myAspect; }
//! @return evaluated orientation matrix to transform infinite plane.
inline const OpenGl_Matrix* Orientation() const { return &myOrientation; }
@@ -75,15 +75,15 @@ private:
void updateTransform();
//! Update resources.
void updateAspect (const Handle(Graphic3d_Aspects)& theObjAspect);
void updateAspect (const Handle(Graphic3d_AspectFillArea3d)& theObjAspect);
private:
OpenGl_PrimitiveArray myPrimitives; //!< vertices and texture coordinates for rendering
OpenGl_Matrix myOrientation; //!< plane transformation matrix.
OpenGl_Aspects* myAspect; //!< capping face aspect.
OpenGl_AspectFace* myAspect; //!< capping face aspect.
Handle(Graphic3d_ClipPlane) myPlaneRoot; //!< parent clipping plane structure.
Handle(Graphic3d_Aspects) myFillAreaAspect;//!< own capping aspect
Handle(Graphic3d_AspectFillArea3d) myFillAreaAspect; //!< own capping aspect
unsigned int myEquationMod; //!< modification counter for plane equation.
unsigned int myAspectMod; //!< modification counter for aspect.

View File

@@ -32,7 +32,7 @@
#include <OpenGl_Sampler.hxx>
#include <OpenGl_ShaderManager.hxx>
#include <OpenGl_Workspace.hxx>
#include <OpenGl_Aspects.hxx>
#include <OpenGl_AspectFace.hxx>
#include <Graphic3d_TransformUtils.hxx>
#include <Graphic3d_RenderingParams.hxx>
@@ -3179,12 +3179,12 @@ Handle(OpenGl_FrameBuffer) OpenGl_Context::SetDefaultFrameBuffer (const Handle(O
// function : SetShadingMaterial
// purpose :
// =======================================================================
void OpenGl_Context::SetShadingMaterial (const OpenGl_Aspects* theAspect,
void OpenGl_Context::SetShadingMaterial (const OpenGl_AspectFace* theAspect,
const Handle(Graphic3d_PresentationAttributes)& theHighlight)
{
const Handle(Graphic3d_Aspects)& anAspect = (!theHighlight.IsNull() && !theHighlight->BasicFillAreaAspect().IsNull())
? (const Handle(Graphic3d_Aspects)& )theHighlight->BasicFillAreaAspect()
: theAspect->Aspect();
const Handle(Graphic3d_AspectFillArea3d)& anAspect = (!theHighlight.IsNull() && !theHighlight->BasicFillAreaAspect().IsNull())
? theHighlight->BasicFillAreaAspect()
: theAspect->Aspect();
const bool toDistinguish = anAspect->Distinguish();
const bool toMapTexture = anAspect->ToMapTexture();
@@ -3260,14 +3260,14 @@ void OpenGl_Context::SetShadingMaterial (const OpenGl_Aspects* theAspect,
// function : CheckIsTransparent
// purpose :
// =======================================================================
Standard_Boolean OpenGl_Context::CheckIsTransparent (const OpenGl_Aspects* theAspect,
Standard_Boolean OpenGl_Context::CheckIsTransparent (const OpenGl_AspectFace* theAspect,
const Handle(Graphic3d_PresentationAttributes)& theHighlight,
Standard_ShortReal& theAlphaFront,
Standard_ShortReal& theAlphaBack)
{
const Handle(Graphic3d_Aspects)& anAspect = (!theHighlight.IsNull() && !theHighlight->BasicFillAreaAspect().IsNull())
? (const Handle(Graphic3d_Aspects)& )theHighlight->BasicFillAreaAspect()
: theAspect->Aspect();
const Handle(Graphic3d_AspectFillArea3d)& anAspect = (!theHighlight.IsNull() && !theHighlight->BasicFillAreaAspect().IsNull())
? theHighlight->BasicFillAreaAspect()
: theAspect->Aspect();
const bool toDistinguish = anAspect->Distinguish();
const Graphic3d_MaterialAspect& aMatFrontSrc = anAspect->FrontMaterial();

View File

@@ -133,7 +133,7 @@ typedef OpenGl_TmplCore44<OpenGl_GlCore43Back> OpenGl_GlCore44Back;
typedef OpenGl_TmplCore44<OpenGl_GlCore43> OpenGl_GlCore44;
class Graphic3d_PresentationAttributes;
class OpenGl_Aspects;
class OpenGl_AspectFace;
class OpenGl_FrameBuffer;
class OpenGl_Sampler;
class OpenGl_ShaderProgram;
@@ -705,17 +705,17 @@ public: //! @name methods to alter or retrieve current state
Standard_EXPORT Standard_Boolean BindProgram (const Handle(OpenGl_ShaderProgram)& theProgram);
//! Setup current shading material.
Standard_EXPORT void SetShadingMaterial (const OpenGl_Aspects* theAspect,
Standard_EXPORT void SetShadingMaterial (const OpenGl_AspectFace* theAspect,
const Handle(Graphic3d_PresentationAttributes)& theHighlight);
//! Checks if transparency is required for the given aspect and highlight style.
Standard_EXPORT static Standard_Boolean CheckIsTransparent (const OpenGl_Aspects* theAspect,
Standard_EXPORT static Standard_Boolean CheckIsTransparent (const OpenGl_AspectFace* theAspect,
const Handle(Graphic3d_PresentationAttributes)& theHighlight,
Standard_ShortReal& theAlphaFront,
Standard_ShortReal& theAlphaBack);
//! Checks if transparency is required for the given aspect and highlight style.
static Standard_Boolean CheckIsTransparent (const OpenGl_Aspects* theAspect,
static Standard_Boolean CheckIsTransparent (const OpenGl_AspectFace* theAspect,
const Handle(Graphic3d_PresentationAttributes)& theHighlight)
{
Standard_ShortReal anAlphaFront = 1.0f, anAlphaBack = 1.0f;

View File

@@ -361,7 +361,7 @@ void OpenGl_FrameStatsPrs::Render (const Handle(OpenGl_Workspace)& theWorkspace)
glDepthMask (GL_FALSE);
}
const OpenGl_Aspects* aTextAspectBack = theWorkspace->SetAspects (&myTextAspect);
const OpenGl_AspectText* aTextAspectBack = theWorkspace->SetAspectText (&myTextAspect);
aCtx->ModelWorldState.Push();
aCtx->ModelWorldState.ChangeCurrent().InitIdentity();
@@ -429,7 +429,7 @@ void OpenGl_FrameStatsPrs::Render (const Handle(OpenGl_Workspace)& theWorkspace)
aCtx->ModelWorldState.Pop();
aCtx->ApplyWorldViewMatrix();
theWorkspace->SetAspects (aTextAspectBack);
theWorkspace->SetAspectText (aTextAspectBack);
if (theWorkspace->UseDepthWrite() != wasEnabledDepth)
{
theWorkspace->UseDepthWrite() = wasEnabledDepth;

View File

@@ -55,7 +55,7 @@ protected:
Handle(OpenGl_FrameStats) myStatsPrev; //!< currently displayed stats
Handle(Graphic3d_TransformPers) myCountersTrsfPers; //!< transformation persistence for counters presentation
OpenGl_Text myCountersText; //!< counters presentation
OpenGl_Aspects myTextAspect; //!< text aspect
OpenGl_AspectText myTextAspect; //!< text aspect
Handle(Graphic3d_TransformPers) myChartTrsfPers; //!< transformation persistence for chart presentation
Handle(Graphic3d_ArrayOfTriangles) myChartArray; //!< array of chart triangles
Handle(OpenGl_VertexBuffer) myChartVertices; //!< VBO with chart triangles

View File

@@ -23,6 +23,7 @@
#include <Graphic3d_TransformPers.hxx>
#include <Graphic3d_TransformUtils.hxx>
#include <gp_Ax3.hxx>
#include <OpenGl_AspectLine.hxx>
#include <OpenGl_Workspace.hxx>
#include <OpenGl_View.hxx>
#include <Precision.hxx>
@@ -110,14 +111,10 @@ void OpenGl_GraduatedTrihedron::initGlResources (const Handle(OpenGl_Context)& t
myLabelValues.SetFontSize (theCtx, myData.ValuesSize());
myAspectLabels.Aspect()->SetTextFontAspect (myData.NamesFontAspect());
myAspectLabels.Aspect()->SetTextFont (!myData.NamesFont().IsEmpty()
? new TCollection_HAsciiString (myData.NamesFont())
: Handle(TCollection_HAsciiString )());
myAspectLabels.Aspect()->SetFont (myData.NamesFont());
myAspectValues.Aspect()->SetTextFontAspect (myData.ValuesFontAspect());
myAspectValues.Aspect()->SetTextFont (!myData.ValuesFont().IsEmpty()
? new TCollection_HAsciiString (myData.ValuesFont())
: Handle(TCollection_HAsciiString )());
myAspectValues.Aspect()->SetFont (myData.ValuesFont());
// Grid aspect
myGridLineAspect.Aspect()->SetColor (myData.GridColor());
@@ -403,7 +400,7 @@ void OpenGl_GraduatedTrihedron::renderAxis (const Handle(OpenGl_Workspace)& theW
{
const Axis& anAxis = myAxes[theIndex];
theWorkspace->SetAspects (&anAxis.LineAspect);
theWorkspace->SetAspectLine (&anAxis.LineAspect);
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
// Reset transformations
@@ -490,7 +487,7 @@ void OpenGl_GraduatedTrihedron::renderTickmarkLabels (const Handle(OpenGl_Worksp
if (aCurAspect.ToDrawTickmarks() && aCurAspect.TickmarksNumber() > 0)
{
theWorkspace->SetAspects (&myGridLineAspect);
theWorkspace->SetAspectLine (&myGridLineAspect);
OpenGl_Mat4 aModelMat (theMat);
@@ -521,7 +518,7 @@ void OpenGl_GraduatedTrihedron::renderTickmarkLabels (const Handle(OpenGl_Worksp
OpenGl_Vec3 aMiddle (theGridAxes.Ticks[theIndex] + aSizeVec * theGridAxes.Axes[theIndex] * 0.5f + aDir * (Standard_ShortReal)(theDpix * anOffset));
myAspectLabels.Aspect()->SetColor (anAxis.NameColor);
theWorkspace->SetAspects (&myAspectLabels);
theWorkspace->SetAspectText (&myAspectLabels);
anAxis.Label.SetPosition (aMiddle);
anAxis.Label.Render (theWorkspace);
}
@@ -529,7 +526,7 @@ void OpenGl_GraduatedTrihedron::renderTickmarkLabels (const Handle(OpenGl_Worksp
if (aCurAspect.ToDrawValues() && aCurAspect.TickmarksNumber() > 0)
{
myAspectValues.Aspect()->SetColor (anAxis.LineAspect.Aspect()->Color());
theWorkspace->SetAspects (&myAspectValues);
theWorkspace->SetAspectText (&myAspectValues);
Standard_Real anOffset = aCurAspect.ValuesOffset() + aCurAspect.TickmarksLength();
for (Standard_Integer anIt = 0; anIt <= aCurAspect.TickmarksNumber(); ++anIt)
@@ -608,7 +605,8 @@ void OpenGl_GraduatedTrihedron::Render (const Handle(OpenGl_Workspace)& theWorks
Standard_ExtCharacter anAxesState = getGridAxes (aCorners, aGridAxes);
// Remember current aspects
const OpenGl_Aspects* anOldAspectLine = theWorkspace->Aspects();
const OpenGl_AspectLine* anOldAspectLine = theWorkspace->AspectLine();
const OpenGl_AspectText* anOldAspectText = theWorkspace->AspectText();
OpenGl_Mat4 aModelMatrix;
aModelMatrix.Convert (aContext->WorldViewState.Current());
@@ -620,7 +618,7 @@ void OpenGl_GraduatedTrihedron::Render (const Handle(OpenGl_Workspace)& theWorks
if (myData.ToDrawGrid())
{
theWorkspace->SetAspects (&myGridLineAspect);
theWorkspace->SetAspectLine (&myGridLineAspect);
// render grid edges
if (anAxesState & XOO_XYO)
@@ -692,7 +690,8 @@ void OpenGl_GraduatedTrihedron::Render (const Handle(OpenGl_Workspace)& theWorks
renderTickmarkLabels (theWorkspace, aModelMatrix, anIter, aGridAxes, aDpix);
}
theWorkspace->SetAspects (anOldAspectLine);
theWorkspace->SetAspectLine (anOldAspectLine);
theWorkspace->SetAspectText (anOldAspectText);
aContext->WorldViewState.Pop();
aContext->ApplyWorldViewMatrix();

View File

@@ -21,7 +21,7 @@
#include <gp_Pnt.hxx>
#include <gp_Dir.hxx>
#include <NCollection_Array1.hxx>
#include <OpenGl_Aspects.hxx>
#include <OpenGl_AspectLine.hxx>
#include <OpenGl_Element.hxx>
#include <OpenGl_PrimitiveArray.hxx>
#include <OpenGl_Text.hxx>
@@ -70,7 +70,7 @@ private:
OpenGl_Vec3 Direction;
Quantity_Color NameColor;
OpenGl_Aspects LineAspect;
OpenGl_AspectLine LineAspect;
mutable OpenGl_Text Label;
mutable OpenGl_PrimitiveArray Tickmark;
mutable OpenGl_PrimitiveArray Line;
@@ -215,13 +215,13 @@ protected:
mutable Axis myAxes[3]; //!< Axes for trihedron
mutable Graphic3d_GraduatedTrihedron myData;
mutable OpenGl_Aspects myGridLineAspect; //!< Color grid properties
mutable OpenGl_AspectLine myGridLineAspect; //!< Color grid properties
protected: //! @name Labels properties
mutable OpenGl_Text myLabelValues;
mutable OpenGl_Aspects myAspectLabels;
mutable OpenGl_Aspects myAspectValues;
mutable OpenGl_Text myLabelValues;
mutable OpenGl_AspectText myAspectLabels;
mutable OpenGl_AspectText myAspectValues;
private:

View File

@@ -564,7 +564,8 @@ void OpenGl_GraphicDriver::TextSize (const Handle(Graphic3d_CView)& theView,
const Standard_ShortReal aHeight = (theHeight < 2.0f) ? DefaultTextHeight() : theHeight;
OpenGl_TextParam aTextParam;
aTextParam.Height = (int )aHeight;
OpenGl_Aspects aTextAspect;
OpenGl_AspectText aTextAspect;
aTextAspect.Aspect()->SetSpace (0.3);
TCollection_ExtendedString anExtText = theText;
NCollection_String aText (anExtText.ToExtString());
OpenGl_Text::StringSize(aCtx, aText, aTextAspect, aTextParam, theView->RenderingParams().Resolution, theWidth, theAscent, theDescent);

View File

@@ -58,7 +58,10 @@ namespace
// =======================================================================
OpenGl_Group::OpenGl_Group (const Handle(Graphic3d_Structure)& theStruct)
: Graphic3d_Group (theStruct),
myAspects(NULL),
myAspectLine(NULL),
myAspectFace(NULL),
myAspectMarker(NULL),
myAspectText(NULL),
myFirst(NULL),
myLast(NULL),
myIsRaytracable (Standard_False)
@@ -83,27 +86,21 @@ OpenGl_Group::~OpenGl_Group()
// function : SetGroupPrimitivesAspect
// purpose :
// =======================================================================
void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect)
void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspect)
{
if (IsDeleted())
{
return;
}
if (myAspects == NULL)
if (myAspectLine == NULL)
{
myAspects = new OpenGl_Aspects (theAspect);
myAspectLine = new OpenGl_AspectLine (theAspect);
}
else
{
myAspects->SetAspect (theAspect);
myAspectLine->SetAspect (theAspect);
}
if (OpenGl_Structure* aStruct = myIsRaytracable ? GlStruct() : NULL)
{
aStruct->UpdateStateIfRaytracable (Standard_False);
}
Update();
}
@@ -111,9 +108,9 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_Aspects)& th
// function : SetPrimitivesAspect
// purpose :
// =======================================================================
void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect)
void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspect)
{
if (myAspects == NULL)
if (myAspectLine == NULL)
{
SetGroupPrimitivesAspect (theAspect);
return;
@@ -123,8 +120,147 @@ void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspe
return;
}
OpenGl_Aspects* anAspects = new OpenGl_Aspects (theAspect);
AddElement (anAspects);
OpenGl_AspectLine* anAspectLine = new OpenGl_AspectLine (theAspect);
AddElement (anAspectLine);
Update();
}
// =======================================================================
// function : SetGroupPrimitivesAspect
// purpose :
// =======================================================================
void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect)
{
if (IsDeleted())
{
return;
}
if (myAspectFace == NULL)
{
myAspectFace = new OpenGl_AspectFace (theAspect);
}
else
{
myAspectFace->SetAspect (theAspect);
}
if (myIsRaytracable)
{
OpenGl_Structure* aStruct = GlStruct();
if (aStruct != NULL)
{
aStruct->UpdateStateIfRaytracable (Standard_False);
}
}
Update();
}
// =======================================================================
// function : SetPrimitivesAspect
// purpose :
// =======================================================================
void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect)
{
if (myAspectFace == NULL)
{
SetGroupPrimitivesAspect (theAspect);
return;
}
else if (IsDeleted())
{
return;
}
OpenGl_AspectFace* anAspectFace = new OpenGl_AspectFace (theAspect);
AddElement (anAspectFace);
Update();
}
// =======================================================================
// function : SetGroupPrimitivesAspect
// purpose :
// =======================================================================
void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspMarker)
{
if (IsDeleted())
{
return;
}
if (myAspectMarker == NULL)
{
myAspectMarker = new OpenGl_AspectMarker (theAspMarker);
}
else
{
myAspectMarker->SetAspect (theAspMarker);
}
Update();
}
// =======================================================================
// function : SetPrimitivesAspect
// purpose :
// =======================================================================
void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspMarker)
{
if (myAspectMarker == NULL)
{
SetGroupPrimitivesAspect (theAspMarker);
return;
}
else if (IsDeleted())
{
return;
}
OpenGl_AspectMarker* anAspectMarker = new OpenGl_AspectMarker (theAspMarker);
AddElement (anAspectMarker);
Update();
}
// =======================================================================
// function : SetGroupPrimitivesAspect
// purpose :
// =======================================================================
void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspText)
{
if (IsDeleted())
{
return;
}
if (myAspectText == NULL)
{
myAspectText = new OpenGl_AspectText (theAspText);
}
else
{
myAspectText->SetAspect (theAspText);
}
Update();
}
// =======================================================================
// function : SetPrimitivesAspect
// purpose :
// =======================================================================
void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspText)
{
if (myAspectText == NULL)
{
SetGroupPrimitivesAspect (theAspText);
return;
}
else if (IsDeleted())
{
return;
}
OpenGl_AspectText* anAspectText = new OpenGl_AspectText (theAspText);
AddElement (anAspectText);
Update();
}
@@ -134,13 +270,21 @@ void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspe
// =======================================================================
void OpenGl_Group::SynchronizeAspects()
{
if (myAspects != NULL)
if (myAspectFace != NULL)
{
myAspects->SynchronizeAspects();
if (OpenGl_Structure* aStruct = myIsRaytracable ? GlStruct() : NULL)
{
aStruct->UpdateStateIfRaytracable (Standard_False);
}
myAspectFace->SynchronizeAspects();
}
if (myAspectLine != NULL)
{
myAspectLine->SynchronizeAspects();
}
if (myAspectMarker != NULL)
{
myAspectMarker->SynchronizeAspects();
}
if (myAspectText != NULL)
{
myAspectText->SynchronizeAspects();
}
for (OpenGl_ElementNode* aNode = myFirst; aNode != NULL; aNode = aNode->next)
{
@@ -148,38 +292,6 @@ void OpenGl_Group::SynchronizeAspects()
}
}
// =======================================================================
// function : ReplaceAspects
// purpose :
// =======================================================================
void OpenGl_Group::ReplaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap)
{
if (theMap.IsEmpty())
{
return;
}
Handle(Graphic3d_Aspects) anAspect;
if (myAspects != NULL
&& theMap.Find (myAspects->Aspect(), anAspect))
{
myAspects->SetAspect (anAspect);
if (OpenGl_Structure* aStruct = myIsRaytracable ? GlStruct() : NULL)
{
aStruct->UpdateStateIfRaytracable (Standard_False);
}
}
for (OpenGl_ElementNode* aNode = myFirst; aNode != NULL; aNode = aNode->next)
{
OpenGl_Aspects* aGlAspect = dynamic_cast<OpenGl_Aspects*> (aNode->elem);
if (aGlAspect != NULL
&& theMap.Find (aGlAspect->Aspect(), anAspect))
{
aGlAspect->SetAspect (anAspect);
}
}
}
// =======================================================================
// function : AddPrimitiveArray
// purpose :
@@ -334,8 +446,14 @@ void OpenGl_Group::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
// Setup aspects
theWorkspace->SetAllowFaceCulling (myIsClosed
&& !theWorkspace->GetGlContext()->Clipping().IsClippingOrCappingOn());
const OpenGl_Aspects* aBackAspects = theWorkspace->Aspects();
const bool isAspectSet = myAspects != NULL && renderFiltered (theWorkspace, myAspects);
const OpenGl_AspectLine* aBackAspectLine = theWorkspace->AspectLine();
const OpenGl_AspectFace* aBackAspectFace = theWorkspace->AspectFace();
const OpenGl_AspectMarker* aBackAspectMarker = theWorkspace->AspectMarker();
const OpenGl_AspectText* aBackAspectText = theWorkspace->AspectText();
const bool isLineSet = myAspectLine && renderFiltered (theWorkspace, myAspectLine);
const bool isFaceSet = myAspectFace && renderFiltered (theWorkspace, myAspectFace);
const bool isMarkerSet = myAspectMarker && renderFiltered (theWorkspace, myAspectMarker);
const bool isTextSet = myAspectText && renderFiltered (theWorkspace, myAspectText);
// Render group elements
for (OpenGl_ElementNode* aNodeIter = myFirst; aNodeIter != NULL; aNodeIter = aNodeIter->next)
@@ -344,8 +462,14 @@ void OpenGl_Group::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
}
// Restore aspects
if (isAspectSet)
theWorkspace->SetAspects (aBackAspects);
if (isLineSet)
theWorkspace->SetAspectLine (aBackAspectLine);
if (isFaceSet)
theWorkspace->SetAspectFace (aBackAspectFace);
if (isMarkerSet)
theWorkspace->SetAspectMarker (aBackAspectMarker);
if (isTextSet)
theWorkspace->SetAspectText (aBackAspectText);
}
// =======================================================================
@@ -384,5 +508,8 @@ void OpenGl_Group::Release (const Handle(OpenGl_Context)& theGlCtx)
}
myLast = NULL;
OpenGl_Element::Destroy (theGlCtx.operator->(), myAspects);
OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectLine);
OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectFace);
OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectMarker);
OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectText);
}

View File

@@ -20,7 +20,10 @@
#include <Graphic3d_Structure.hxx>
#include <NCollection_List.hxx>
#include <OpenGl_Aspects.hxx>
#include <OpenGl_AspectLine.hxx>
#include <OpenGl_AspectFace.hxx>
#include <OpenGl_AspectMarker.hxx>
#include <OpenGl_AspectText.hxx>
#include <OpenGl_Element.hxx>
class OpenGl_Group;
@@ -45,25 +48,64 @@ public:
Standard_EXPORT virtual void Clear (const Standard_Boolean theToUpdateStructureMgr) Standard_OVERRIDE;
//! Return line aspect.
virtual Handle(Graphic3d_Aspects) Aspects() const Standard_OVERRIDE
virtual Handle(Graphic3d_AspectLine3d) LineAspect() const Standard_OVERRIDE
{
return myAspects != NULL
? myAspects->Aspect()
: Handle(Graphic3d_Aspects)();
return myAspectLine != NULL
? myAspectLine->Aspect()
: Handle(Graphic3d_AspectLine3d)();
}
//! Update aspect.
Standard_EXPORT virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect) Standard_OVERRIDE;
//! Update line aspect.
Standard_EXPORT virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspect) Standard_OVERRIDE;
//! Append aspect as an element.
Standard_EXPORT virtual void SetPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect) Standard_OVERRIDE;
//! Append line aspect as an element.
Standard_EXPORT virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspect) Standard_OVERRIDE;
//! Return marker aspect.
virtual Handle(Graphic3d_AspectMarker3d) MarkerAspect() const Standard_OVERRIDE
{
return myAspectMarker != NULL
? myAspectMarker->Aspect()
: Handle(Graphic3d_AspectMarker3d)();
}
//! Update marker aspect.
Standard_EXPORT virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspect) Standard_OVERRIDE;
//! Append marker aspect as an element.
Standard_EXPORT virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspect) Standard_OVERRIDE;
//! Return fill area aspect.
virtual Handle(Graphic3d_AspectFillArea3d) FillAreaAspect() const Standard_OVERRIDE
{
return myAspectFace != NULL
? myAspectFace->Aspect()
: Handle(Graphic3d_AspectFillArea3d)();
}
//! Update face aspect.
Standard_EXPORT virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect) Standard_OVERRIDE;
//! Append face aspect as an element.
Standard_EXPORT virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect) Standard_OVERRIDE;
//! Return marker aspect.
virtual Handle(Graphic3d_AspectText3d) TextAspect() const Standard_OVERRIDE
{
return myAspectText != NULL
? myAspectText->Aspect()
: Handle(Graphic3d_AspectText3d)();
}
//! Update text aspect.
Standard_EXPORT virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspect) Standard_OVERRIDE;
//! Append text aspect as an element.
Standard_EXPORT virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspect) Standard_OVERRIDE;
//! Update presentation aspects after their modification.
Standard_EXPORT virtual void SynchronizeAspects() Standard_OVERRIDE;
//! Replace aspects specified in the replacement map.
Standard_EXPORT virtual void ReplaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap) Standard_OVERRIDE;
//! Add primitive array element
Standard_EXPORT virtual void AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType,
const Handle(Graphic3d_IndexBuffer)& theIndices,
@@ -111,8 +153,8 @@ public:
//! Returns first OpenGL element node of the group.
const OpenGl_ElementNode* FirstNode() const { return myFirst; }
//! Returns OpenGL aspect.
const OpenGl_Aspects* GlAspects() const { return myAspects; }
//! Returns OpenGL face aspect.
const OpenGl_AspectFace* AspectFace() const { return myAspectFace; }
//! Is the group ray-tracable (contains ray-tracable elements)?
Standard_Boolean IsRaytracable() const { return myIsRaytracable; }
@@ -123,10 +165,15 @@ protected:
protected:
OpenGl_Aspects* myAspects;
OpenGl_ElementNode* myFirst;
OpenGl_ElementNode* myLast;
Standard_Boolean myIsRaytracable;
OpenGl_AspectLine* myAspectLine;
OpenGl_AspectFace* myAspectFace;
OpenGl_AspectMarker* myAspectMarker;
OpenGl_AspectText* myAspectText;
OpenGl_ElementNode* myFirst;
OpenGl_ElementNode* myLast;
Standard_Boolean myIsRaytracable;
public:

View File

@@ -13,7 +13,7 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <OpenGl_Aspects.hxx>
#include <OpenGl_AspectFace.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_GraphicDriver.hxx>
#include <OpenGl_IndexBuffer.hxx>
@@ -494,7 +494,8 @@ void OpenGl_PrimitiveArray::drawArray (const Handle(OpenGl_Workspace)& theWorksp
// function : drawEdges
// purpose :
// =======================================================================
void OpenGl_PrimitiveArray::drawEdges (const Handle(OpenGl_Workspace)& theWorkspace) const
void OpenGl_PrimitiveArray::drawEdges (const OpenGl_Vec4& theEdgeColour,
const Handle(OpenGl_Workspace)& theWorkspace) const
{
const Handle(OpenGl_Context)& aGlContext = theWorkspace->GetGlContext();
if (myVboAttribs.IsNull())
@@ -502,18 +503,18 @@ void OpenGl_PrimitiveArray::drawEdges (const Handle(OpenGl_Workspace)& theWorksp
return;
}
const OpenGl_Aspects* anAspect = theWorkspace->Aspects();
const OpenGl_AspectLine* anAspectLineOld = theWorkspace->SetAspectLine (theWorkspace->AspectFace()->AspectEdge());
const OpenGl_AspectLine* anAspect = theWorkspace->ApplyAspectLine();
#if !defined(GL_ES_VERSION_2_0)
const Standard_Integer aPolyModeOld = aGlContext->SetPolygonMode (GL_LINE);
#endif
if (aGlContext->core20fwd != NULL)
{
aGlContext->ShaderManager()->BindLineProgram (Handle(OpenGl_TextureSet)(), anAspect->Aspect()->EdgeLineType(),
aGlContext->ShaderManager()->BindLineProgram (Handle(OpenGl_TextureSet)(), anAspect->Aspect()->Type(),
Graphic3d_TOSM_UNLIT, Graphic3d_AlphaMode_Opaque, Standard_False,
anAspect->ShaderProgramRes (aGlContext));
}
aGlContext->SetSampleAlphaToCoverage (aGlContext->ShaderManager()->MaterialState().HasAlphaCutoff());
const GLenum aDrawMode = !aGlContext->ActiveProgram().IsNull()
&& aGlContext->ActiveProgram()->HasTessellationStage()
? GL_PATCHES
@@ -532,11 +533,9 @@ void OpenGl_PrimitiveArray::drawEdges (const Handle(OpenGl_Workspace)& theWorksp
/// 3) draw primitive's edges by vertexes if no edges and bounds array is specified
myVboAttribs->BindPositionAttribute (aGlContext);
aGlContext->SetColor4fv (theWorkspace->EdgeColor().a() >= 0.1f
? theWorkspace->EdgeColor()
: theWorkspace->View()->BackgroundColor());
aGlContext->SetTypeOfLine (anAspect->Aspect()->EdgeLineType());
aGlContext->SetLineWidth (anAspect->Aspect()->EdgeWidth());
aGlContext->SetColor4fv (theEdgeColour);
aGlContext->SetTypeOfLine (anAspect->Aspect()->Type());
aGlContext->SetLineWidth (anAspect->Aspect()->Width());
if (!myVboIndices.IsNull())
{
@@ -580,6 +579,7 @@ void OpenGl_PrimitiveArray::drawEdges (const Handle(OpenGl_Workspace)& theWorksp
myVboAttribs->UnbindAttribute (aGlContext, Graphic3d_TOA_POS);
// restore line context
theWorkspace->SetAspectLine (anAspectLineOld);
#if !defined(GL_ES_VERSION_2_0)
aGlContext->SetPolygonMode (aPolyModeOld);
#endif
@@ -591,7 +591,7 @@ void OpenGl_PrimitiveArray::drawEdges (const Handle(OpenGl_Workspace)& theWorksp
// =======================================================================
void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWorkspace) const
{
const OpenGl_Aspects* anAspectMarker = theWorkspace->Aspects();
const OpenGl_AspectMarker* anAspectMarker = theWorkspace->ApplyAspectMarker();
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
const GLenum aDrawMode = !aCtx->ActiveProgram().IsNull()
&& aCtx->ActiveProgram()->HasTessellationStage()
@@ -636,7 +636,7 @@ void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWork
aCtx->SetPointSize (1.0f);
return;
}
else if (anAspectMarker->Aspect()->MarkerType() == Aspect_TOM_POINT)
else if (anAspectMarker->Aspect()->Type() == Aspect_TOM_POINT)
{
aCtx->SetPointSize (anAspectMarker->MarkerSize());
aCtx->core11fwd->glDrawArrays (aDrawMode, 0, !myVboAttribs.IsNull() ? myVboAttribs->GetElemsNb() : myAttribs->NbElements);
@@ -644,7 +644,7 @@ void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWork
}
#if !defined(GL_ES_VERSION_2_0)
// Textured markers will be drawn with the glBitmap
else if (anAspectMarker->Aspect()->MarkerType() != Aspect_TOM_POINT
else if (anAspectMarker->Aspect()->Type() != Aspect_TOM_POINT
&& aSpriteNorm != NULL)
{
/**if (!isHilight && (myPArray->vcolours != NULL))
@@ -768,7 +768,12 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
return;
}
const OpenGl_Aspects* anAspectFace = theWorkspace->ApplyAspects();
const OpenGl_AspectFace* anAspectFace = theWorkspace->ApplyAspectFace();
const OpenGl_AspectLine* anAspectLine = theWorkspace->ApplyAspectLine();
const OpenGl_AspectMarker* anAspectMarker = myDrawMode == GL_POINTS
? theWorkspace->ApplyAspectMarker()
: theWorkspace->AspectMarker();
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
Handle(OpenGl_TextureSet) aTextureBack;
@@ -806,14 +811,14 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
{
if (myDrawMode == GL_POINTS)
{
if (anAspectFace->Aspect()->MarkerType() == Aspect_TOM_EMPTY)
if (anAspectMarker->Aspect()->Type() == Aspect_TOM_EMPTY)
{
return;
}
}
else
{
if (anAspectFace->Aspect()->LineType() == Aspect_TOL_EMPTY)
if (anAspectLine->Aspect()->Type() == Aspect_TOL_EMPTY)
{
return;
}
@@ -830,7 +835,7 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
Standard_Boolean toKeepData = Standard_False;
if (myDrawMode == GL_POINTS)
{
const Handle(OpenGl_TextureSet)& aSpriteNormRes = anAspectFace->SpriteRes (aCtx);
const Handle(OpenGl_TextureSet)& aSpriteNormRes = anAspectMarker->SpriteRes (aCtx);
const OpenGl_PointSprite* aSpriteNorm = !aSpriteNormRes.IsNull() ? dynamic_cast<const OpenGl_PointSprite*> (aSpriteNormRes->First().get()) : NULL;
toKeepData = aSpriteNorm != NULL
&& aSpriteNorm->IsDisplayList();
@@ -862,20 +867,20 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
case GL_POINTS:
{
aShadingModel = aCtx->ShaderManager()->ChooseMarkerShadingModel (anAspectFace->ShadingModel(), hasVertNorm);
const Handle(OpenGl_TextureSet)& aSpriteNormRes = anAspectFace->SpriteRes (aCtx);
const Handle(OpenGl_TextureSet)& aSpriteNormRes = anAspectMarker->SpriteRes (aCtx);
const OpenGl_PointSprite* aSpriteNorm = !aSpriteNormRes.IsNull() ? dynamic_cast<const OpenGl_PointSprite*> (aSpriteNormRes->First().get()) : NULL;
if (aSpriteNorm != NULL
&& !aSpriteNorm->IsDisplayList())
{
const Handle(OpenGl_TextureSet)& aSprite = toHilight && anAspectFace->SpriteHighlightRes (aCtx)->First()->IsValid()
? anAspectFace->SpriteHighlightRes (aCtx)
const Handle(OpenGl_TextureSet)& aSprite = toHilight && anAspectMarker->SpriteHighlightRes (aCtx)->First()->IsValid()
? anAspectMarker->SpriteHighlightRes (aCtx)
: aSpriteNormRes;
aCtx->BindTextures (aSprite);
aCtx->ShaderManager()->BindMarkerProgram (aSprite, aShadingModel, Graphic3d_AlphaMode_Opaque, hasVertColor, anAspectFace->ShaderProgramRes (aCtx));
aCtx->ShaderManager()->BindMarkerProgram (aSprite, aShadingModel, Graphic3d_AlphaMode_Opaque, hasVertColor, anAspectMarker->ShaderProgramRes (aCtx));
}
else
{
aCtx->ShaderManager()->BindMarkerProgram (Handle(OpenGl_TextureSet)(), aShadingModel, Graphic3d_AlphaMode_Opaque, hasVertColor, anAspectFace->ShaderProgramRes (aCtx));
aCtx->ShaderManager()->BindMarkerProgram (Handle(OpenGl_TextureSet)(), aShadingModel, Graphic3d_AlphaMode_Opaque, hasVertColor, anAspectMarker->ShaderProgramRes (aCtx));
}
break;
}
@@ -884,11 +889,11 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
{
aShadingModel = aCtx->ShaderManager()->ChooseLineShadingModel (anAspectFace->ShadingModel(), hasVertNorm);
aCtx->ShaderManager()->BindLineProgram (NULL,
anAspectFace->Aspect()->LineType(),
anAspectLine->Aspect()->Type(),
aShadingModel,
Graphic3d_AlphaMode_Opaque,
hasVertColor,
anAspectFace->ShaderProgramRes (aCtx));
anAspectLine->ShaderProgramRes (aCtx));
break;
}
default:
@@ -935,20 +940,19 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
{
aCtx->SetTextureMatrix (aCtx->ActiveTextures()->First()->Sampler()->Parameters());
}
aCtx->SetSampleAlphaToCoverage (aCtx->ShaderManager()->MaterialState().HasAlphaCutoff());
const Graphic3d_Vec4* aFaceColors = !myBounds.IsNull() && !toHilight && anAspectFace->Aspect()->InteriorStyle() != Aspect_IS_HIDDENLINE
? myBounds->Colors
: NULL;
const OpenGl_Vec4& anInteriorColor = theWorkspace->InteriorColor();
aCtx->SetColor4fv (anInteriorColor);
if (!myIsFillType)
{
const OpenGl_Vec4& aLineColor = myDrawMode == GL_POINTS ? theWorkspace->MarkerColor() : theWorkspace->LineColor();
aCtx->SetColor4fv (aLineColor);
if (myDrawMode == GL_LINES
|| myDrawMode == GL_LINE_STRIP)
{
aCtx->SetTypeOfLine (anAspectFace->Aspect()->LineType());
aCtx->SetLineWidth (anAspectFace->Aspect()->LineWidth());
aCtx->SetTypeOfLine (anAspectLine->Aspect()->Type());
aCtx->SetLineWidth (anAspectLine->Aspect()->Width());
}
drawArray (theWorkspace, aFaceColors, hasColorAttrib);
@@ -956,6 +960,8 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
return;
}
const OpenGl_Vec4& anInteriorColor = theWorkspace->InteriorColor();
aCtx->SetColor4fv (anInteriorColor);
drawArray (theWorkspace, aFaceColors, hasColorAttrib);
// draw outline - only closed triangulation with defined vertex normals can be drawn in this way
@@ -991,7 +997,8 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
}
else
{
drawEdges (theWorkspace);
const OpenGl_Vec4& anEdgeColor = theWorkspace->EdgeColor();
drawEdges (anEdgeColor, theWorkspace);
}
}
#endif

View File

@@ -124,7 +124,8 @@ private:
const Standard_Boolean theHasVertColor) const;
//! Auxiliary procedures
void drawEdges (const Handle(OpenGl_Workspace)& theWorkspace) const;
void drawEdges (const OpenGl_Vec4& theEdgeColour,
const Handle(OpenGl_Workspace)& theWorkspace) const;
void drawMarkers (const Handle(OpenGl_Workspace)& theWorkspace) const;

View File

@@ -16,7 +16,10 @@
#include <typeinfo>
#include <Graphic3d_TextureParams.hxx>
#include <OpenGl_Aspects.hxx>
#include <OpenGl_AspectFace.hxx>
#include <OpenGl_AspectLine.hxx>
#include <OpenGl_AspectMarker.hxx>
#include <OpenGl_AspectText.hxx>
#include <OpenGl_ClippingIterator.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_ShaderManager.hxx>
@@ -1156,6 +1159,7 @@ void OpenGl_ShaderManager::PushMaterialState (const Handle(OpenGl_ShaderProgram)
return;
}
myContext->SetSampleAlphaToCoverage (false);
if (myMaterialState.AlphaCutoff() < ShortRealLast())
{
glAlphaFunc (GL_GEQUAL, myMaterialState.AlphaCutoff());
@@ -1184,6 +1188,7 @@ void OpenGl_ShaderManager::PushMaterialState (const Handle(OpenGl_ShaderProgram)
return;
}
myContext->SetSampleAlphaToCoverage (myMaterialState.HasAlphaCutoff());
theProgram->SetUniform (myContext,
theProgram->GetStateLocation (OpenGl_OCCT_ALPHA_CUTOFF),
myMaterialState.AlphaCutoff());
@@ -1240,7 +1245,7 @@ void OpenGl_ShaderManager::PushOitState (const Handle(OpenGl_ShaderProgram)& the
// purpose :
// =======================================================================
void OpenGl_ShaderManager::PushInteriorState (const Handle(OpenGl_ShaderProgram)& theProgram,
const Handle(Graphic3d_Aspects)& theAspect) const
const Handle(Graphic3d_AspectFillArea3d)& theAspect) const
{
if (theProgram.IsNull()
|| !theProgram->IsValid())

View File

@@ -24,7 +24,10 @@
#include <OpenGl_SetOfShaderPrograms.hxx>
#include <OpenGl_ShaderStates.hxx>
#include <OpenGl_Aspects.hxx>
#include <OpenGl_AspectFace.hxx>
#include <OpenGl_AspectLine.hxx>
#include <OpenGl_AspectText.hxx>
#include <OpenGl_AspectMarker.hxx>
#include <OpenGl_MaterialState.hxx>
#include <OpenGl_Texture.hxx>
@@ -337,7 +340,7 @@ public:
//! Setup interior style line edges variables.
Standard_EXPORT void PushInteriorState (const Handle(OpenGl_ShaderProgram)& theProgram,
const Handle(Graphic3d_Aspects)& theAspect) const;
const Handle(Graphic3d_AspectFillArea3d)& theAspect) const;
public:

View File

@@ -52,7 +52,7 @@ void OpenGl_Structure::renderBoundingBox (const Handle(OpenGl_Workspace)& theWor
const Graphic3d_Vec3d aSize = myBndBox.Size();
aCtx->ActiveProgram()->SetUniform (aCtx, "occBBoxCenter", Graphic3d_Vec3 ((float )aCenter.x(), (float )aCenter.y(), (float )aCenter.z()));
aCtx->ActiveProgram()->SetUniform (aCtx, "occBBoxSize", Graphic3d_Vec3 ((float )aSize.x(), (float )aSize.y(), (float )aSize.z()));
aCtx->SetColor4fv (theWorkspace->InteriorColor());
aCtx->SetColor4fv (theWorkspace->LineColor());
const Handle(OpenGl_VertexBuffer)& aBoundBoxVertBuffer = aCtx->ShaderManager()->BoundBoxVertBuffer();
aBoundBoxVertBuffer->BindAttribute (aCtx, Graphic3d_TOA_POS);
@@ -87,7 +87,7 @@ void OpenGl_Structure::renderBoundingBox (const Handle(OpenGl_Workspace)& theWor
};
aCtx->ShaderManager()->BindLineProgram (Handle(OpenGl_TextureSet)(), Aspect_TOL_SOLID, Graphic3d_TOSM_UNLIT, Graphic3d_AlphaMode_Opaque, false, Handle(OpenGl_ShaderProgram)());
aCtx->SetColor4fv (theWorkspace->InteriorColor());
aCtx->SetColor4fv (theWorkspace->LineColor());
aCtx->core11fwd->glDisable (GL_LIGHTING);
aCtx->core11->glEnableClientState (GL_VERTEX_ARRAY);
aCtx->core11->glVertexPointer (3, GL_FLOAT, 0, aVerts[0].GetData());
@@ -460,7 +460,10 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con
aCtx->ApplyModelViewMatrix();
// remember aspects
const OpenGl_Aspects* aPrevAspectFace = theWorkspace->Aspects();
const OpenGl_AspectLine* aPrevAspectLine = theWorkspace->AspectLine();
const OpenGl_AspectFace* aPrevAspectFace = theWorkspace->AspectFace();
const OpenGl_AspectMarker* aPrevAspectMarker = theWorkspace->AspectMarker();
const OpenGl_AspectText* aPrevAspectText = theWorkspace->AspectText();
// Apply correction for mirror transform
if (myIsMirrored)
@@ -588,7 +591,10 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &theWorkspace) con
aCtx->SetGlNormalizeEnabled (anOldGlNormalize);
// Restore aspects
theWorkspace->SetAspects (aPrevAspectFace);
theWorkspace->SetAspectLine (aPrevAspectLine);
theWorkspace->SetAspectFace (aPrevAspectFace);
theWorkspace->SetAspectMarker (aPrevAspectMarker);
theWorkspace->SetAspectText (aPrevAspectText);
// Apply highlight box
if (!isClipped

View File

@@ -19,7 +19,10 @@
#include <Graphic3d_CStructure.hxx>
#include <Graphic3d_SequenceOfHClipPlane.hxx>
#include <OpenGl_Aspects.hxx>
#include <OpenGl_AspectLine.hxx>
#include <OpenGl_AspectFace.hxx>
#include <OpenGl_AspectMarker.hxx>
#include <OpenGl_AspectText.hxx>
#include <OpenGl_GraphicDriver.hxx>
#include <OpenGl_Group.hxx>

View File

@@ -13,7 +13,7 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <OpenGl_Aspects.hxx>
#include <OpenGl_AspectText.hxx>
#include <OpenGl_GlCore11.hxx>
#include <OpenGl_GraphicDriver.hxx>
#include <OpenGl_ShaderManager.hxx>
@@ -39,8 +39,6 @@ namespace
0.0, 0.0, 0.0, 1.0
};
static const TCollection_AsciiString THE_DEFAULT_FONT (Font_NOF_ASCII_MONO);
//! Auxiliary tool for setting polygon offset temporarily.
struct BackPolygonOffsetSentry
{
@@ -289,7 +287,7 @@ void OpenGl_Text::Release (OpenGl_Context* theCtx)
// =======================================================================
void OpenGl_Text::StringSize (const Handle(OpenGl_Context)& theCtx,
const NCollection_String& theText,
const OpenGl_Aspects& theTextAspect,
const OpenGl_AspectText& theTextAspect,
const OpenGl_TextParam& theParams,
const unsigned int theResolution,
Standard_ShortReal& theWidth,
@@ -355,8 +353,10 @@ void OpenGl_Text::StringSize (const Handle(OpenGl_Context)& theCtx,
// =======================================================================
void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
{
const OpenGl_Aspects* aTextAspect = theWorkspace->ApplyAspects();
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
theWorkspace->SetAspectFace (&theWorkspace->FontFaceAspect());
theWorkspace->ApplyAspectFace();
const OpenGl_AspectText* aTextAspect = theWorkspace->ApplyAspectText();
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
const Handle(OpenGl_TextureSet) aPrevTexture = aCtx->BindTextures (Handle(OpenGl_TextureSet)());
// Bind custom shader program or generate default version
@@ -390,9 +390,10 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
// purpose :
// =======================================================================
void OpenGl_Text::Render (const Handle(OpenGl_Context)& theCtx,
const OpenGl_Aspects& theTextAspect,
unsigned int theResolution) const
const OpenGl_AspectText& theTextAspect,
const unsigned int theResolution) const
{
const bool anAlphaToCoverageOld = theCtx->SetSampleAlphaToCoverage (false);
#if !defined(GL_ES_VERSION_2_0)
const Standard_Integer aPrevPolygonMode = theCtx->SetPolygonMode (GL_FILL);
const bool aPrevHatchingMode = theCtx->SetPolygonHatchEnabled (false);
@@ -407,6 +408,7 @@ void OpenGl_Text::Render (const Handle(OpenGl_Context)& theCtx,
theCtx->SetPolygonMode (aPrevPolygonMode);
theCtx->SetPolygonHatchEnabled (aPrevHatchingMode);
#endif
theCtx->SetSampleAlphaToCoverage (anAlphaToCoverageOld);
}
// =======================================================================
@@ -414,8 +416,8 @@ void OpenGl_Text::Render (const Handle(OpenGl_Context)& theCtx,
// purpose :
// =======================================================================
void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
const OpenGl_Aspects& theTextAspect,
const OpenGl_Vec3& theDVec) const
const OpenGl_AspectText& theTextAspect,
const OpenGl_Vec3 theDVec) const
{
OpenGl_Mat4d aModViewMat;
OpenGl_Mat4d aProjectMat;
@@ -432,7 +434,7 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
{
Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, myPoint.x() + theDVec.x(), myPoint.y() + theDVec.y(), 0.f);
Graphic3d_TransformUtils::Scale<GLdouble> (aModViewMat, 1.f, -1.f, 1.f);
Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect.Aspect()->TextAngle(), 0.f, 0.f, 1.f);
Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect.Aspect()->GetTextAngle(), 0.f, 0.f, 1.f);
}
else
{
@@ -474,10 +476,10 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
else
{
Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, anObjX, anObjY, anObjZ);
Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect.Aspect()->TextAngle(), 0.0, 0.0, 1.0);
Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect.Aspect()->GetTextAngle(), 0.0, 0.0, 1.0);
}
if (!theTextAspect.Aspect()->IsTextZoomable())
if (!theTextAspect.Aspect()->GetTextZoomable())
{
Graphic3d_TransformUtils::Scale<GLdouble> (aModViewMat, myScaleHeight, myScaleHeight, myScaleHeight);
}
@@ -514,7 +516,7 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
// purpose :
// =======================================================================
void OpenGl_Text::drawText (const Handle(OpenGl_Context)& theCtx,
const OpenGl_Aspects& theTextAspect) const
const OpenGl_AspectText& theTextAspect) const
{
(void )theTextAspect;
if (myVertsVbo.Length() != myTextures.Length()
@@ -545,15 +547,14 @@ void OpenGl_Text::drawText (const Handle(OpenGl_Context)& theCtx,
// function : FontKey
// purpose :
// =======================================================================
TCollection_AsciiString OpenGl_Text::FontKey (const OpenGl_Aspects& theAspect,
Standard_Integer theHeight,
unsigned int theResolution)
TCollection_AsciiString OpenGl_Text::FontKey (const OpenGl_AspectText& theAspect,
const Standard_Integer theHeight,
const unsigned int theResolution)
{
const Font_FontAspect anAspect = theAspect.Aspect()->TextFontAspect() != Font_FA_Undefined
? theAspect.Aspect()->TextFontAspect()
const Font_FontAspect anAspect = theAspect.Aspect()->GetTextFontAspect() != Font_FA_Undefined
? theAspect.Aspect()->GetTextFontAspect()
: Font_FA_Regular;
const TCollection_AsciiString& aFont = !theAspect.Aspect()->TextFont().IsNull() ? theAspect.Aspect()->TextFont()->String() : THE_DEFAULT_FONT;
return aFont
return theAspect.Aspect()->Font()
+ TCollection_AsciiString(":") + Standard_Integer(anAspect)
+ TCollection_AsciiString(":") + Standard_Integer(theResolution)
+ TCollection_AsciiString(":") + theHeight;
@@ -564,10 +565,10 @@ TCollection_AsciiString OpenGl_Text::FontKey (const OpenGl_Aspects& theAspect,
// purpose :
// =======================================================================
Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
const OpenGl_Aspects& theAspect,
Standard_Integer theHeight,
unsigned int theResolution,
const TCollection_AsciiString& theKey)
const OpenGl_AspectText& theAspect,
const Standard_Integer theHeight,
const unsigned int theResolution,
const TCollection_AsciiString theKey)
{
Handle(OpenGl_Font) aFont;
if (theHeight < 2)
@@ -578,11 +579,9 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
if (!theCtx->GetResource (theKey, aFont))
{
Handle(Font_FontMgr) aFontMgr = Font_FontMgr::GetInstance();
const TCollection_AsciiString& aFontName = !theAspect.Aspect()->TextFont().IsNull()
? theAspect.Aspect()->TextFont()->String()
: THE_DEFAULT_FONT;
Font_FontAspect anAspect = theAspect.Aspect()->TextFontAspect() != Font_FA_Undefined
? theAspect.Aspect()->TextFontAspect()
const TCollection_AsciiString& aFontName = theAspect.Aspect()->Font();
Font_FontAspect anAspect = theAspect.Aspect()->GetTextFontAspect() != Font_FA_Undefined
? theAspect.Aspect()->GetTextFontAspect()
: Font_FA_Regular;
Handle(Font_FTFont) aFontFt;
if (Handle(Font_SystemFont) aRequestedFont = aFontMgr->FindFont (aFontName, anAspect))
@@ -596,7 +595,7 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
{
TCollection_ExtendedString aMsg;
aMsg += "Font '";
aMsg += aFontName;
aMsg += theAspect.Aspect()->Font();
aMsg += "' - initialization of GL resources has failed!";
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg);
aFontFt.Nullify();
@@ -608,7 +607,7 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
{
TCollection_ExtendedString aMsg;
aMsg += "Font '";
aMsg += aFontName;
aMsg += theAspect.Aspect()->Font();
aMsg += "' is broken or has incompatible format! File path: ";
aMsg += aRequestedFont->FontPathAny (anAspect);
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg);
@@ -620,7 +619,7 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
{
TCollection_ExtendedString aMsg;
aMsg += "Font '";
aMsg += aFontName;
aMsg += theAspect.Aspect()->Font();
aMsg += "' is not found in the system!";
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg);
aFont = new OpenGl_Font (aFontFt, theKey);
@@ -636,8 +635,8 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
// purpose :
// =======================================================================
void OpenGl_Text::drawRect (const Handle(OpenGl_Context)& theCtx,
const OpenGl_Aspects& theTextAspect,
const OpenGl_Vec4& theColorSubs) const
const OpenGl_AspectText& theTextAspect,
const OpenGl_Vec4& theColorSubs) const
{
Handle(OpenGl_ShaderProgram) aPrevProgram = theCtx->ActiveProgram();
if (myBndVertsVbo.IsNull())
@@ -687,10 +686,10 @@ void OpenGl_Text::drawRect (const Handle(OpenGl_Context)& theCtx,
// purpose :
// =======================================================================
void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
const OpenGl_Aspects& theTextAspect,
const OpenGl_Vec4& theColorText,
const OpenGl_Vec4& theColorSubs,
unsigned int theResolution) const
const OpenGl_AspectText& theTextAspect,
const OpenGl_Vec4& theColorText,
const OpenGl_Vec4& theColorSubs,
const unsigned int theResolution) const
{
if (myString.IsEmpty())
{
@@ -760,7 +759,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
myWinX, myWinY, myWinZ);
// compute scale factor for constant text height
if (theTextAspect.Aspect()->IsTextZoomable())
if (theTextAspect.Aspect()->GetTextZoomable())
{
myExportHeight = aPointSize;
}
@@ -788,7 +787,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
// setup depth test
const bool hasDepthTest = !myIs2d
&& theTextAspect.Aspect()->TextStyle() != Aspect_TOST_ANNOTATION;
&& theTextAspect.Aspect()->Style() != Aspect_TOST_ANNOTATION;
if (!hasDepthTest)
{
glDisable (GL_DEPTH_TEST);
@@ -817,11 +816,8 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// alpha to coverage makes text too thin
theCtx->SetSampleAlphaToCoverage (false);
// extra drawings
switch (theTextAspect.Aspect()->TextDisplayType())
switch (theTextAspect.Aspect()->DisplayType())
{
case Aspect_TODT_BLEND:
{
@@ -884,7 +880,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
}
#endif
if (theTextAspect.Aspect()->TextDisplayType() == Aspect_TODT_DIMENSION)
if (theTextAspect.Aspect()->DisplayType() == Aspect_TODT_DIMENSION)
{
glDisable (GL_BLEND);
if (!myIs2d)

View File

@@ -18,7 +18,7 @@
#include <OpenGl_Element.hxx>
#include <OpenGl_Aspects.hxx>
#include <OpenGl_AspectText.hxx>
#include <OpenGl_TextParam.hxx>
#include <OpenGl_TextBuilder.hxx>
@@ -83,21 +83,21 @@ public: //! @name methods for compatibility with layers
Standard_EXPORT OpenGl_Text();
//! Create key for shared resource
Standard_EXPORT static TCollection_AsciiString FontKey (const OpenGl_Aspects& theAspect,
Standard_Integer theHeight,
unsigned int theResolution);
Standard_EXPORT static TCollection_AsciiString FontKey (const OpenGl_AspectText& theAspect,
const Standard_Integer theHeight,
const unsigned int theResolution);
//! Find shared resource for specified font or initialize new one
Standard_EXPORT static Handle(OpenGl_Font) FindFont (const Handle(OpenGl_Context)& theCtx,
const OpenGl_Aspects& theAspect,
Standard_Integer theHeight,
unsigned int theResolution,
const TCollection_AsciiString& theKey);
const OpenGl_AspectText& theAspect,
const Standard_Integer theHeight,
const unsigned int theResolution,
const TCollection_AsciiString theKey);
//! Compute text width
Standard_EXPORT static void StringSize (const Handle(OpenGl_Context)& theCtx,
const NCollection_String& theText,
const OpenGl_Aspects& theTextAspect,
const OpenGl_AspectText& theTextAspect,
const OpenGl_TextParam& theParams,
const unsigned int theResolution,
Standard_ShortReal& theWidth,
@@ -112,8 +112,8 @@ public: //! @name methods for compatibility with layers
//! Perform rendering
Standard_EXPORT void Render (const Handle(OpenGl_Context)& theCtx,
const OpenGl_Aspects& theTextAspect,
unsigned int theResolution = Graphic3d_RenderingParams::THE_DEFAULT_RESOLUTION) const;
const OpenGl_AspectText& theTextAspect,
const unsigned int theResolution = Graphic3d_RenderingParams::THE_DEFAULT_RESOLUTION) const;
protected:
@@ -127,24 +127,24 @@ private:
//! Setup matrix.
void setupMatrix (const Handle(OpenGl_Context)& theCtx,
const OpenGl_Aspects& theTextAspect,
const OpenGl_Vec3& theDVec) const;
const OpenGl_AspectText& theTextAspect,
const OpenGl_Vec3 theDVec) const;
//! Draw arrays of vertices.
void drawText (const Handle(OpenGl_Context)& theCtx,
const OpenGl_Aspects& theTextAspect) const;
const OpenGl_AspectText& theTextAspect) const;
//! Draw rectangle from bounding text box.
void drawRect (const Handle(OpenGl_Context)& theCtx,
const OpenGl_Aspects& theTextAspect,
const OpenGl_Vec4& theColorSubs) const;
const OpenGl_AspectText& theTextAspect,
const OpenGl_Vec4& theColorSubs) const;
//! Main rendering code
void render (const Handle(OpenGl_Context)& theCtx,
const OpenGl_Aspects& theTextAspect,
const OpenGl_Vec4& theColorText,
const OpenGl_Vec4& theColorSubs,
unsigned int theResolution) const;
const OpenGl_AspectText& theTextAspect,
const OpenGl_Vec4& theColorText,
const OpenGl_Vec4& theColorSubs,
const unsigned int theResolution) const;
protected:

View File

@@ -70,7 +70,7 @@ OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr,
myTransientDrawToFront (Standard_True),
myBackBufferRestored (Standard_False),
myIsImmediateDrawn (Standard_False),
myTextureParams (new OpenGl_Aspects()),
myTextureParams (new OpenGl_AspectFace()),
myBgGradientArray (new OpenGl_BackgroundArray (Graphic3d_TOB_GRADIENT)),
myBgTextureArray (new OpenGl_BackgroundArray (Graphic3d_TOB_TEXTURE)),
// ray-tracing fields initialization

View File

@@ -35,7 +35,7 @@
#include <Graphic3d_WorldViewProjState.hxx>
#include <Graphic3d_ZLayerSettings.hxx>
#include <OpenGl_Aspects.hxx>
#include <OpenGl_AspectFace.hxx>
#include <OpenGl_BackgroundArray.hxx>
#include <OpenGl_BVHTreeSelector.hxx>
#include <OpenGl_Context.hxx>
@@ -520,7 +520,7 @@ protected: //! @name Rendering properties
protected: //! @name Background parameters
OpenGl_Aspects* myTextureParams; //!< Stores texture and its parameters for textured background
OpenGl_AspectFace* myTextureParams; //!< Stores texture and its parameters for textured background
OpenGl_BackgroundArray* myBgGradientArray; //!< Primitive array for gradient background
OpenGl_BackgroundArray* myBgTextureArray; //!< Primitive array for texture background
@@ -773,7 +773,7 @@ protected: //! @name methods related to ray-tracing
const Handle(OpenGl_Context)& theGlContext);
//! Creates ray-tracing material properties.
OpenGl_RaytraceMaterial convertMaterial (const OpenGl_Aspects* theAspect,
OpenGl_RaytraceMaterial convertMaterial (const OpenGl_AspectFace* theAspect,
const Handle(OpenGl_Context)& theGlContext);
//! Adds OpenGL primitive array to ray-traced scene geometry.

View File

@@ -344,7 +344,7 @@ void buildTextureTransform (const Handle(Graphic3d_TextureParams)& theParams, BV
// function : convertMaterial
// purpose : Creates ray-tracing material properties
// =======================================================================
OpenGl_RaytraceMaterial OpenGl_View::convertMaterial (const OpenGl_Aspects* theAspect,
OpenGl_RaytraceMaterial OpenGl_View::convertMaterial (const OpenGl_AspectFace* theAspect,
const Handle(OpenGl_Context)& theGlContext)
{
OpenGl_RaytraceMaterial theMaterial;
@@ -509,20 +509,22 @@ Standard_Boolean OpenGl_View::addRaytraceGroups (const OpenGl_Structure*
{
// Get group material
OpenGl_RaytraceMaterial aGroupMaterial;
if (aGroupIter.Value()->GlAspects() != NULL)
if (aGroupIter.Value()->AspectFace() != NULL)
{
aGroupMaterial = convertMaterial (aGroupIter.Value()->GlAspects(), theGlContext);
aGroupMaterial = convertMaterial (
aGroupIter.Value()->AspectFace(), theGlContext);
}
Standard_Integer aMatID = static_cast<Standard_Integer> (myRaytraceGeometry.Materials.size());
// Use group material if available, otherwise use structure material
myRaytraceGeometry.Materials.push_back (aGroupIter.Value()->GlAspects() != NULL ? aGroupMaterial : theStructMat);
myRaytraceGeometry.Materials.push_back (
aGroupIter.Value()->AspectFace() != NULL ? aGroupMaterial : theStructMat);
// Add OpenGL elements from group (extract primitives arrays and aspects)
for (const OpenGl_ElementNode* aNode = aGroupIter.Value()->FirstNode(); aNode != NULL; aNode = aNode->next)
{
OpenGl_Aspects* anAspect = dynamic_cast<OpenGl_Aspects*> (aNode->elem);
OpenGl_AspectFace* anAspect = dynamic_cast<OpenGl_AspectFace*> (aNode->elem);
if (anAspect != NULL)
{

View File

@@ -27,6 +27,7 @@
#include <NCollection_Mat4.hxx>
#include <OpenGl_AspectLine.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_FrameStats.hxx>
#include <OpenGl_Matrix.hxx>
@@ -124,9 +125,9 @@ void OpenGl_View::drawBackground (const Handle(OpenGl_Workspace)& theWorkspace)
{
aCtx->core11fwd->glDisable (GL_BLEND);
const OpenGl_Aspects* anOldAspectFace = theWorkspace->SetAspects (myTextureParams);
const OpenGl_AspectFace* anOldAspectFace = theWorkspace->SetAspectFace (myTextureParams);
myBgTextureArray->Render (theWorkspace);
theWorkspace->SetAspects (anOldAspectFace);
theWorkspace->SetAspectFace (anOldAspectFace);
}
if (wasUsedZBuffer)
@@ -1445,7 +1446,6 @@ bool OpenGl_View::blitBuffers (OpenGl_FrameBuffer* theReadFbo,
if (aVerts->IsValid()
&& aManager->BindFboBlitProgram())
{
aCtx->SetSampleAlphaToCoverage (false);
theReadFbo->ColorTexture()->Bind (aCtx, Graphic3d_TextureUnit_0);
if (theReadFbo->ColorTexture()->Sampler()->Parameters()->Filter() != aFilter)
{

View File

@@ -16,7 +16,10 @@
#include <OpenGl_Workspace.hxx>
#include <OpenGl_ArbFBO.hxx>
#include <OpenGl_Aspects.hxx>
#include <OpenGl_AspectLine.hxx>
#include <OpenGl_AspectFace.hxx>
#include <OpenGl_AspectMarker.hxx>
#include <OpenGl_AspectText.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_Element.hxx>
#include <OpenGl_FrameBuffer.hxx>
@@ -120,7 +123,10 @@ OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Wi
myNbSkippedTranspElems (0),
myRenderFilter (OpenGl_RenderFilter_Empty),
//
myAspectsSet (&myDefaultAspects),
myAspectLineSet (&myDefaultAspectLine),
myAspectFaceSet (&myDefaultAspectFace),
myAspectMarkerSet (&myDefaultAspectMarker),
myAspectTextSet (&myDefaultAspectText),
//
ViewMatrix_applied (&myDefaultMatrix),
StructureMatrix_applied (&myDefaultMatrix),
@@ -149,6 +155,9 @@ OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Wi
#endif
}
myFontFaceAspect.Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Blend, 0.285f);
myFontFaceAspect.Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
myNoneCulling .Aspect()->SetSuppressBackFaces (false);
myNoneCulling .Aspect()->SetDrawEdges (false);
myNoneCulling .Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Opaque);
@@ -184,6 +193,14 @@ Standard_Boolean OpenGl_Workspace::Activate()
{
myGlContext->ShaderManager()->PushState (Handle(OpenGl_ShaderProgram)());
}
#if !defined(GL_ES_VERSION_2_0)
// font GLSL program has embedded discard, while FFP needs alpha test
myFontFaceAspect.Aspect()->SetAlphaMode ((!myGlContext->caps->ffpEnable && myGlContext->core11 != NULL)
? Graphic3d_AlphaMode_Blend
: Graphic3d_AlphaMode_Mask,
0.285f);
#endif
return Standard_True;
}
@@ -197,13 +214,21 @@ void OpenGl_Workspace::ResetAppliedAspect()
myHighlightStyle.Nullify();
myToAllowFaceCulling = false;
myAspectsSet = &myDefaultAspects;
myAspectsApplied.Nullify();
myAspectLineSet = &myDefaultAspectLine;
myAspectFaceSet = &myDefaultAspectFace;
myAspectFaceApplied.Nullify();
myAspectMarkerSet = &myDefaultAspectMarker;
myAspectMarkerApplied.Nullify();
myAspectTextSet = &myDefaultAspectText;
myGlContext->SetPolygonOffset (Graphic3d_PolygonOffset());
ApplyAspects();
myGlContext->SetTypeOfLine (myDefaultAspects.Aspect()->LineType());
myGlContext->SetLineWidth (myDefaultAspects.Aspect()->LineWidth());
ApplyAspectLine();
ApplyAspectFace();
ApplyAspectMarker();
ApplyAspectText();
myGlContext->SetTypeOfLine (myDefaultAspectLine.Aspect()->Type());
myGlContext->SetLineWidth (myDefaultAspectLine.Aspect()->Width());
}
// =======================================================================
@@ -212,11 +237,11 @@ void OpenGl_Workspace::ResetAppliedAspect()
// =======================================================================
Graphic3d_PolygonOffset OpenGl_Workspace::SetDefaultPolygonOffset (const Graphic3d_PolygonOffset& theOffset)
{
Graphic3d_PolygonOffset aPrev = myDefaultAspects.Aspect()->PolygonOffset();
myDefaultAspects.Aspect()->SetPolygonOffset (theOffset);
if (myAspectsApplied == myDefaultAspects.Aspect()
|| myAspectsApplied.IsNull()
|| (myAspectsApplied->PolygonOffset().Mode & Aspect_POM_None) == Aspect_POM_None)
Graphic3d_PolygonOffset aPrev = myDefaultAspectFace.Aspect()->PolygonOffset();
myDefaultAspectFace.Aspect()->SetPolygonOffset (theOffset);
if (myAspectFaceApplied == myDefaultAspectFace.Aspect()
|| myAspectFaceApplied.IsNull()
|| (myAspectFaceApplied->PolygonOffset().Mode & Aspect_POM_None) == Aspect_POM_None)
{
myGlContext->SetPolygonOffset (theOffset);
}
@@ -224,33 +249,66 @@ Graphic3d_PolygonOffset OpenGl_Workspace::SetDefaultPolygonOffset (const Graphic
}
// =======================================================================
// function : SetAspects
// function : SetAspectLine
// purpose :
// =======================================================================
const OpenGl_Aspects* OpenGl_Workspace::SetAspects (const OpenGl_Aspects* theAspect)
const OpenGl_AspectLine* OpenGl_Workspace::SetAspectLine (const OpenGl_AspectLine* theAspect)
{
const OpenGl_Aspects* aPrevAspects = myAspectsSet;
myAspectsSet = theAspect;
return aPrevAspects;
const OpenGl_AspectLine* aPrevAspectLine = myAspectLineSet;
myAspectLineSet = theAspect;
return aPrevAspectLine;
}
// =======================================================================
// function : ApplyAspects
// function : SetAspectFace
// purpose :
// =======================================================================
const OpenGl_Aspects* OpenGl_Workspace::ApplyAspects()
const OpenGl_AspectFace * OpenGl_Workspace::SetAspectFace (const OpenGl_AspectFace* theAspect)
{
const OpenGl_AspectFace* aPrevAspectFace = myAspectFaceSet;
myAspectFaceSet = theAspect;
return aPrevAspectFace;
}
// =======================================================================
// function : SetAspectMarker
// purpose :
// =======================================================================
const OpenGl_AspectMarker* OpenGl_Workspace::SetAspectMarker (const OpenGl_AspectMarker* theAspect)
{
const OpenGl_AspectMarker* aPrevAspectMarker = myAspectMarkerSet;
myAspectMarkerSet = theAspect;
return aPrevAspectMarker;
}
// =======================================================================
// function : SetAspectText
// purpose :
// =======================================================================
const OpenGl_AspectText * OpenGl_Workspace::SetAspectText (const OpenGl_AspectText* theAspect)
{
const OpenGl_AspectText* aPrevAspectText = myAspectTextSet;
myAspectTextSet = theAspect;
return aPrevAspectText;
}
// =======================================================================
// function : ApplyAspectFace
// purpose :
// =======================================================================
const OpenGl_AspectFace* OpenGl_Workspace::ApplyAspectFace()
{
if (myView->BackfacingModel() == Graphic3d_TOBM_AUTOMATIC)
{
bool toSuppressBackFaces = myToAllowFaceCulling
&& myAspectsSet->Aspect()->ToSuppressBackFaces();
&& myAspectFaceSet->Aspect()->ToSuppressBackFaces();
if (toSuppressBackFaces)
{
if (myAspectsSet->Aspect()->InteriorStyle() == Aspect_IS_HATCH
|| myAspectsSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_Blend
|| myAspectsSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_Mask
|| (myAspectsSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_BlendAuto
&& myAspectsSet->Aspect()->FrontMaterial().Transparency() != 0.0f))
if (myAspectFaceSet->Aspect()->InteriorStyle() == Aspect_IS_HATCH
|| myAspectFaceSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_Blend
|| myAspectFaceSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_Mask
|| (myAspectFaceSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_BlendAuto
&& myAspectFaceSet->Aspect()->FrontMaterial().Transparency() != 0.0f))
{
// disable culling in case of translucent shading aspect
toSuppressBackFaces = false;
@@ -259,22 +317,22 @@ const OpenGl_Aspects* OpenGl_Workspace::ApplyAspects()
myGlContext->SetCullBackFaces (toSuppressBackFaces);
}
if (myAspectsSet->Aspect() == myAspectsApplied
if (myAspectFaceSet->Aspect() == myAspectFaceApplied
&& myHighlightStyle == myAspectFaceAppliedWithHL)
{
return myAspectsSet;
return myAspectFaceSet;
}
myAspectFaceAppliedWithHL = myHighlightStyle;
// Aspect_POM_None means: do not change current settings
if ((myAspectsSet->Aspect()->PolygonOffset().Mode & Aspect_POM_None) != Aspect_POM_None)
if ((myAspectFaceSet->Aspect()->PolygonOffset().Mode & Aspect_POM_None) != Aspect_POM_None)
{
myGlContext->SetPolygonOffset (myAspectsSet->Aspect()->PolygonOffset());
myGlContext->SetPolygonOffset (myAspectFaceSet->Aspect()->PolygonOffset());
}
const Aspect_InteriorStyle anIntstyle = myAspectsSet->Aspect()->InteriorStyle();
if (myAspectsApplied.IsNull()
|| myAspectsApplied->InteriorStyle() != anIntstyle)
const Aspect_InteriorStyle anIntstyle = myAspectFaceSet->Aspect()->InteriorStyle();
if (myAspectFaceApplied.IsNull()
|| myAspectFaceApplied->InteriorStyle() != anIntstyle)
{
#if !defined(GL_ES_VERSION_2_0)
myGlContext->SetPolygonMode (anIntstyle == Aspect_IS_POINT ? GL_POINT : GL_FILL);
@@ -285,7 +343,7 @@ const OpenGl_Aspects* OpenGl_Workspace::ApplyAspects()
#if !defined(GL_ES_VERSION_2_0)
if (anIntstyle == Aspect_IS_HATCH)
{
myGlContext->SetPolygonHatchStyle (myAspectsSet->Aspect()->HatchStyle());
myGlContext->SetPolygonHatchStyle (myAspectFaceSet->Aspect()->HatchStyle());
}
#endif
@@ -293,29 +351,50 @@ const OpenGl_Aspects* OpenGl_Workspace::ApplyAspects()
if (anIntstyle == Aspect_IS_HIDDENLINE)
{
// copy all values including line edge aspect
*myAspectFaceHl.Aspect() = *myAspectsSet->Aspect();
*myAspectFaceHl.Aspect() = *myAspectFaceSet->Aspect();
myAspectFaceHl.SetAspectEdge (myAspectFaceSet->AspectEdge());
myAspectFaceHl.Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
myAspectFaceHl.Aspect()->SetInteriorColor (myView->BackgroundColor().GetRGB());
myAspectFaceHl.Aspect()->SetDistinguish (false);
myAspectFaceHl.SetNoLighting();
myAspectsSet = &myAspectFaceHl;
myAspectFaceSet = &myAspectFaceHl;
}
else
{
myGlContext->SetShadingMaterial (myAspectsSet, myHighlightStyle);
myGlContext->SetShadingMaterial (myAspectFaceSet, myHighlightStyle);
}
if (myAspectsSet->Aspect()->ToMapTexture())
if (myAspectFaceSet->Aspect()->ToMapTexture())
{
myGlContext->BindTextures (myAspectsSet->TextureSet (myGlContext));
myGlContext->BindTextures (myAspectFaceSet->TextureSet (myGlContext));
}
else
{
myGlContext->BindTextures (myEnvironmentTexture);
}
myAspectsApplied = myAspectsSet->Aspect();
return myAspectsSet;
myAspectFaceApplied = myAspectFaceSet->Aspect();
return myAspectFaceSet;
}
// =======================================================================
// function : ApplyAspectMarker
// purpose :
// =======================================================================
const OpenGl_AspectMarker* OpenGl_Workspace::ApplyAspectMarker()
{
if (myAspectMarkerSet->Aspect() != myAspectMarkerApplied)
{
if (myAspectMarkerApplied.IsNull()
|| (myAspectMarkerSet->Aspect()->Scale() != myAspectMarkerApplied->Scale()))
{
#if !defined(GL_ES_VERSION_2_0)
glPointSize (myAspectMarkerSet->Aspect()->Scale());
#endif
}
myAspectMarkerApplied = myAspectMarkerSet->Aspect();
}
return myAspectMarkerSet;
}
// =======================================================================
@@ -419,7 +498,7 @@ bool OpenGl_Workspace::ShouldRender (const OpenGl_Element* theElement)
return true;
}
if (OpenGl_Context::CheckIsTransparent (myAspectsSet, myHighlightStyle))
if (OpenGl_Context::CheckIsTransparent (myAspectFaceSet, myHighlightStyle))
{
++myNbSkippedTranspElems;
return false;
@@ -429,12 +508,12 @@ bool OpenGl_Workspace::ShouldRender (const OpenGl_Element* theElement)
{
if (!theElement->IsFillDrawMode())
{
if (dynamic_cast<const OpenGl_Aspects*> (theElement) == NULL)
if (dynamic_cast<const OpenGl_AspectFace*> (theElement) == NULL)
{
return false;
}
}
else if (!OpenGl_Context::CheckIsTransparent (myAspectsSet, myHighlightStyle))
else if (!OpenGl_Context::CheckIsTransparent (myAspectFaceSet, myHighlightStyle))
{
return false;
}

View File

@@ -18,7 +18,7 @@
#include <Graphic3d_BufferType.hxx>
#include <OpenGl_Aspects.hxx>
#include <OpenGl_AspectFace.hxx>
#include <OpenGl_CappingAlgo.hxx>
#include <OpenGl_FrameBuffer.hxx>
#include <OpenGl_Material.hxx>
@@ -111,12 +111,28 @@ public:
//! Set highlight style.
void SetHighlightStyle (const Handle(Graphic3d_PresentationAttributes)& theStyle) { myHighlightStyle = theStyle; }
//! Return line color taking into account highlight flag.
const OpenGl_Vec4& LineColor() const
{
return !myHighlightStyle.IsNull()
? myHighlightStyle->ColorRGBA()
: myAspectLineSet->Aspect()->ColorRGBA();
}
//! Return edge color taking into account highlight flag.
const OpenGl_Vec4& EdgeColor() const
{
return !myHighlightStyle.IsNull()
? myHighlightStyle->ColorRGBA()
: myAspectsSet->Aspect()->EdgeColorRGBA();
: myAspectFaceSet->AspectEdge()->Aspect()->ColorRGBA();
}
//! Return marker color taking into account highlight flag.
const OpenGl_Vec4& MarkerColor() const
{
return !myHighlightStyle.IsNull()
? myHighlightStyle->ColorRGBA()
: myAspectMarkerSet->Aspect()->ColorRGBA();
}
//! Return Interior color taking into account highlight flag.
@@ -124,7 +140,7 @@ public:
{
return !myHighlightStyle.IsNull()
? myHighlightStyle->ColorRGBA()
: myAspectsSet->Aspect()->InteriorColorRGBA();
: myAspectFaceSet->Aspect()->InteriorColorRGBA();
}
//! Return text color taking into account highlight flag.
@@ -132,7 +148,7 @@ public:
{
return !myHighlightStyle.IsNull()
? myHighlightStyle->ColorRGBA()
: myAspectsSet->Aspect()->ColorRGBA();
: myAspectTextSet->Aspect()->ColorRGBA();
}
//! Return text Subtitle color taking into account highlight flag.
@@ -140,18 +156,48 @@ public:
{
return !myHighlightStyle.IsNull()
? myHighlightStyle->ColorRGBA()
: myAspectsSet->Aspect()->ColorSubTitleRGBA();
: myAspectTextSet->Aspect()->ColorSubTitleRGBA();
}
//! Currently set aspects (can differ from applied).
const OpenGl_Aspects* Aspects() const { return myAspectsSet; }
//! Currently set line aspect (can differ from applied).
const OpenGl_AspectLine* AspectLine() const { return myAspectLineSet; }
//! Assign new aspects (will be applied within ApplyAspects()).
Standard_EXPORT const OpenGl_Aspects* SetAspects (const OpenGl_Aspects* theAspect);
//! Currently set face aspect (can differ from applied).
const OpenGl_AspectFace* AspectFace() const { return myAspectFaceSet; }
//! Apply aspects.
//! @return aspect set by SetAspects()
Standard_EXPORT const OpenGl_Aspects* ApplyAspects();
//! Currently set marker aspect (can differ from applied).
const OpenGl_AspectMarker* AspectMarker() const { return myAspectMarkerSet; }
//! Currently set text aspect (can differ from applied).
const OpenGl_AspectText* AspectText() const { return myAspectTextSet; }
//! Assign new line aspect (will be applied within ApplyAspectLine()).
Standard_EXPORT const OpenGl_AspectLine* SetAspectLine (const OpenGl_AspectLine* theAspect);
//! Assign new face aspect (will be applied within ApplyAspectFace()).
Standard_EXPORT const OpenGl_AspectFace* SetAspectFace (const OpenGl_AspectFace* theAspect);
//! Assign new marker aspect (will be applied within ApplyAspectMarker()).
Standard_EXPORT const OpenGl_AspectMarker* SetAspectMarker (const OpenGl_AspectMarker* theAspect);
//! Assign new text aspect (will be applied within ApplyAspectText()).
Standard_EXPORT const OpenGl_AspectText* SetAspectText (const OpenGl_AspectText* theAspect);
//! Apply line aspect.
//! @return aspect set by SetAspectLine()
const OpenGl_AspectLine* ApplyAspectLine() { return myAspectLineSet; }
//! Apply face aspect.
//! @return aspect set by SetAspectFace()
Standard_EXPORT const OpenGl_AspectFace* ApplyAspectFace();
//! Apply marker aspect.
//! @return aspect set by SetAspectMarker()
Standard_EXPORT const OpenGl_AspectMarker* ApplyAspectMarker();
//! Apply text aspect.
//! @return aspect set by SetAspectText()
const OpenGl_AspectText* ApplyAspectText() { return myAspectTextSet; }
//! Clear the applied aspect state to default values.
void ResetAppliedAspect();
@@ -183,11 +229,14 @@ public:
//! @return applied model structure matrix.
inline const OpenGl_Matrix* ModelMatrix() const { return StructureMatrix_applied; }
//! Returns face aspect for textured font rendering.
const OpenGl_AspectFace& FontFaceAspect() const { return myFontFaceAspect; }
//! Returns face aspect for none culling mode.
const OpenGl_Aspects& NoneCulling() const { return myNoneCulling; }
const OpenGl_AspectFace& NoneCulling() const { return myNoneCulling; }
//! Returns face aspect for front face culling mode.
const OpenGl_Aspects& FrontCulling() const { return myFrontCulling; }
const OpenGl_AspectFace& FrontCulling() const { return myFrontCulling; }
//! Sets a new environment texture.
void SetEnvironmentTexture (const Handle(OpenGl_TextureSet)& theTexture) { myEnvironmentTexture = theTexture; }
@@ -197,23 +246,31 @@ public:
protected: //! @name protected fields
OpenGl_View* myView;
Handle(OpenGl_Window) myWindow;
Handle(OpenGl_Context) myGlContext;
Standard_Boolean myUseZBuffer;
Standard_Boolean myUseDepthWrite;
OpenGl_Aspects myNoneCulling;
OpenGl_Aspects myFrontCulling;
OpenGl_View* myView;
Handle(OpenGl_Window) myWindow;
Handle(OpenGl_Context) myGlContext;
Standard_Boolean myUseZBuffer;
Standard_Boolean myUseDepthWrite;
OpenGl_AspectFace myNoneCulling;
OpenGl_AspectFace myFrontCulling;
OpenGl_AspectFace myFontFaceAspect;
protected: //! @name fields related to status
Standard_Integer myNbSkippedTranspElems; //!< counter of skipped transparent elements for OpenGl_LayerList two rendering passes method
Standard_Integer myRenderFilter; //!< active filter for skipping rendering of elements by some criteria (multiple render passes)
OpenGl_Aspects myDefaultAspects;
const OpenGl_Aspects* myAspectsSet;
Handle(Graphic3d_Aspects) myAspectsApplied;
OpenGl_AspectLine myDefaultAspectLine;
OpenGl_AspectFace myDefaultAspectFace;
OpenGl_AspectMarker myDefaultAspectMarker;
OpenGl_AspectText myDefaultAspectText;
const OpenGl_AspectLine* myAspectLineSet;
const OpenGl_AspectFace* myAspectFaceSet;
Handle(Graphic3d_AspectFillArea3d) myAspectFaceApplied;
const OpenGl_AspectMarker* myAspectMarkerSet;
Handle(Graphic3d_AspectMarker3d) myAspectMarkerApplied;
const OpenGl_AspectText* myAspectTextSet;
Handle(Graphic3d_PresentationAttributes) myAspectFaceAppliedWithHL;
const OpenGl_Matrix* ViewMatrix_applied;
@@ -224,7 +281,7 @@ protected: //! @name fields related to status
OpenGl_Matrix myModelViewMatrix; //!< Model matrix with applied structure transformations
OpenGl_Aspects myAspectFaceHl; //!< Hiddenline aspect
OpenGl_AspectFace myAspectFaceHl; //!< Hiddenline aspect
Handle(OpenGl_TextureSet) myEnvironmentTexture;

View File

@@ -53,8 +53,6 @@ Prs3d_ToolCylinder.hxx
Prs3d_ToolCylinder.cxx
Prs3d_ToolQuadric.hxx
Prs3d_ToolQuadric.cxx
Prs3d_ToolSector.hxx
Prs3d_ToolSector.cxx
Prs3d_ToolSphere.hxx
Prs3d_ToolSphere.cxx
Prs3d_TypeOfHighlight.hxx

View File

@@ -26,6 +26,7 @@ IMPLEMENT_STANDARD_RTTIEXT(Prs3d_TextAspect, Prs3d_BasicAspect)
// =======================================================================
Prs3d_TextAspect::Prs3d_TextAspect()
: myTextAspect (new Graphic3d_AspectText3d (Quantity_Color (Quantity_NOC_YELLOW), Font_NOF_ASCII_TRIPLEX, 1.0, 0.0)),
myAngle (0.0),
myHeight(16.0),
myHorizontalJustification (Graphic3d_HTA_LEFT),
myVerticalJustification (Graphic3d_VTA_BOTTOM),
@@ -40,6 +41,7 @@ Prs3d_TextAspect::Prs3d_TextAspect()
// =======================================================================
Prs3d_TextAspect::Prs3d_TextAspect (const Handle(Graphic3d_AspectText3d)& theAspect)
: myTextAspect (theAspect),
myAngle (0.0),
myHeight(16.0),
myHorizontalJustification (Graphic3d_HTA_LEFT),
myVerticalJustification (Graphic3d_VTA_BOTTOM),

View File

@@ -39,18 +39,24 @@ public:
//! Sets the font used in text display.
void SetFont (const Standard_CString theFont) { myTextAspect->SetFont (theFont); }
//! Returns the height-width ratio, also known as the expansion factor.
void SetHeightWidthRatio (const Standard_Real theRatio) { myTextAspect->SetExpansionFactor (theRatio); }
//! Sets the length of the box which text will occupy.
void SetSpace (const Standard_Real theSpace) { myTextAspect->SetSpace (theSpace); }
//! Sets the height of the text.
void SetHeight (const Standard_Real theHeight) { myHeight = theHeight; }
//! Sets the angle
void SetAngle (const Standard_Real theAngle) { myTextAspect->SetTextAngle (theAngle); }
void SetAngle (const Standard_Real theAngle) { myAngle = theAngle; }
//! Returns the height of the text box.
Standard_Real Height() const { return myHeight; }
//! Returns the angle
Standard_Real Angle() const { return myTextAspect->GetTextAngle(); }
Standard_Real Angle() const { return myAngle; }
//! Sets horizontal alignment of text.
void SetHorizontalJustification (const Graphic3d_HorizontalTextAlignment theJustification) { myHorizontalJustification = theJustification; }
@@ -100,6 +106,7 @@ public:
protected:
Handle(Graphic3d_AspectText3d) myTextAspect;
Standard_Real myAngle;
Standard_Real myHeight;
Graphic3d_HorizontalTextAlignment myHorizontalJustification;
Graphic3d_VerticalTextAlignment myVerticalJustification;

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