Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
96243ce93e |
@@ -7,8 +7,7 @@ if (NOT DEFINED ${3RDPARTY_QT_DIR} AND ${3RDPARTY_QT_DIR} STREQUAL "")
|
||||
FIND_PRODUCT_DIR ("${3RDPARTY_DIR}" Qt 3RDPARTY_QT_DIR_NAME)
|
||||
|
||||
if (NOT DEFINED ${3RDPARTY_QT_DIR_NAME} AND ${3RDPARTY_QT_DIR_NAME} STREQUAL "")
|
||||
set (3RDPARTY_QT_DIR "" CACHE PATH "The directory containing qt")
|
||||
message (FATAL_ERROR "Could not find used third-party product: 3RDPARTY_QT_DIR")
|
||||
message (FATAL_ERROR "... Qt root directory was not found")
|
||||
endif()
|
||||
|
||||
# Combine directory name with absolute path and show in GUI
|
||||
@@ -32,10 +31,4 @@ if (NOT ${Qt5_FOUND})
|
||||
#message (STATUS "Qt4 cmake configuration")
|
||||
else()
|
||||
#message (STATUS "Qt5 cmake configuration")
|
||||
endif()
|
||||
|
||||
if (3RDPARTY_QT_DIR OR EXISTS "${3RDPARTY_QT_DIR}")
|
||||
list (APPEND 3RDPARTY_DLL_DIRS "${3RDPARTY_QT_DIR}/bin")
|
||||
else()
|
||||
list (APPEND 3RDPARTY_NO_DLLS 3RDPARTY_QT_DLL_DIR)
|
||||
endif()
|
||||
endif()
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 11 KiB |
BIN
data/images/hatch_1_.png
Normal file
After Width: | Height: | Size: 670 B |
BIN
data/images/hatch_2.png
Normal file
After Width: | Height: | Size: 679 B |
BIN
data/images/hatch_3.png
Normal file
After Width: | Height: | Size: 761 B |
BIN
data/images/hatch_4.png
Normal file
After Width: | Height: | Size: 674 B |
BIN
data/images/hatch_5.png
Normal file
After Width: | Height: | Size: 887 B |
BIN
data/images/hatch_6.png
Normal file
After Width: | Height: | Size: 933 B |
BIN
data/images/hatch_7.png
Normal file
After Width: | Height: | Size: 633 B |
BIN
data/images/hatch_8.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
@@ -52,14 +52,6 @@ namespace
|
||||
return aDevicePixelRatio;
|
||||
});
|
||||
|
||||
/*EM_JS(void, jsSetOcctCamera, (float theFOV, float theAspect, float theNear, float theFar), {
|
||||
setOcctCamera();
|
||||
});*/
|
||||
|
||||
EM_JS(void, jsPostFrameRender, (), {
|
||||
postFrameRender();
|
||||
});
|
||||
|
||||
//! Return cavas size in pixels.
|
||||
static Graphic3d_Vec2i jsCanvasSize()
|
||||
{
|
||||
@@ -344,13 +336,7 @@ void WasmOcctView::handleViewRedraw (const Handle(AIS_InteractiveContext)& theCt
|
||||
const Handle(V3d_View)& theView)
|
||||
{
|
||||
myUpdateRequests = 0;
|
||||
|
||||
theView->Invalidate(); /// Three.js cannot be rendered properly without full redraw
|
||||
glEnable (GL_POLYGON_OFFSET_FILL); /// reset defaults Graphic3d_PolygonOffset after Three.js
|
||||
glPolygonOffset (1.0f, 1.0f);
|
||||
|
||||
AIS_ViewController::handleViewRedraw (theCtx, theView);
|
||||
jsPostFrameRender();
|
||||
if (myToAskNextFrame)
|
||||
{
|
||||
// ask more frames
|
||||
|
@@ -4,7 +4,6 @@
|
||||
|
||||
#include <Message.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <Message_PrinterSystemLog.hxx>
|
||||
#include <OSD_MemInfo.hxx>
|
||||
#include <OSD_Parallel.hxx>
|
||||
|
||||
@@ -57,8 +56,6 @@ static void onFileReadFailed (void* theOpaque)
|
||||
int main()
|
||||
{
|
||||
Message::DefaultMessenger()->Printers().First()->SetTraceLevel (Message_Trace);
|
||||
Handle(Message_PrinterSystemLog) aJSConsolePrinter = new Message_PrinterSystemLog ("webgl-sample", Message_Trace);
|
||||
Message::DefaultMessenger()->AddPrinter (aJSConsolePrinter); // open JavaScript console within the Browser to see this output
|
||||
Message::DefaultMessenger()->Send (TCollection_AsciiString("NbLogicalProcessors: ") + OSD_Parallel::NbLogicalProcessors(), Message_Trace);
|
||||
aViewer.run();
|
||||
Message::DefaultMessenger()->Send (OSD_MemInfo::PrintInfo(), Message_Trace);
|
||||
|
@@ -16,7 +16,6 @@
|
||||
<div><label for="fileInput">Choose BREP file to upload: </label><input type="file" id="fileInput" accept=".brep"></div>
|
||||
<h4>Console output:</h4>
|
||||
<p id="output"></p>
|
||||
<script src="three.min.js"></script>
|
||||
<script>
|
||||
//! Resize canvas to fit into window.
|
||||
function updateCanvasSize()
|
||||
@@ -58,7 +57,6 @@ if (!isWasmSupported())
|
||||
{
|
||||
var anElement = document.getElementById('output');
|
||||
anElement.innerHTML += "Browser is too old - WebAssembly support is missing!<br>Please check updates or install a modern browser.<br>";
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
//! Define OCCT WebGL Viewer module.
|
||||
@@ -78,44 +76,6 @@ var Module =
|
||||
})()
|
||||
};
|
||||
|
||||
var aCanvas = document.getElementById ('canvas');
|
||||
var aGlCtx = aCanvas.getContext ('webgl2', { alpha: false, depth: true, antialias: false, preserveDrawingBuffer: true } );
|
||||
if (aGlCtx == null)
|
||||
{
|
||||
aGlCtx = aCanvas.getContext ('webgl', { alpha: false, depth: true, antialias: false, preserveDrawingBuffer: true } );
|
||||
}
|
||||
var aScene = new THREE.Scene();
|
||||
var aCamera = new THREE.PerspectiveCamera (75, window.innerWidth / window.innerHeight);
|
||||
//var aRenderer = new THREE.WebGLRenderer ({antialias: true});
|
||||
var aRenderer = new THREE.WebGLRenderer ({antialias: false, canvas: aCanvas, context: aGlCtx});
|
||||
aRenderer.autoClear = false;
|
||||
aRenderer.autoClearColor = false;
|
||||
aRenderer.autoClearDepth = false;
|
||||
aRenderer.autoClearStencil = false;
|
||||
aRenderer.setSize (window.innerWidth,window.innerHeight);
|
||||
//document.body.appendChild (aRenderer.domElement);
|
||||
var aGeom = new THREE.BoxGeometry (1,1,1);
|
||||
var aMat = new THREE.MeshBasicMaterial ({color: 0xff0000});
|
||||
var aCube = new THREE.Mesh (aGeom, aMat);
|
||||
aScene.add (aCube);
|
||||
aCube.position.z = -5; aCube.rotation.x = 10; aCube.rotation.y = 5;
|
||||
/*aRenderer.render (aScene, aCamera);
|
||||
var anAnimate = function(){
|
||||
aCube.rotation.x += 0.01;
|
||||
aRenderer.state.reset();
|
||||
aRenderer.render (aScene, aCamera);
|
||||
requestAnimationFrame (anAnimate);
|
||||
}
|
||||
anAnimate();*/
|
||||
|
||||
function postFrameRender()
|
||||
{
|
||||
//console.log("postFrameRender()"); ///
|
||||
//aCamera.
|
||||
aRenderer.state.reset();
|
||||
aRenderer.render (aScene, aCamera)
|
||||
}
|
||||
|
||||
//! Handle file uploading.
|
||||
fileInput.onchange = function()
|
||||
{
|
||||
|
@@ -637,6 +637,11 @@ void AIS_ColoredShape::addShapesWithCustomProps (const Handle(Prs3d_Presentation
|
||||
{
|
||||
aShadedGroup = thePrs->NewGroup();
|
||||
aShadedGroup->SetClosed (isClosed);
|
||||
if (isClosed)
|
||||
{
|
||||
if (aDrawer->HasOwnFillCappingAspect())
|
||||
aShadedGroup->SetGroupPrimitivesAspect (aDrawer->FillCappingAspect());
|
||||
}
|
||||
}
|
||||
aShadedGroup->SetPrimitivesAspect (aDrawer->ShadingAspect()->Aspect());
|
||||
aShadedGroup->AddPrimitiveArray (aTriangles);
|
||||
|
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <Graphic3d_AspectFillArea3d.hxx>
|
||||
#include <Graphic3d_AspectFillCapping.hxx>
|
||||
#include <Graphic3d_AspectLine3d.hxx>
|
||||
#include <Graphic3d_AspectMarker3d.hxx>
|
||||
#include <Graphic3d_AspectText3d.hxx>
|
||||
|
@@ -180,10 +180,7 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
StdPrs_ShadedShape::Add (aPrs, myshape, myDrawer,
|
||||
myDrawer->ShadingAspect()->Aspect()->ToMapTexture()
|
||||
&& !myDrawer->ShadingAspect()->Aspect()->TextureMap().IsNull(),
|
||||
myUVOrigin, myUVRepeat, myUVScale);
|
||||
StdPrs_ShadedShape::Add (aPrs, myshape, myDrawer, myDrawer->FillCappingAspect());
|
||||
}
|
||||
catch (Standard_Failure const& anException)
|
||||
{
|
||||
|
@@ -15,6 +15,8 @@ Graphic3d_Aspects.cxx
|
||||
Graphic3d_Aspects.hxx
|
||||
Graphic3d_AspectFillArea3d.cxx
|
||||
Graphic3d_AspectFillArea3d.hxx
|
||||
Graphic3d_AspectFillCapping.cxx
|
||||
Graphic3d_AspectFillCapping.hxx
|
||||
Graphic3d_AspectLine3d.cxx
|
||||
Graphic3d_AspectLine3d.hxx
|
||||
Graphic3d_AspectMarker3d.cxx
|
||||
|
110
src/Graphic3d/Graphic3d_AspectFillCapping.cxx
Normal file
@@ -0,0 +1,110 @@
|
||||
// Created on: 2017-04-14
|
||||
// Created by: Anton POLETAEV
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <Graphic3d_AspectFillCapping.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectFillCapping, Standard_Transient)
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_AspectFillCapping
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_AspectFillCapping::Graphic3d_AspectFillCapping()
|
||||
: myFlags (Flags_None),
|
||||
myHatchingState (0)
|
||||
{
|
||||
Graphic3d_MaterialAspect aMaterial;
|
||||
aMaterial.SetColor (Quantity_NOC_BLACK);
|
||||
aMaterial.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
|
||||
aMaterial.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
|
||||
aMaterial.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
|
||||
aMaterial.SetReflectionModeOff (Graphic3d_TOR_EMISSION);
|
||||
aMaterial.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
|
||||
SetHatchStyle (Aspect_HS_HORIZONTAL);
|
||||
SetHatchMaterial (aMaterial);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetHatchStyle
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_AspectFillCapping::SetHatchStyle (const Aspect_HatchStyle theStyle)
|
||||
{
|
||||
myStippleHatch = new Graphic3d_HatchStyle (theStyle);
|
||||
myTextureHatch.Nullify();
|
||||
myHatchingState++;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetHatchStyle
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_AspectFillCapping::SetHatchStyle (const Handle(Graphic3d_HatchStyle)& theStyle)
|
||||
{
|
||||
myStippleHatch = theStyle;
|
||||
myTextureHatch.Nullify();
|
||||
myHatchingState++;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetHatchStyle
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_AspectFillCapping::SetHatchStyle (const Handle(Graphic3d_TextureMap)& theTexture)
|
||||
{
|
||||
myStippleHatch.Nullify();
|
||||
myTextureHatch = theTexture;
|
||||
myHatchingState++;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetHatchMaterial
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_AspectFillCapping::SetHatchMaterial (const Graphic3d_MaterialAspect& theMaterial)
|
||||
{
|
||||
myHatchMaterial = theMaterial;
|
||||
myHatchingState++;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetToDrawHatch
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_AspectFillCapping::SetToDrawHatch (const Standard_Boolean theToDraw)
|
||||
{
|
||||
setFlag (theToDraw, Flags_DrawHatching);
|
||||
myHatchingState++;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetHatchZoomPeristent
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_AspectFillCapping::SetHatchZoomPeristent (const Standard_Boolean theToSet)
|
||||
{
|
||||
setFlag (theToSet, Flags_HatchZoomPersistent);
|
||||
myHatchingState++;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetHatchRotationPeristent
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_AspectFillCapping::SetHatchRotationPeristent (const Standard_Boolean theToSet)
|
||||
{
|
||||
setFlag (theToSet, Flags_HatchRotationPersistent);
|
||||
myHatchingState++;
|
||||
}
|
164
src/Graphic3d/Graphic3d_AspectFillCapping.hxx
Normal file
@@ -0,0 +1,164 @@
|
||||
// Created on: 2017-04-14
|
||||
// Created by: Anton POLETAEV
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Graphic3d_AspectFillCapping_HeaderFile
|
||||
#define _Graphic3d_AspectFillCapping_HeaderFile
|
||||
|
||||
#include <Aspect_HatchStyle.hxx>
|
||||
#include <Graphic3d_Aspects.hxx>
|
||||
#include <Graphic3d_HatchStyle.hxx>
|
||||
#include <Graphic3d_MaterialAspect.hxx>
|
||||
#include <Graphic3d_ShaderProgram.hxx>
|
||||
#include <Graphic3d_TextureMap.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
|
||||
//! Defines graphical attributes for drawing section planes on solids resulted from clipping (cutting) planes.
|
||||
class Graphic3d_AspectFillCapping : public Graphic3d_Aspects
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor.
|
||||
Standard_EXPORT Graphic3d_AspectFillCapping();
|
||||
|
||||
public:
|
||||
|
||||
//! Sets material for filling section created by clipping.
|
||||
void SetMaterial (const Graphic3d_MaterialAspect& theMaterial) { myMaterial = theMaterial; }
|
||||
|
||||
//! Returns material for filling section created by clipping.
|
||||
const Graphic3d_MaterialAspect& Material() const { return myMaterial; }
|
||||
|
||||
//! Sets flag indicating whether object's material (instead of defined by this aspect) should be used for filling section.
|
||||
void SetUseObjectMaterial (const Standard_Boolean theToUse) { setFlag (theToUse, Flags_UseObjectMaterial); }
|
||||
|
||||
//! Returns flag indicating whether object's material (instead of defined by this aspect) should be used for filling section.
|
||||
Standard_Boolean ToUseObjectMaterial() const { return (myFlags & Flags_UseObjectMaterial) != 0; }
|
||||
|
||||
//! Sets texture for filling section created by clipping.
|
||||
void SetTexture (const Handle(Graphic3d_TextureMap)& theTexture) { myTexture = theTexture; }
|
||||
|
||||
//! Returns texture for filling section created by clipping.
|
||||
const Handle(Graphic3d_TextureMap)& Texture() const { return myTexture; }
|
||||
|
||||
//! Sets flag indicating whether object's texture (instead of defined by this aspect) should be used for filling section.
|
||||
void SetUseObjectTexture (const Standard_Boolean theToUse) { setFlag (theToUse, Flags_UseObjectTexture); }
|
||||
|
||||
//! Returns flag indicating whether object's texture (instead of defined by this aspect) should be used for filling section.
|
||||
Standard_Boolean ToUseObjectTexture() const { return (myFlags & Flags_UseObjectTexture) != 0; }
|
||||
|
||||
//! Sets OpenGL/GLSL shader program.
|
||||
void SetShader (const Handle(Graphic3d_ShaderProgram)& theShader) { myShader = theShader; }
|
||||
|
||||
//! Returns OpenGL/GLSL shader program.
|
||||
const Handle(Graphic3d_ShaderProgram)& Shader() const { return myShader; }
|
||||
|
||||
//! Sets flag indicating whether object's shader (instead of defined by this aspect) should be used for filling section.
|
||||
void SetUseObjectShader (const Standard_Boolean theToUse) { setFlag (theToUse, Flags_UseObjectShader); }
|
||||
|
||||
//! Returns flag indicating whether object's shader (instead of defined by this aspect) should be used for filling section.
|
||||
Standard_Boolean ToUseObjectShader() const { return (myFlags & Flags_UseObjectShader) != 0; }
|
||||
|
||||
public:
|
||||
|
||||
//! Sets style of hatch defined by predefined stipple mask.
|
||||
Standard_EXPORT void SetHatchStyle (const Aspect_HatchStyle theStyle);
|
||||
|
||||
//! Sets style of hatch defined by custom stipple mask.
|
||||
Standard_EXPORT void SetHatchStyle (const Handle(Graphic3d_HatchStyle)& theStyle);
|
||||
|
||||
//! Sets style of hatch defined by texture map (decal texture with alpha channel should be used).
|
||||
Standard_EXPORT void SetHatchStyle (const Handle(Graphic3d_TextureMap)& theTexture);
|
||||
|
||||
//! Sets material style for hatch lines (texture).
|
||||
Standard_EXPORT void SetHatchMaterial (const Graphic3d_MaterialAspect& theMaterial);
|
||||
|
||||
//! Returns material style for hatch lines (texture).
|
||||
const Graphic3d_MaterialAspect& HatchMaterial() const { return myHatchMaterial; }
|
||||
|
||||
//! Sets boolean flag indicating whether the hatch layer should be drawn or not.
|
||||
Standard_EXPORT void SetToDrawHatch (const Standard_Boolean theToDraw);
|
||||
|
||||
//! Returns boolean flag indicating whether the hatch layer should be drawn or not.
|
||||
Standard_Boolean ToDrawHatch() const { return (myFlags & Flags_DrawHatching) != 0; }
|
||||
|
||||
//! Sets flag controlling behavior of hatch texture mapping on zooming.
|
||||
//! @param theToSet [in] if passed TRUE the texture will keep constant screen-scale independent of zooming.
|
||||
Standard_EXPORT void SetHatchZoomPeristent (const Standard_Boolean theToSet);
|
||||
|
||||
//! Returns value of flag controlling behavior of hatch texture mapping on zooming.
|
||||
Standard_Boolean IsHatchZoomPersistent() { return (myFlags & Flags_HatchZoomPersistent) != 0; }
|
||||
|
||||
//! Sets flag controlling behavior of hatch texture mapping on camera rotation around heading vector.
|
||||
Standard_EXPORT void SetHatchRotationPeristent (const Standard_Boolean theToSet);
|
||||
|
||||
//! Returns value of flag controlling behavior of hatch texture mapping on camera rotation around heading vector.
|
||||
Standard_Boolean IsHatchRotationPersistent() { return (myFlags & Flags_HatchRotationPersistent) != 0; }
|
||||
|
||||
//! Returns true if hatch is defined by texture.
|
||||
Standard_Boolean IsTextureHatch() const { return !myTextureHatch.IsNull(); }
|
||||
|
||||
//! Returns texture map defining the hatch.
|
||||
const Handle(Graphic3d_TextureMap)& TextureHatch() const { return myTextureHatch; }
|
||||
|
||||
//! Returns true if hatch is defined by stipple mask.
|
||||
Standard_Boolean IsStippleHatch() const { return !myStippleHatch.IsNull(); }
|
||||
|
||||
//! Returns the stipple mask.
|
||||
const Handle(Graphic3d_HatchStyle)& StippleHatch() const { return myStippleHatch; }
|
||||
|
||||
//! Returns modification counter for hatching state.
|
||||
Standard_Size HatchingState() const { return myHatchingState; }
|
||||
|
||||
private:
|
||||
|
||||
enum Flags
|
||||
{
|
||||
Flags_None = 0x00, //!< no flags
|
||||
Flags_UseObjectMaterial = 0x01, //!< use object material
|
||||
Flags_UseObjectTexture = 0x02, //!< use object texture
|
||||
Flags_UseObjectShader = 0x04, //!< use object GLSL program
|
||||
Flags_HatchZoomPersistent = 0x08, //!< zoom-persistent texturing
|
||||
Flags_HatchRotationPersistent = 0x10, //!< rotation-persistent texturing
|
||||
Flags_DrawHatching = 0x20, //!< draw hatching
|
||||
Flags_UseObjectProperties = //!< use entire fill area aspect from object
|
||||
Flags_UseObjectMaterial
|
||||
| Flags_UseObjectTexture
|
||||
| Flags_UseObjectShader
|
||||
};
|
||||
|
||||
void setFlag (const Standard_Boolean theToUse, const unsigned int theFlag)
|
||||
{
|
||||
myFlags = theToUse ? myFlags | theFlag : myFlags & ~theFlag;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Graphic3d_MaterialAspect myMaterial;
|
||||
Handle(Graphic3d_TextureMap) myTexture;
|
||||
Handle(Graphic3d_ShaderProgram) myShader;
|
||||
Handle(Graphic3d_HatchStyle) myStippleHatch;
|
||||
Handle(Graphic3d_TextureMap) myTextureHatch;
|
||||
Graphic3d_MaterialAspect myHatchMaterial;
|
||||
unsigned int myFlags;
|
||||
Standard_Size myHatchingState;
|
||||
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectFillCapping, Graphic3d_Aspects)
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE (Graphic3d_AspectFillCapping, Graphic3d_Aspects)
|
||||
|
||||
#endif // _Graphic3d_AspectFillCapping_HeaderFile
|
@@ -24,19 +24,6 @@ IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ClipPlane,Standard_Transient)
|
||||
namespace
|
||||
{
|
||||
static volatile Standard_Integer THE_CLIP_PLANE_COUNTER = 0;
|
||||
|
||||
static Handle(Graphic3d_AspectFillArea3d) defaultAspect()
|
||||
{
|
||||
Graphic3d_MaterialAspect aMaterial (Graphic3d_NOM_DEFAULT);
|
||||
Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d();
|
||||
anAspect->SetDistinguishOff();
|
||||
anAspect->SetFrontMaterial (aMaterial);
|
||||
anAspect->SetHatchStyle (Aspect_HS_HORIZONTAL);
|
||||
anAspect->SetInteriorStyle (Aspect_IS_SOLID);
|
||||
anAspect->SetInteriorColor (Quantity_NOC_GRAY20);
|
||||
anAspect->SetSuppressBackFaces (false);
|
||||
return anAspect;
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -44,19 +31,8 @@ namespace
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_ClipPlane::Graphic3d_ClipPlane()
|
||||
: myAspect (defaultAspect()),
|
||||
myPrevInChain(NULL),
|
||||
myPlane (0.0, 0.0, 1.0, 0.0),
|
||||
myEquation (0.0, 0.0, 1.0, 0.0),
|
||||
myEquationRev(0.0, 0.0,-1.0, 0.0),
|
||||
myChainLenFwd(1),
|
||||
myFlags (Graphic3d_CappingFlags_None),
|
||||
myEquationMod(0),
|
||||
myAspectMod (0),
|
||||
myIsOn (Standard_True),
|
||||
myIsCapping (Standard_False)
|
||||
{
|
||||
makeId();
|
||||
init();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -64,19 +40,8 @@ Graphic3d_ClipPlane::Graphic3d_ClipPlane()
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_ClipPlane::Graphic3d_ClipPlane (const Graphic3d_Vec4d& theEquation)
|
||||
: myAspect (defaultAspect()),
|
||||
myPrevInChain(NULL),
|
||||
myPlane (theEquation.x(), theEquation.y(), theEquation.z(), theEquation.w()),
|
||||
myEquation (theEquation),
|
||||
myEquationRev(0.0, 0.0,-1.0, 0.0),
|
||||
myChainLenFwd(1),
|
||||
myFlags (Graphic3d_CappingFlags_None),
|
||||
myEquationMod(0),
|
||||
myAspectMod (0),
|
||||
myIsOn (Standard_True),
|
||||
myIsCapping (Standard_False)
|
||||
{
|
||||
makeId();
|
||||
init (gp_Pln (theEquation.x(), theEquation.y(), theEquation.z(), theEquation.a()));
|
||||
updateInversedPlane();
|
||||
}
|
||||
|
||||
@@ -84,42 +49,27 @@ Graphic3d_ClipPlane::Graphic3d_ClipPlane (const Graphic3d_Vec4d& theEquation)
|
||||
// function : Graphic3d_ClipPlane
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Graphic3d_ClipPlane& theOther)
|
||||
: Standard_Transient(theOther),
|
||||
myAspect (defaultAspect()),
|
||||
myPrevInChain(NULL),
|
||||
myPlane (theOther.myPlane),
|
||||
myEquation (theOther.myEquation),
|
||||
myEquationRev(theOther.myEquationRev),
|
||||
myChainLenFwd(1),
|
||||
myFlags (theOther.myFlags),
|
||||
myEquationMod(0),
|
||||
myAspectMod (0),
|
||||
myIsOn (theOther.myIsOn),
|
||||
myIsCapping (theOther.myIsCapping)
|
||||
Graphic3d_ClipPlane::Graphic3d_ClipPlane (const Graphic3d_ClipPlane& theOther)
|
||||
: Standard_Transient (theOther)
|
||||
{
|
||||
makeId();
|
||||
*myAspect = *theOther.CappingAspect();
|
||||
*mySectionStyle = *theOther.CappingSectionStyle();
|
||||
init (theOther.myPlane,
|
||||
theOther.myEquationRev,
|
||||
theOther.myIsOn,
|
||||
theOther.myIsCapping,
|
||||
theOther.ToOverrideCappingAspect(),
|
||||
theOther.CappingSectionStyle());
|
||||
updateInversedPlane();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_ClipPlane
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_ClipPlane::Graphic3d_ClipPlane(const gp_Pln& thePlane)
|
||||
: myAspect (defaultAspect()),
|
||||
myPrevInChain(NULL),
|
||||
myPlane (thePlane),
|
||||
myChainLenFwd(1),
|
||||
myFlags (Graphic3d_CappingFlags_None),
|
||||
myEquationMod(0),
|
||||
myAspectMod (0),
|
||||
myIsOn (Standard_True),
|
||||
myIsCapping (Standard_False)
|
||||
Graphic3d_ClipPlane::Graphic3d_ClipPlane (const gp_Pln& thePlane)
|
||||
{
|
||||
thePlane.Coefficients (myEquation[0], myEquation[1], myEquation[2], myEquation[3]);
|
||||
init (thePlane);
|
||||
updateInversedPlane();
|
||||
makeId();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -131,7 +81,7 @@ void Graphic3d_ClipPlane::SetEquation (const Graphic3d_Vec4d& theEquation)
|
||||
myPlane = gp_Pln (theEquation.x(), theEquation.y(), theEquation.z(), theEquation.w());
|
||||
myEquation = theEquation;
|
||||
updateInversedPlane();
|
||||
myEquationMod++;
|
||||
myOrientationDirty = Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -143,7 +93,7 @@ void Graphic3d_ClipPlane::SetEquation (const gp_Pln& thePlane)
|
||||
myPlane = thePlane;
|
||||
thePlane.Coefficients (myEquation[0], myEquation[1], myEquation[2], myEquation[3]);
|
||||
updateInversedPlane();
|
||||
myEquationMod++;
|
||||
myOrientationDirty = Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -183,128 +133,114 @@ Handle(Graphic3d_ClipPlane) Graphic3d_ClipPlane::Clone() const
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::SetCappingColor (const Quantity_Color& theColor)
|
||||
{
|
||||
myAspect->SetInteriorColor (theColor);
|
||||
myAspect->ChangeFrontMaterial().SetColor (theColor);
|
||||
mySectionStyle->SetInteriorColor (theColor);
|
||||
mySectionStyle->ChangeFrontMaterial().SetColor (theColor);
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetCappingMaterial
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::SetCappingMaterial (const Graphic3d_MaterialAspect& theMat)
|
||||
void Graphic3d_ClipPlane::SetCappingSectionStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle)
|
||||
{
|
||||
myAspect->SetFrontMaterial (theMat);
|
||||
if (myAspect->FrontMaterial().MaterialType() != Graphic3d_MATERIAL_ASPECT)
|
||||
mySectionStyle = theStyle;
|
||||
if (mySectionStyle->FrontMaterial().MaterialType() != Graphic3d_MATERIAL_ASPECT)
|
||||
{
|
||||
myAspect->SetInteriorColor (theMat.Color());
|
||||
}
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetCappingTexture
|
||||
// function : OrientationMatrix
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::SetCappingTexture (const Handle(Graphic3d_TextureMap)& theTexture)
|
||||
const Graphic3d_Mat4& Graphic3d_ClipPlane::OrientationMatrix() const
|
||||
{
|
||||
if (!theTexture.IsNull())
|
||||
if (myOrientationDirty)
|
||||
{
|
||||
myAspect->SetTextureMapOn();
|
||||
Handle(Graphic3d_TextureSet) aTextureSet = myAspect->TextureSet();
|
||||
if (aTextureSet.IsNull() || aTextureSet->Size() != 1)
|
||||
const Standard_ShortReal aDirection[] = {
|
||||
static_cast<Standard_ShortReal> (myEquation[0]),
|
||||
static_cast<Standard_ShortReal> (myEquation[1]),
|
||||
static_cast<Standard_ShortReal> (myEquation[2])
|
||||
};
|
||||
|
||||
const Standard_ShortReal aTranslate[] = {
|
||||
static_cast<Standard_ShortReal> (myEquation[0] * -myEquation[3]),
|
||||
static_cast<Standard_ShortReal> (myEquation[1] * -myEquation[3]),
|
||||
static_cast<Standard_ShortReal> (myEquation[2] * -myEquation[3])
|
||||
};
|
||||
|
||||
Standard_ShortReal aSide1[] = { 0.0f, 0.0f, 0.0f };
|
||||
Standard_ShortReal aSide2[] = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
const Standard_ShortReal aMagintude = static_cast<Standard_ShortReal> (Sqrt (myEquation[0] * myEquation[0] + myEquation[2] * myEquation[2]));
|
||||
|
||||
if (aMagintude < ShortRealSmall())
|
||||
{
|
||||
aTextureSet = new Graphic3d_TextureSet (theTexture);
|
||||
aSide1[0] = 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
aTextureSet->SetFirst (theTexture);
|
||||
aSide1[0] = aDirection[2] / aMagintude;
|
||||
aSide1[2] = -aDirection[0] / aMagintude;
|
||||
}
|
||||
myAspect->SetTextureSet (aTextureSet);
|
||||
|
||||
aSide2[0] = (-aSide1[1] * aDirection[2]) - (-aSide1[2] * aDirection[1]);
|
||||
aSide2[1] = (-aSide1[2] * aDirection[0]) - (-aSide1[0] * aDirection[2]);
|
||||
aSide2[2] = (-aSide1[0] * aDirection[1]) - (-aSide1[1] * aDirection[0]);
|
||||
|
||||
myOrientationMat.SetValue (0, 0, aSide1[0]);
|
||||
myOrientationMat.SetValue (1, 0, aSide1[1]);
|
||||
myOrientationMat.SetValue (2, 0, aSide1[2]);
|
||||
myOrientationMat.SetValue (3, 0, 0.0F);
|
||||
|
||||
myOrientationMat.SetValue (0, 1, aDirection[0]);
|
||||
myOrientationMat.SetValue (1, 1, aDirection[1]);
|
||||
myOrientationMat.SetValue (2, 1, aDirection[2]);
|
||||
myOrientationMat.SetValue (3, 1, 0.0F);
|
||||
|
||||
myOrientationMat.SetValue (0, 2, aSide2[0]);
|
||||
myOrientationMat.SetValue (1, 2, aSide2[1]);
|
||||
myOrientationMat.SetValue (2, 2, aSide2[2]);
|
||||
myOrientationMat.SetValue (3, 2, 0.0F);
|
||||
|
||||
myOrientationMat.SetValue (0, 3, aTranslate[0]);
|
||||
myOrientationMat.SetValue (1, 3, aTranslate[1]);
|
||||
myOrientationMat.SetValue (2, 3, aTranslate[2]);
|
||||
myOrientationMat.SetValue (3, 3, 1.0F);
|
||||
|
||||
myOrientationDirty = Standard_False;
|
||||
}
|
||||
else
|
||||
|
||||
return myOrientationMat;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : init
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::init (const gp_Pln& thePlane,
|
||||
const Graphic3d_Vec4d& theEquationRev,
|
||||
const Standard_Boolean theIsOn,
|
||||
const Standard_Boolean theIsCapping,
|
||||
const Standard_Boolean theOverrideStyle,
|
||||
const Handle(Graphic3d_AspectFillCapping)& theStyle)
|
||||
{
|
||||
if (myEntityUID.IsEmpty())
|
||||
{
|
||||
myAspect->SetTextureMapOff();
|
||||
myAspect->SetTextureSet (Handle(Graphic3d_TextureSet)());
|
||||
myEntityUID = TCollection_AsciiString ("Graphic3d_ClipPlane_") //DynamicType()->Name()
|
||||
+ TCollection_AsciiString (Standard_Atomic_Increment (&THE_CLIP_PLANE_COUNTER));
|
||||
}
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetCappingHatch
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::SetCappingHatch (const Aspect_HatchStyle theStyle)
|
||||
{
|
||||
myAspect->SetHatchStyle (theStyle);
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetCappingCustomHatch
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::SetCappingCustomHatch (const Handle(Graphic3d_HatchStyle)& theStyle)
|
||||
{
|
||||
myAspect->SetHatchStyle (theStyle);
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetCappingHatchOn
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::SetCappingHatchOn()
|
||||
{
|
||||
myAspect->SetInteriorStyle (Aspect_IS_HATCH);
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetCappingHatchOff
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::SetCappingHatchOff()
|
||||
{
|
||||
myAspect->SetInteriorStyle (Aspect_IS_SOLID);
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetCappingAspect
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::SetCappingAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect)
|
||||
{
|
||||
myAspect = theAspect;
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : setCappingFlag
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::setCappingFlag (bool theToUse, int theFlag)
|
||||
{
|
||||
if (theToUse)
|
||||
{
|
||||
myFlags |= theFlag;
|
||||
}
|
||||
else
|
||||
{
|
||||
myFlags &= ~(theFlag);
|
||||
}
|
||||
++myAspectMod;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : makeId
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::makeId()
|
||||
{
|
||||
myId = TCollection_AsciiString ("Graphic3d_ClipPlane_") //DynamicType()->Name()
|
||||
+ TCollection_AsciiString (Standard_Atomic_Increment (&THE_CLIP_PLANE_COUNTER));
|
||||
myPrevInChain = NULL;
|
||||
myEquationRev = theEquationRev;
|
||||
myChainLenFwd = 1;
|
||||
myPlane = thePlane;
|
||||
myPlane.Coefficients (myEquation[0], myEquation[1], myEquation[2], myEquation[3]);
|
||||
myIsOn = theIsOn;
|
||||
myIsCapping = theIsCapping;
|
||||
myOverrideObjectStyle = theOverrideStyle;
|
||||
mySectionStyle = theStyle.IsNull() ? new Graphic3d_AspectFillCapping() : theStyle;
|
||||
myOrientationDirty = Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -326,7 +262,7 @@ void Graphic3d_ClipPlane::updateChainLen()
|
||||
// =======================================================================
|
||||
void Graphic3d_ClipPlane::SetChainNextPlane (const Handle(Graphic3d_ClipPlane)& thePlane)
|
||||
{
|
||||
++myEquationMod;
|
||||
myOrientationDirty = Standard_True;
|
||||
if (!myNextInChain.IsNull())
|
||||
{
|
||||
myNextInChain->myPrevInChain = NULL;
|
||||
|
@@ -19,9 +19,12 @@
|
||||
#include <Aspect_HatchStyle.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
#include <Graphic3d_AspectFillArea3d.hxx>
|
||||
#include <Graphic3d_AspectFillCapping.hxx>
|
||||
#include <Graphic3d_BndBox3d.hxx>
|
||||
#include <Graphic3d_CappingFlags.hxx>
|
||||
#include <Graphic3d_Mat4.hxx>
|
||||
#include <Graphic3d_TextureMap.hxx>
|
||||
#include <NCollection_Handle.hxx>
|
||||
#include <NCollection_Vec4.hxx>
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <Standard_TypeDef.hxx>
|
||||
@@ -167,49 +170,11 @@ public:
|
||||
public: // @name user-defined graphical attributes
|
||||
|
||||
//! Return color for rendering capping surface.
|
||||
Quantity_Color CappingColor() const { return myAspect->FrontMaterial().MaterialType() == Graphic3d_MATERIAL_ASPECT ? myAspect->FrontMaterial().Color() : myAspect->InteriorColor(); }
|
||||
Quantity_Color CappingColor() const { return mySectionStyle->FrontMaterial().MaterialType() == Graphic3d_MATERIAL_ASPECT ? mySectionStyle->FrontMaterial().Color() : mySectionStyle->InteriorColor(); }
|
||||
|
||||
//! Set color for rendering capping surface.
|
||||
Standard_EXPORT void SetCappingColor (const Quantity_Color& theColor);
|
||||
|
||||
//! Set material for rendering capping surface.
|
||||
//! @param theMat [in] the material.
|
||||
Standard_EXPORT void SetCappingMaterial (const Graphic3d_MaterialAspect& theMat);
|
||||
|
||||
//! @return capping material.
|
||||
const Graphic3d_MaterialAspect& CappingMaterial() const { return myAspect->FrontMaterial(); }
|
||||
|
||||
//! Set texture to be applied on capping surface.
|
||||
//! @param theTexture [in] the texture.
|
||||
Standard_EXPORT void SetCappingTexture (const Handle(Graphic3d_TextureMap)& theTexture);
|
||||
|
||||
//! @return capping texture map.
|
||||
Handle(Graphic3d_TextureMap) CappingTexture() const { return !myAspect->TextureSet().IsNull() && !myAspect->TextureSet()->IsEmpty()
|
||||
? myAspect->TextureSet()->First()
|
||||
: Handle(Graphic3d_TextureMap)(); }
|
||||
|
||||
//! Set hatch style (stipple) and turn hatching on.
|
||||
//! @param theStyle [in] the hatch style.
|
||||
Standard_EXPORT void SetCappingHatch (const Aspect_HatchStyle theStyle);
|
||||
|
||||
//! @return hatching style.
|
||||
Aspect_HatchStyle CappingHatch() const { return (Aspect_HatchStyle)myAspect->HatchStyle()->HatchType(); }
|
||||
|
||||
//! Set custom hatch style (stipple) and turn hatching on.
|
||||
//! @param theStyle [in] the hatch pattern.
|
||||
Standard_EXPORT void SetCappingCustomHatch (const Handle(Graphic3d_HatchStyle)& theStyle);
|
||||
|
||||
//! @return hatching style.
|
||||
const Handle(Graphic3d_HatchStyle)& CappingCustomHatch() const { return myAspect->HatchStyle(); }
|
||||
|
||||
//! Turn on hatching.
|
||||
Standard_EXPORT void SetCappingHatchOn();
|
||||
|
||||
//! Turn off hatching.
|
||||
Standard_EXPORT void SetCappingHatchOff();
|
||||
|
||||
//! @return True if hatching mask is turned on.
|
||||
Standard_Boolean IsHatchOn() const { return myAspect->InteriorStyle() == Aspect_IS_HATCH; }
|
||||
|
||||
//! This ID is used for managing associated resources in graphical driver.
|
||||
//! The clip plane can be assigned within a range of IO which can be
|
||||
@@ -220,41 +185,18 @@ public: // @name user-defined graphical attributes
|
||||
//! @return clip plane resource identifier string.
|
||||
const TCollection_AsciiString& GetId() const
|
||||
{
|
||||
return myId;
|
||||
return myEntityUID;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//! Return capping aspect.
|
||||
//! Returns style used for drawing capping section.
|
||||
//! @return capping surface rendering aspect.
|
||||
const Handle(Graphic3d_AspectFillArea3d)& CappingAspect() const { return myAspect; }
|
||||
const Handle(Graphic3d_AspectFillCapping)& CappingSectionStyle() const { return mySectionStyle; }
|
||||
|
||||
//! Assign capping aspect.
|
||||
Standard_EXPORT void SetCappingAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect);
|
||||
//! Sets clipping section filling aspect.
|
||||
Standard_EXPORT void SetCappingSectionStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle);
|
||||
|
||||
//! Flag indicating whether material for capping plane should be taken from object.
|
||||
//! Default value: FALSE (use dedicated capping plane material).
|
||||
bool ToUseObjectMaterial() const { return (myFlags & Graphic3d_CappingFlags_ObjectMaterial) != 0; }
|
||||
|
||||
//! Set flag for controlling the source of capping plane material.
|
||||
void SetUseObjectMaterial (bool theToUse) { setCappingFlag (theToUse, Graphic3d_CappingFlags_ObjectMaterial); }
|
||||
|
||||
//! Flag indicating whether texture for capping plane should be taken from object.
|
||||
//! Default value: FALSE.
|
||||
bool ToUseObjectTexture() const { return (myFlags & Graphic3d_CappingFlags_ObjectTexture) != 0; }
|
||||
|
||||
//! Set flag for controlling the source of capping plane texture.
|
||||
void SetUseObjectTexture (bool theToUse) { setCappingFlag (theToUse, Graphic3d_CappingFlags_ObjectTexture); }
|
||||
|
||||
//! Flag indicating whether shader program for capping plane should be taken from object.
|
||||
//! Default value: FALSE.
|
||||
bool ToUseObjectShader() const { return (myFlags & Graphic3d_CappingFlags_ObjectShader) != 0; }
|
||||
|
||||
//! Set flag for controlling the source of capping plane shader program.
|
||||
void SetUseObjectShader(bool theToUse) { setCappingFlag (theToUse, Graphic3d_CappingFlags_ObjectShader); }
|
||||
|
||||
//! Return true if some fill area aspect properties should be taken from object.
|
||||
bool ToUseObjectProperties() const { return myFlags != Graphic3d_CappingFlags_None; }
|
||||
|
||||
public:
|
||||
|
||||
@@ -393,14 +335,25 @@ public: // @name modification counters
|
||||
{
|
||||
return myAspectMod;
|
||||
}
|
||||
//! Flag indicating whether section style of the plane should overrides similar property of object presentation.
|
||||
//! Default value: FALSE (use dedicated presentation aspect style).
|
||||
bool ToOverrideCappingAspect() const { return myOverrideObjectStyle; }
|
||||
|
||||
//! Sets flag for controlling the preference of using section style between clip plane and object.
|
||||
void SetToOverrideCappingAspect (const bool theToOverride) { myOverrideObjectStyle = theToOverride; }
|
||||
|
||||
//! Returns plane's orientation matrix.
|
||||
Standard_EXPORT const Graphic3d_Mat4& OrientationMatrix() const;
|
||||
|
||||
private:
|
||||
|
||||
//! Generate unique object id for OpenGL graphic resource manager.
|
||||
void makeId();
|
||||
|
||||
//! Set capping flag.
|
||||
Standard_EXPORT void setCappingFlag (bool theToUse, int theFlag);
|
||||
//! Initializes plane and makes unique identifier (UID) to differentiate clipping plane entities.
|
||||
void init (const gp_Pln& thePlane = gp_Pln(),
|
||||
const Graphic3d_Vec4d& theEquationRev = Graphic3d_Vec4d(0.0, 0.0,-1.0, 0.0),
|
||||
const Standard_Boolean theIsOn = Standard_True,
|
||||
const Standard_Boolean theIsCapping = Standard_False,
|
||||
const Standard_Boolean theOverrideStyle = Standard_False,
|
||||
const Handle(Graphic3d_AspectFillCapping)& theStyle = Handle(Graphic3d_AspectFillCapping)());
|
||||
|
||||
//! Update chain length in backward direction.
|
||||
void updateChainLen();
|
||||
@@ -415,10 +368,10 @@ private:
|
||||
|
||||
private:
|
||||
|
||||
Handle(Graphic3d_AspectFillArea3d) myAspect; //!< fill area aspect
|
||||
Handle(Graphic3d_AspectFillCapping) mySectionStyle; //!< Style set for drawing capped solid section.
|
||||
Handle(Graphic3d_ClipPlane) myNextInChain; //!< next plane in a chain of planes defining logical AND operation
|
||||
Graphic3d_ClipPlane* myPrevInChain; //!< previous plane in a chain of planes defining logical AND operation
|
||||
TCollection_AsciiString myId; //!< resource id
|
||||
TCollection_AsciiString myEntityUID; //!< Unique identifier for the plane
|
||||
gp_Pln myPlane; //!< plane definition
|
||||
Graphic3d_Vec4d myEquation; //!< plane equation vector
|
||||
Graphic3d_Vec4d myEquationRev; //!< reversed plane equation
|
||||
@@ -428,6 +381,9 @@ private:
|
||||
unsigned int myAspectMod; //!< modification counter of aspect
|
||||
Standard_Boolean myIsOn; //!< state of the clipping plane
|
||||
Standard_Boolean myIsCapping; //!< state of graphic driver capping
|
||||
Standard_Boolean myOverrideObjectStyle; //!< Flag forcing to use plane's section style rather than section style defined for object
|
||||
mutable Standard_Boolean myOrientationDirty; //!< Boolean flag indicating whether orientation matrix is dirty or not.
|
||||
mutable Graphic3d_Mat4 myOrientationMat; //!< Plane orientation matrix (for visualization purposes).
|
||||
|
||||
};
|
||||
|
||||
|
@@ -37,6 +37,7 @@
|
||||
|
||||
class Graphic3d_Structure;
|
||||
class Graphic3d_ArrayOfPrimitives;
|
||||
class Graphic3d_AspectFillCapping;
|
||||
class Graphic3d_Text;
|
||||
|
||||
//! This class allows the definition of groups
|
||||
@@ -105,6 +106,9 @@ public:
|
||||
//! Modifies the current context of the group to give another aspect for all the primitives created after this call in the group.
|
||||
virtual void SetPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect) = 0;
|
||||
|
||||
//! Returns style of filling clipping sections on closed shell primitives.
|
||||
virtual Handle(Graphic3d_AspectFillCapping) FillCappingAspect() const = 0;
|
||||
|
||||
//! Update presentation aspects after their modification.
|
||||
virtual void SynchronizeAspects() = 0;
|
||||
|
||||
|
@@ -21,13 +21,15 @@
|
||||
//! - ASPECT_LINE: aspect for line primitives;
|
||||
//! - ASPECT_TEXT: aspect for text primitives;
|
||||
//! - ASPECT_MARKER: aspect for marker primitives;
|
||||
//! - ASPECT_FILL_AREA: aspect for face primitives.
|
||||
//! - ASPECT_FILL_AREA: aspect for face primitives;
|
||||
//! - Graphic3d_ASPECT_FILL_CAPPING: aspect for filling clipping sections.
|
||||
enum Graphic3d_GroupAspect
|
||||
{
|
||||
Graphic3d_ASPECT_LINE,
|
||||
Graphic3d_ASPECT_TEXT,
|
||||
Graphic3d_ASPECT_MARKER,
|
||||
Graphic3d_ASPECT_FILL_AREA
|
||||
Graphic3d_ASPECT_FILL_AREA,
|
||||
Graphic3d_ASPECT_FILL_CAPPING
|
||||
};
|
||||
|
||||
#endif // _Graphic3d_GroupAspect_HeaderFile
|
||||
|
@@ -18,7 +18,6 @@
|
||||
#include <NCollection_Array1.hxx>
|
||||
|
||||
//! Class holding array of textures to be mapped as a set.
|
||||
//! Textures should be defined in ascending order of texture units within the set.
|
||||
class Graphic3d_TextureSet : public Standard_Transient
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Graphic3d_TextureSet, Standard_Transient)
|
||||
|
@@ -243,12 +243,6 @@ void Message_PrinterOStream::SetConsoleTextColor (Standard_OStream* theOStream,
|
||||
}
|
||||
SetConsoleTextAttribute (anStdOut, aFlags);
|
||||
}
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
// Terminal capabilities are undefined on this platform.
|
||||
// std::cout could be redirected to HTML page, into terminal or somewhere else.
|
||||
(void )theOStream;
|
||||
(void )theTextColor;
|
||||
(void )theIsIntenseText;
|
||||
#else
|
||||
if (theOStream == NULL)
|
||||
{
|
||||
|
@@ -54,35 +54,6 @@
|
||||
}
|
||||
return ANDROID_LOG_DEBUG;
|
||||
}
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
#include <emscripten/emscripten.h>
|
||||
|
||||
// actual version of Emscripten does not define these yet
|
||||
#ifndef EM_LOG_INFO
|
||||
#define EM_LOG_INFO 0
|
||||
#endif
|
||||
#ifndef EM_LOG_DEBUG
|
||||
#define EM_LOG_DEBUG 0
|
||||
#endif
|
||||
|
||||
//! Convert message gravity into emscripten_log() flags.
|
||||
static int getEmscriptenPriority (const Message_Gravity theGravity)
|
||||
{
|
||||
switch (theGravity)
|
||||
{
|
||||
case Message_Trace: return EM_LOG_CONSOLE | EM_LOG_DEBUG;
|
||||
case Message_Info: return EM_LOG_CONSOLE | EM_LOG_INFO;
|
||||
case Message_Warning: return EM_LOG_CONSOLE | EM_LOG_WARN;
|
||||
case Message_Alarm: return EM_LOG_CONSOLE | EM_LOG_ERROR;
|
||||
case Message_Fail: return EM_LOG_CONSOLE | EM_LOG_ERROR;
|
||||
}
|
||||
return EM_LOG_CONSOLE;
|
||||
}
|
||||
|
||||
//! Print message to console.debug().
|
||||
EM_JS(void, debugMsgToConsole, (const char* theStr), {
|
||||
console.debug(UTF8ToString(theStr));
|
||||
});
|
||||
#else
|
||||
#include <syslog.h>
|
||||
|
||||
@@ -119,8 +90,6 @@ Message_PrinterSystemLog::Message_PrinterSystemLog (const TCollection_AsciiStrin
|
||||
myEventSource = (Standard_Address )RegisterEventSourceW (NULL, aWideSrcName.ToWideString());
|
||||
#elif defined(__ANDROID__)
|
||||
//
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
//
|
||||
#else
|
||||
openlog (myEventSourceName.ToCString(), LOG_PID | LOG_NDELAY, LOG_USER);
|
||||
#endif
|
||||
@@ -141,8 +110,6 @@ Message_PrinterSystemLog::~Message_PrinterSystemLog()
|
||||
}
|
||||
#elif defined(__ANDROID__)
|
||||
//
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
//
|
||||
#else
|
||||
closelog();
|
||||
#endif
|
||||
@@ -165,15 +132,6 @@ void Message_PrinterSystemLog::Send (const Standard_CString theString,
|
||||
Send (TCollection_ExtendedString (theString), theGravity, true);
|
||||
#elif defined(__ANDROID__)
|
||||
__android_log_write (getAndroidLogPriority (theGravity), myEventSourceName.ToCString(), theString);
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
if (theGravity == Message_Trace)
|
||||
{
|
||||
debugMsgToConsole (theString);
|
||||
}
|
||||
else
|
||||
{
|
||||
emscripten_log (getEmscriptenPriority (theGravity), "%s", theString);
|
||||
}
|
||||
#else
|
||||
syslog (getSysLogPriority (theGravity), "%s", theString);
|
||||
#endif
|
||||
@@ -196,15 +154,6 @@ void Message_PrinterSystemLog::Send (const TCollection_AsciiString& theString,
|
||||
Send (TCollection_ExtendedString (theString), theGravity, true);
|
||||
#elif defined(__ANDROID__)
|
||||
__android_log_write (getAndroidLogPriority (theGravity), myEventSourceName.ToCString(), theString.ToCString());
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
if (theGravity == Message_Trace)
|
||||
{
|
||||
debugMsgToConsole (theString.ToCString());
|
||||
}
|
||||
else
|
||||
{
|
||||
emscripten_log (getEmscriptenPriority (theGravity), "%s", theString.ToCString());
|
||||
}
|
||||
#else
|
||||
syslog (getSysLogPriority (theGravity), "%s", theString.ToCString());
|
||||
#endif
|
||||
|
@@ -56,7 +56,6 @@ OpenGl_TextureFormat.cxx
|
||||
OpenGl_TextureFormat.hxx
|
||||
OpenGl_TextureSet.cxx
|
||||
OpenGl_TextureSet.hxx
|
||||
OpenGl_TextureSetPairIterator.hxx
|
||||
OpenGl_Resource.hxx
|
||||
OpenGl_Resource.cxx
|
||||
OpenGl_NamedResource.hxx
|
||||
|
@@ -195,7 +195,6 @@ void OpenGl_AspectsTextureSet::build (const Handle(OpenGl_Context)& theCtx,
|
||||
|
||||
Standard_Integer& aTextureSetBits = myTextures[0]->ChangeTextureSetBits();
|
||||
aTextureSetBits = Graphic3d_TextureSetBits_NONE;
|
||||
Standard_Integer aPrevTextureUnit = -1;
|
||||
if (theAspect->ToMapTexture())
|
||||
{
|
||||
Graphic3d_TextureSet::Iterator aTextureIter (aNewTextureSet);
|
||||
@@ -213,11 +212,6 @@ void OpenGl_AspectsTextureSet::build (const Handle(OpenGl_Context)& theCtx,
|
||||
if (aResource->Init(theCtx, aTexture))
|
||||
{
|
||||
aResIter0.ChangeUnit() = aResource->Sampler()->Parameters()->TextureUnit();
|
||||
if (aResIter0.Unit() < aPrevTextureUnit)
|
||||
{
|
||||
throw Standard_ProgramError("Graphic3d_TextureMap defines texture units in non-ascending order");
|
||||
}
|
||||
aPrevTextureUnit = aResIter0.Unit();
|
||||
aResource->Sampler()->SetParameters(aTexture->GetParams());
|
||||
aResource->SetRevision (aTexture->Revision());
|
||||
}
|
||||
@@ -268,11 +262,6 @@ void OpenGl_AspectsTextureSet::build (const Handle(OpenGl_Context)& theCtx,
|
||||
// update occupation of texture units
|
||||
const Graphic3d_TextureUnit aTexUnit = aResource->Sampler()->Parameters()->TextureUnit();
|
||||
aResIter0.ChangeUnit() = aTexUnit;
|
||||
if (aResIter0.Unit() < aPrevTextureUnit)
|
||||
{
|
||||
throw Standard_ProgramError("Graphic3d_TextureMap defines texture units in non-ascending order");
|
||||
}
|
||||
aPrevTextureUnit = aResIter0.Unit();
|
||||
if (aTexUnit >= Graphic3d_TextureUnit_0 && aTexUnit <= Graphic3d_TextureUnit_5)
|
||||
{
|
||||
aTextureSetBits |= (1 << int(aTexUnit));
|
||||
|
@@ -21,11 +21,16 @@
|
||||
#include <OpenGl_PrimitiveArray.hxx>
|
||||
#include <OpenGl_CappingPlaneResource.hxx>
|
||||
#include <OpenGl_Vec.hxx>
|
||||
#include <OpenGl_View.hxx>
|
||||
#include <OpenGl_Structure.hxx>
|
||||
#include <OpenGl_ShaderManager.hxx>
|
||||
|
||||
namespace
|
||||
{
|
||||
static const OpenGl_CappingPlaneResource* THE_DEFAULT_ASPECT = new OpenGl_CappingPlaneResource (new Graphic3d_AspectFillCapping);
|
||||
static const TCollection_AsciiString THE_QUAD_PARRAY = "OpenGl_CappingAlgo_Quad";
|
||||
static const TCollection_AsciiString THE_PLANE_STYLE = "OpenGl_CappingAlgo_CappingStyle_";
|
||||
|
||||
//! Auxiliary sentry object managing stencil test.
|
||||
struct StencilTestSentry
|
||||
{
|
||||
@@ -58,21 +63,113 @@ namespace
|
||||
GLint myDepthFuncPrev;
|
||||
};
|
||||
|
||||
//! Render infinite capping plane.
|
||||
//! @param theWorkspace [in] the GL workspace, context state.
|
||||
//! @param thePlane [in] the graphical plane, for which the capping surface is rendered.
|
||||
static void renderPlane (const Handle(OpenGl_Workspace)& theWorkspace,
|
||||
const Handle(OpenGl_CappingPlaneResource)& thePlane)
|
||||
class OpenGl_SharedElement : public OpenGl_Resource
|
||||
{
|
||||
public:
|
||||
OpenGl_SharedElement (OpenGl_Element* theGlElement) : myGlElement (theGlElement) {}
|
||||
virtual void Release (OpenGl_Context* theGlCtx) Standard_OVERRIDE
|
||||
{
|
||||
OpenGl_Element::Destroy (theGlCtx, myGlElement);
|
||||
}
|
||||
OpenGl_Element* GlElement() const { return myGlElement; }
|
||||
|
||||
//! Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules.
|
||||
Standard_Size EstimatedDataSize() const Standard_OVERRIDE { return 0; }
|
||||
|
||||
private:
|
||||
OpenGl_Element* myGlElement;
|
||||
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTI_INLINE (OpenGl_SharedElement, OpenGl_Resource)
|
||||
};
|
||||
|
||||
//! Iitializes and returns vertex buffer for plane section
|
||||
OpenGl_PrimitiveArray* initQuad (const Handle(OpenGl_Context)& theContext)
|
||||
{
|
||||
Handle(OpenGl_SharedElement) aSharedResource;
|
||||
|
||||
if (!theContext->GetResource (THE_QUAD_PARRAY, aSharedResource))
|
||||
{
|
||||
aSharedResource = new OpenGl_SharedElement (OpenGl_CappingPlaneResource::BuildInfinitPlaneVertices());
|
||||
theContext->ShareResource (THE_QUAD_PARRAY, aSharedResource);
|
||||
}
|
||||
|
||||
return dynamic_cast<OpenGl_PrimitiveArray*> (aSharedResource->GlElement());
|
||||
}
|
||||
|
||||
//! Render section plane using the given aspects.
|
||||
void renderSection (const Handle(OpenGl_Workspace)& theWorkspace,
|
||||
const OpenGl_PrimitiveArray* theQuad,
|
||||
const OpenGl_Aspects* theCappingAspect,
|
||||
const OpenGl_Aspects* theHatchAspect,
|
||||
const OpenGl_Mat4& theCappingMatrix,
|
||||
const Standard_ShortReal theHatchScale,
|
||||
const Standard_ShortReal theHatchRotate)
|
||||
{
|
||||
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
|
||||
const bool wasCullAllowed = theWorkspace->SetAllowFaceCulling (true);
|
||||
|
||||
// set identity model matrix
|
||||
const Standard_Boolean isTextureHatch =
|
||||
theHatchAspect != NULL
|
||||
&& theHatchAspect->Aspect()->TextureMapState();
|
||||
|
||||
aContext->ModelWorldState.Push();
|
||||
aContext->ModelWorldState.SetCurrent (OpenGl_Mat4::Map (*thePlane->Orientation()->mat));
|
||||
aContext->ModelWorldState.SetCurrent (theCappingMatrix);
|
||||
aContext->ApplyModelViewMatrix();
|
||||
|
||||
thePlane->Primitives().Render (theWorkspace);
|
||||
theWorkspace->SetAspects (theCappingAspect);
|
||||
theWorkspace->ApplyAspects();
|
||||
|
||||
theQuad->Render (theWorkspace);
|
||||
|
||||
if (theHatchAspect != NULL)
|
||||
{
|
||||
Graphic3d_Vec2 aPrevScale;
|
||||
Standard_ShortReal aPrevRotate = 0.0;
|
||||
|
||||
if (isTextureHatch)
|
||||
{
|
||||
glEnable (GL_BLEND);
|
||||
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
if ((theHatchScale != 1.0 || theHatchRotate != 0.0) && !theHatchAspect->TextureSet(aContext)->IsEmpty())
|
||||
{
|
||||
Handle(OpenGl_Texture) aTexture = theHatchAspect->TextureSet(aContext)->First();
|
||||
const Handle(Graphic3d_TextureParams)& aTexParams = aTexture->Sampler()->Parameters();
|
||||
|
||||
aPrevScale = aTexParams->Scale();
|
||||
aPrevRotate = aTexParams->Rotation();
|
||||
|
||||
const Standard_Boolean isMirror = aPrevScale.x() * aPrevScale.y() < 0.0;
|
||||
aTexParams->SetScale (aPrevScale * theHatchScale);
|
||||
aTexParams->SetRotation (isMirror ? aPrevRotate - theHatchRotate : aPrevRotate + theHatchRotate);
|
||||
}
|
||||
}
|
||||
|
||||
theWorkspace->SetAspects (theHatchAspect);
|
||||
theWorkspace->ApplyAspects();
|
||||
|
||||
glDepthFunc (GL_LEQUAL);
|
||||
|
||||
theQuad->Render (theWorkspace);
|
||||
|
||||
glDepthFunc (GL_LESS);
|
||||
|
||||
if (isTextureHatch)
|
||||
{
|
||||
glDisable (GL_BLEND);
|
||||
|
||||
if (theHatchScale != 1.0 || theHatchRotate != 0.0)
|
||||
{
|
||||
Handle(OpenGl_Texture) aTexture = theHatchAspect->TextureSet(aContext)->First();
|
||||
const Handle(Graphic3d_TextureParams)& aTexParams = aTexture->Sampler()->Parameters();
|
||||
|
||||
aTexParams->SetScale (aPrevScale);
|
||||
aTexParams->SetRotation (aPrevRotate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
aContext->ModelWorldState.Pop();
|
||||
aContext->ApplyModelViewMatrix();
|
||||
@@ -86,13 +183,23 @@ namespace
|
||||
const OpenGl_Structure& theStructure,
|
||||
const Handle(Graphic3d_ClipPlane)& theClipChain,
|
||||
const Standard_Integer theSubPlaneIndex,
|
||||
const Handle(OpenGl_CappingPlaneResource)& thePlane)
|
||||
const Handle(OpenGl_CappingPlaneResource)& thePlane,
|
||||
const OpenGl_PrimitiveArray* theQuad)
|
||||
{
|
||||
const Standard_Integer aPrevFilter = theWorkspace->RenderFilter();
|
||||
const Standard_Integer anAnyFilter = aPrevFilter & ~(Standard_Integer )(OpenGl_RenderFilter_OpaqueOnly | OpenGl_RenderFilter_TransparentOnly);
|
||||
|
||||
const Handle(Graphic3d_ClipPlane)& aPlane = theClipChain;
|
||||
|
||||
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
|
||||
const Handle(Graphic3d_ClipPlane)& aRenderPlane = thePlane->Plane();
|
||||
const Handle(Graphic3d_Camera) aCamera = theWorkspace->View() != NULL
|
||||
? theWorkspace->View()->Camera()
|
||||
: Handle(Graphic3d_Camera)();
|
||||
const OpenGl_Mat4& aPlaneMat = OpenGl_Mat4::Map (aPlane->OrientationMatrix());
|
||||
Standard_ShortReal aRotateAngle = 0.0;
|
||||
Standard_ShortReal aViewScale = ShortRealLast();
|
||||
OpenGl_Mat4 aRotateZoomMat;
|
||||
|
||||
for (OpenGl_Structure::GroupIterator aGroupIter (theStructure.Groups()); aGroupIter.More(); aGroupIter.Next())
|
||||
{
|
||||
if (!aGroupIter.Value()->IsClosed())
|
||||
@@ -103,16 +210,6 @@ namespace
|
||||
// clear stencil only if something has been actually drawn
|
||||
theStencilSentry.Init();
|
||||
|
||||
// check if capping plane should be rendered within current pass (only opaque / only transparent)
|
||||
const OpenGl_Aspects* anObjAspectFace = aRenderPlane->ToUseObjectProperties() ? aGroupIter.Value()->GlAspects() : NULL;
|
||||
thePlane->Update (aContext, anObjAspectFace != NULL ? anObjAspectFace->Aspect() : Handle(Graphic3d_Aspects)());
|
||||
theWorkspace->SetAspects (thePlane->AspectFace());
|
||||
theWorkspace->SetRenderFilter (aPrevFilter);
|
||||
if (!theWorkspace->ShouldRender (&thePlane->Primitives()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// suppress only opaque/transparent filter since for filling stencil the whole geometry should be drawn
|
||||
theWorkspace->SetRenderFilter (anAnyFilter);
|
||||
|
||||
@@ -121,7 +218,7 @@ namespace
|
||||
aContext->ShaderManager()->UpdateClippingState();
|
||||
|
||||
glClear (GL_STENCIL_BUFFER_BIT);
|
||||
const bool aColorMaskBack = aContext->SetColorMask (false);
|
||||
glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
|
||||
// override aspects, disable culling
|
||||
theWorkspace->SetAspects (&theWorkspace->NoneCulling());
|
||||
@@ -140,20 +237,7 @@ namespace
|
||||
glStencilOp (GL_KEEP, GL_INVERT, GL_INVERT);
|
||||
|
||||
// render closed primitives
|
||||
if (aRenderPlane->ToUseObjectProperties())
|
||||
{
|
||||
aGroupIter.Value()->Render (theWorkspace);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (; aGroupIter.More(); aGroupIter.Next())
|
||||
{
|
||||
if (aGroupIter.Value()->IsClosed())
|
||||
{
|
||||
aGroupIter.Value()->Render (theWorkspace);
|
||||
}
|
||||
}
|
||||
}
|
||||
aGroupIter.Value()->Render (theWorkspace);
|
||||
|
||||
// override material, cull back faces
|
||||
theWorkspace->SetAspects (&theWorkspace->FrontCulling());
|
||||
@@ -164,7 +248,7 @@ namespace
|
||||
aContext->ShaderManager()->UpdateClippingState();
|
||||
|
||||
// render capping plane using the generated stencil mask
|
||||
aContext->SetColorMask (aColorMaskBack);
|
||||
glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
if (theWorkspace->UseDepthWrite())
|
||||
{
|
||||
glDepthMask (GL_TRUE);
|
||||
@@ -176,8 +260,69 @@ namespace
|
||||
glEnable (GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
theWorkspace->SetAspects (thePlane->AspectFace());
|
||||
renderPlane (theWorkspace, thePlane);
|
||||
const OpenGl_Aspects* aGroupAspectFace = aGroupIter.Value()->GlAspects();
|
||||
const OpenGl_CappingPlaneResource* aGroupAspectCapping = aGroupIter.Value()->AspectFillCapping();
|
||||
const OpenGl_CappingPlaneResource* anAspectCapping =
|
||||
thePlane && (!aGroupAspectCapping || aGroupAspectCapping->Aspect().IsNull() || aPlane->ToOverrideCappingAspect())
|
||||
? thePlane.get()
|
||||
: aGroupAspectCapping;
|
||||
|
||||
if (anAspectCapping == NULL)
|
||||
{
|
||||
anAspectCapping = THE_DEFAULT_ASPECT;
|
||||
}
|
||||
|
||||
const OpenGl_Aspects* anAspectFace = anAspectCapping->CappingFaceAspect (aGroupAspectFace);
|
||||
const Standard_Boolean hasHatch = anAspectCapping->Aspect()->ToDrawHatch();
|
||||
const OpenGl_Aspects* anAspectHatching = hasHatch ? anAspectCapping->HatchingFaceAspect() : NULL;
|
||||
const Standard_Boolean hasTextureHatch = hasHatch && !anAspectCapping->Aspect()->TextureHatch().IsNull();
|
||||
const Standard_Boolean isRotatePers = hasTextureHatch && !aCamera.IsNull() && anAspectCapping->Aspect()->IsHatchRotationPersistent();
|
||||
const Standard_Boolean isZoomPers = hasTextureHatch && !aCamera.IsNull() && anAspectCapping->Aspect()->IsHatchZoomPersistent();
|
||||
|
||||
Standard_ShortReal aHatchScale = 1.0;
|
||||
Standard_ShortReal aHatchAngle = 0.0;
|
||||
|
||||
if (isRotatePers || isZoomPers)
|
||||
{
|
||||
|
||||
if (isRotatePers)
|
||||
{
|
||||
if (aRotateAngle == 0.0)
|
||||
{
|
||||
const gp_Dir aPlaneSide (aPlaneMat.GetValue (0, 0), aPlaneMat.GetValue (1, 0), aPlaneMat.GetValue (2, 0));
|
||||
const gp_Dir aPlaneUp (aPlaneMat.GetValue (0, 2), aPlaneMat.GetValue (1, 2), aPlaneMat.GetValue (2, 2));
|
||||
const gp_Dir& aCameraUp = aCamera->Up();
|
||||
const gp_Vec aCameraPln = aPlaneSide.Dot (aCameraUp) * aPlaneSide + aPlaneUp.Dot (aCameraUp) * aPlaneUp;
|
||||
if (aCameraPln.Magnitude() > Precision::Confusion())
|
||||
{
|
||||
const gp_Dir& aCameraDir = aCamera->Direction();
|
||||
aRotateAngle = static_cast<Standard_ShortReal> (aCameraPln.AngleWithRef (aPlaneUp, aCameraDir) / M_PI * 180.0);
|
||||
}
|
||||
}
|
||||
|
||||
aHatchAngle = aRotateAngle;
|
||||
}
|
||||
|
||||
if (isZoomPers)
|
||||
{
|
||||
if (aViewScale == ShortRealLast())
|
||||
{
|
||||
const Standard_Real aFocus = aCamera->IsOrthographic()
|
||||
? aCamera->Distance()
|
||||
: (aCamera->ZFocusType() == Graphic3d_Camera::FocusType_Relative
|
||||
? Standard_Real(aCamera->ZFocus() * aCamera->Distance())
|
||||
: Standard_Real(aCamera->ZFocus()));
|
||||
|
||||
const gp_XYZ aViewDim = aCamera->ViewDimensions (aFocus);
|
||||
aViewScale = static_cast<Standard_ShortReal> (aViewDim.Y() / aContext->Viewport()[3]);
|
||||
}
|
||||
|
||||
if (!anAspectHatching->TextureSet(aContext)->IsEmpty())
|
||||
aHatchScale = 1.0f / (aViewScale * anAspectHatching->TextureSet(aContext)->First()->SizeY());
|
||||
}
|
||||
}
|
||||
|
||||
renderSection (theWorkspace, theQuad, anAspectFace, hasHatch ? anAspectCapping->HatchingFaceAspect() : NULL, aPlaneMat, aHatchScale, aHatchAngle);
|
||||
|
||||
// turn on the current plane to restore initial state
|
||||
aContext->ChangeClipping().ResetCappingFilter();
|
||||
@@ -187,7 +332,7 @@ namespace
|
||||
|
||||
if (theStructure.InstancedStructure() != NULL)
|
||||
{
|
||||
renderCappingForStructure (theStencilSentry, theWorkspace, *theStructure.InstancedStructure(), theClipChain, theSubPlaneIndex, thePlane);
|
||||
renderCappingForStructure (theStencilSentry, theWorkspace, *theStructure.InstancedStructure(), theClipChain, theSubPlaneIndex, thePlane, theQuad);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,6 +351,12 @@ void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)& theWorks
|
||||
return;
|
||||
}
|
||||
|
||||
const OpenGl_PrimitiveArray* aCappingQuad = initQuad (aContext);
|
||||
if (!aCappingQuad)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// remember current aspect face defined in workspace
|
||||
const OpenGl_Aspects* aFaceAsp = theWorkspace->Aspects();
|
||||
|
||||
@@ -214,6 +365,16 @@ void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)& theWorks
|
||||
theWorkspace->SetRenderFilter (aPrevFilter | OpenGl_RenderFilter_FillModeOnly);
|
||||
StencilTestSentry aStencilSentry;
|
||||
|
||||
GLboolean aPrevBlend = glIsEnabled (GL_BLEND);
|
||||
GLint aPrevBlendSrc = GL_ONE;
|
||||
GLint aPrevBlendDst = GL_ZERO;
|
||||
if (aPrevBlend == GL_TRUE)
|
||||
{
|
||||
glGetIntegerv (GL_BLEND_SRC_ALPHA, &aPrevBlendSrc);
|
||||
glGetIntegerv (GL_BLEND_DST_ALPHA, &aPrevBlendDst);
|
||||
glDisable (GL_BLEND);
|
||||
}
|
||||
|
||||
// generate capping for every clip plane
|
||||
for (OpenGl_ClippingIterator aCappingIt (aContext->Clipping()); aCappingIt.More(); aCappingIt.Next())
|
||||
{
|
||||
@@ -229,23 +390,33 @@ void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)& theWorks
|
||||
for (const Graphic3d_ClipPlane* aSubPlaneIter = aClipChain.get(); aSubPlaneIter != NULL; aSubPlaneIter = aSubPlaneIter->ChainNextPlane().get(), ++aSubPlaneIndex)
|
||||
{
|
||||
// get resource for the plane
|
||||
const TCollection_AsciiString& aResId = aSubPlaneIter->GetId();
|
||||
const TCollection_AsciiString& aResId = THE_PLANE_STYLE + aSubPlaneIter->GetId();
|
||||
Handle(OpenGl_CappingPlaneResource) aPlaneRes;
|
||||
if (!aContext->GetResource (aResId, aPlaneRes))
|
||||
{
|
||||
// share and register for release once the resource is no longer used
|
||||
aPlaneRes = new OpenGl_CappingPlaneResource (aSubPlaneIter);
|
||||
aPlaneRes = new OpenGl_CappingPlaneResource (aSubPlaneIter->CappingSectionStyle());
|
||||
aContext->ShareResource (aResId, aPlaneRes);
|
||||
}
|
||||
|
||||
renderCappingForStructure (aStencilSentry, theWorkspace, theStructure, aClipChain, aSubPlaneIndex, aPlaneRes);
|
||||
renderCappingForStructure (aStencilSentry, theWorkspace, theStructure, aClipChain, aSubPlaneIndex, aPlaneRes, aCappingQuad);
|
||||
|
||||
// set delayed resource release
|
||||
aPlaneRes.Nullify();
|
||||
aContext->ReleaseResource (aResId, Standard_True);
|
||||
if (!aResId.IsEmpty())
|
||||
{
|
||||
// schedule release of resource if not used
|
||||
aContext->ReleaseResource (aResId, Standard_True);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (aPrevBlend == GL_TRUE)
|
||||
{
|
||||
glEnable (GL_BLEND);
|
||||
glBlendFunc (aPrevBlendSrc, aPrevBlendDst);
|
||||
}
|
||||
|
||||
// restore rendering aspects
|
||||
theWorkspace->SetAspects (aFaceAsp);
|
||||
theWorkspace->SetRenderFilter (aPrevFilter);
|
||||
|
@@ -56,21 +56,28 @@ namespace
|
||||
{ 0.0f, 0.0f, 0.0f, 1.0f } }
|
||||
};
|
||||
|
||||
Handle(Graphic3d_Aspects) defaultMaterial()
|
||||
{
|
||||
Handle(Graphic3d_AspectFillArea3d) anAspect;
|
||||
const Graphic3d_MaterialAspect aMaterial (Graphic3d_NOM_DEFAULT);
|
||||
anAspect = new Graphic3d_AspectFillArea3d();
|
||||
anAspect->SetDistinguishOff();
|
||||
anAspect->SetFrontMaterial (aMaterial);
|
||||
anAspect->SetInteriorStyle (Aspect_IS_SOLID);
|
||||
anAspect->SetInteriorColor (aMaterial.Color());
|
||||
anAspect->SetSuppressBackFaces (false);
|
||||
return anAspect;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// =======================================================================
|
||||
// function : OpenGl_CappingPlaneResource
|
||||
// function : BuildInfinitPlaneVertices
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d_ClipPlane)& thePlane)
|
||||
: myPrimitives (NULL),
|
||||
myOrientation (OpenGl_IdentityMatrix),
|
||||
myAspect (NULL),
|
||||
myPlaneRoot (thePlane),
|
||||
myEquationMod ((unsigned int )-1),
|
||||
myAspectMod ((unsigned int )-1)
|
||||
OpenGl_PrimitiveArray* OpenGl_CappingPlaneResource::BuildInfinitPlaneVertices()
|
||||
{
|
||||
OpenGl_PrimitiveArray* aPrimitives = NULL;
|
||||
// Fill primitive array
|
||||
Handle(NCollection_AlignedAllocator) anAlloc = new NCollection_AlignedAllocator (16);
|
||||
Handle(Graphic3d_Buffer) anAttribs = new Graphic3d_Buffer (anAlloc);
|
||||
@@ -83,8 +90,26 @@ OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d
|
||||
if (anAttribs->Init (12, anAttribInfo, 3))
|
||||
{
|
||||
memcpy (anAttribs->ChangeData(), THE_CAPPING_PLN_VERTS, sizeof(THE_CAPPING_PLN_VERTS));
|
||||
myPrimitives.InitBuffers (NULL, Graphic3d_TOPA_TRIANGLES, NULL, anAttribs, NULL);
|
||||
|
||||
aPrimitives = new OpenGl_PrimitiveArray (NULL);
|
||||
aPrimitives->InitBuffers (NULL, Graphic3d_TOPA_TRIANGLES, NULL, anAttribs, NULL);
|
||||
}
|
||||
return aPrimitives;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OpenGl_CappingPlaneResource
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d_AspectFillCapping)& theAspect)
|
||||
: myCappingAspect(),//defaultMaterial()),
|
||||
myHatchingAspect(),//defaultMaterial()),
|
||||
myHatchingState (0)
|
||||
{
|
||||
myCappingAspect.SetAspect (defaultMaterial());
|
||||
myHatchingAspect.SetAspect (defaultMaterial());
|
||||
|
||||
SetAspect (theAspect);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -93,18 +118,83 @@ OpenGl_CappingPlaneResource::OpenGl_CappingPlaneResource (const Handle(Graphic3d
|
||||
// =======================================================================
|
||||
OpenGl_CappingPlaneResource::~OpenGl_CappingPlaneResource()
|
||||
{
|
||||
Release (NULL);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Update
|
||||
// function : SetAspect
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_CappingPlaneResource::Update (const Handle(OpenGl_Context)& theCtx,
|
||||
const Handle(Graphic3d_Aspects)& theObjAspect)
|
||||
void OpenGl_CappingPlaneResource::SetAspect (const Handle(Graphic3d_AspectFillCapping)& theAspect)
|
||||
{
|
||||
updateTransform (theCtx);
|
||||
updateAspect (theObjAspect);
|
||||
myAspect = theAspect;
|
||||
|
||||
if (theAspect.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!theAspect->ToUseObjectMaterial()
|
||||
|| !theAspect->ToUseObjectTexture()
|
||||
|| !theAspect->ToUseObjectShader())
|
||||
{
|
||||
Handle(Graphic3d_Aspects) aFillAspect = myCappingAspect.Aspect();
|
||||
|
||||
if (!theAspect->ToUseObjectMaterial())
|
||||
{
|
||||
aFillAspect->SetFrontMaterial (theAspect->Material());
|
||||
aFillAspect->SetInteriorColor (theAspect->Material().Color());
|
||||
}
|
||||
|
||||
if (!theAspect->ToUseObjectTexture())
|
||||
{
|
||||
aFillAspect->SetTextureMap (theAspect->Texture());
|
||||
|
||||
if (!theAspect->Texture().IsNull())
|
||||
{
|
||||
aFillAspect->SetTextureMapOn();
|
||||
}
|
||||
else
|
||||
{
|
||||
aFillAspect->SetTextureMapOff();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
aFillAspect->SetTextureMap (Handle(Graphic3d_TextureMap)());
|
||||
aFillAspect->SetTextureMapOff();
|
||||
}
|
||||
|
||||
if (!theAspect->ToUseObjectShader())
|
||||
{
|
||||
aFillAspect->SetShaderProgram (theAspect->Shader());
|
||||
}
|
||||
|
||||
myCappingAspect.SetAspect (aFillAspect);
|
||||
}
|
||||
|
||||
if (theAspect->ToDrawHatch()
|
||||
&& (theAspect->IsTextureHatch()
|
||||
|| theAspect->IsStippleHatch()))
|
||||
{
|
||||
Handle(Graphic3d_Aspects) aFillAspect = myHatchingAspect.Aspect();
|
||||
|
||||
aFillAspect->SetInteriorStyle (theAspect->IsStippleHatch() ? Aspect_IS_HATCH : Aspect_IS_SOLID);
|
||||
aFillAspect->SetHatchStyle (theAspect->IsStippleHatch() ? theAspect->StippleHatch() : Handle(Graphic3d_HatchStyle)());
|
||||
aFillAspect->SetTextureMap (theAspect->IsTextureHatch() ? theAspect->TextureHatch() : Handle(Graphic3d_TextureMap)());
|
||||
aFillAspect->SetFrontMaterial (theAspect->HatchMaterial());
|
||||
aFillAspect->SetInteriorColor (theAspect->HatchMaterial().Color());
|
||||
if (theAspect->IsTextureHatch())
|
||||
{
|
||||
aFillAspect->SetTextureMapOn();
|
||||
}
|
||||
else
|
||||
{
|
||||
aFillAspect->SetTextureMapOff();
|
||||
}
|
||||
|
||||
myHatchingAspect.SetAspect (aFillAspect);
|
||||
myHatchingState = theAspect->HatchingState();
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -113,123 +203,109 @@ void OpenGl_CappingPlaneResource::Update (const Handle(OpenGl_Context)& theCtx,
|
||||
// =======================================================================
|
||||
void OpenGl_CappingPlaneResource::Release (OpenGl_Context* theContext)
|
||||
{
|
||||
OpenGl_Element::Destroy (theContext, myAspect);
|
||||
myPrimitives.Release (theContext);
|
||||
myEquationMod = (unsigned int )-1;
|
||||
myAspectMod = (unsigned int )-1;
|
||||
myCappingAspect .Release (theContext);
|
||||
myHatchingAspect.Release (theContext);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : updateAspect
|
||||
// function : CappingFaceAspect
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_CappingPlaneResource::updateAspect (const Handle(Graphic3d_Aspects)& theObjAspect)
|
||||
const OpenGl_Aspects* OpenGl_CappingPlaneResource::CappingFaceAspect (const OpenGl_Aspects* theObjectAspect) const
|
||||
{
|
||||
if (myAspect == NULL)
|
||||
if (myAspect.IsNull())
|
||||
{
|
||||
myAspect = new OpenGl_Aspects();
|
||||
myAspectMod = myPlaneRoot->MCountAspect() - 1; // mark out of sync
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (theObjAspect.IsNull())
|
||||
{
|
||||
if (myAspectMod != myPlaneRoot->MCountAspect())
|
||||
{
|
||||
myAspect->SetAspect (myPlaneRoot->CappingAspect());
|
||||
myAspectMod = myPlaneRoot->MCountAspect();
|
||||
}
|
||||
return;
|
||||
}
|
||||
Handle(Graphic3d_Aspects) aFillAspect = myCappingAspect.Aspect();
|
||||
|
||||
if (myFillAreaAspect.IsNull())
|
||||
{
|
||||
myFillAreaAspect = new Graphic3d_AspectFillArea3d();
|
||||
}
|
||||
if (myAspectMod != myPlaneRoot->MCountAspect())
|
||||
{
|
||||
*myFillAreaAspect = *myPlaneRoot->CappingAspect();
|
||||
}
|
||||
|
||||
if (myPlaneRoot->ToUseObjectMaterial())
|
||||
if (myAspect->ToUseObjectMaterial() && theObjectAspect != NULL)
|
||||
{
|
||||
// only front material currently supported by capping rendering
|
||||
myFillAreaAspect->SetFrontMaterial (theObjAspect->FrontMaterial());
|
||||
myFillAreaAspect->SetInteriorColor (theObjAspect->InteriorColor());
|
||||
}
|
||||
if (myPlaneRoot->ToUseObjectTexture())
|
||||
{
|
||||
myFillAreaAspect->SetTextureSet (theObjAspect->TextureSet());
|
||||
if (theObjAspect->ToMapTexture())
|
||||
{
|
||||
myFillAreaAspect->SetTextureMapOn();
|
||||
}
|
||||
else
|
||||
{
|
||||
myFillAreaAspect->SetTextureMapOff();
|
||||
}
|
||||
}
|
||||
if (myPlaneRoot->ToUseObjectShader())
|
||||
{
|
||||
myFillAreaAspect->SetShaderProgram (theObjAspect->ShaderProgram());
|
||||
}
|
||||
|
||||
myAspect->SetAspect (myFillAreaAspect);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : updateTransform
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OpenGl_CappingPlaneResource::updateTransform (const Handle(OpenGl_Context)& theCtx)
|
||||
{
|
||||
if (myEquationMod == myPlaneRoot->MCountEquation()
|
||||
&& myLocalOrigin.IsEqual (theCtx->ShaderManager()->LocalOrigin(), gp::Resolution()))
|
||||
{
|
||||
return; // nothing to update
|
||||
}
|
||||
|
||||
myEquationMod = myPlaneRoot->MCountEquation();
|
||||
myLocalOrigin = theCtx->ShaderManager()->LocalOrigin();
|
||||
|
||||
const Graphic3d_ClipPlane::Equation& anEq = myPlaneRoot->GetEquation();
|
||||
const Standard_Real anEqW = theCtx->ShaderManager()->LocalClippingPlaneW (*myPlaneRoot);
|
||||
|
||||
// re-evaluate infinite plane transformation matrix
|
||||
const Graphic3d_Vec3 aNorm (anEq.xyz());
|
||||
const Graphic3d_Vec3 T (anEq.xyz() * -anEqW);
|
||||
|
||||
// project plane normal onto OX to find left vector
|
||||
const Standard_ShortReal aProjLen = sqrt ((Standard_ShortReal)anEq.xz().SquareModulus());
|
||||
Graphic3d_Vec3 aLeft;
|
||||
if (aProjLen < ShortRealSmall())
|
||||
{
|
||||
aLeft[0] = 1.0f;
|
||||
aFillAspect->SetFrontMaterial (theObjectAspect->Aspect()->FrontMaterial());
|
||||
aFillAspect->SetInteriorColor (theObjectAspect->Aspect()->InteriorColor());
|
||||
}
|
||||
else
|
||||
{
|
||||
aLeft[0] = aNorm[2] / aProjLen;
|
||||
aLeft[2] = -aNorm[0] / aProjLen;
|
||||
aFillAspect->SetFrontMaterial (myAspect->Material());
|
||||
aFillAspect->SetInteriorColor (myAspect->Material().Color());
|
||||
}
|
||||
|
||||
const Graphic3d_Vec3 F = Graphic3d_Vec3::Cross (-aLeft, aNorm);
|
||||
if (myAspect->ToUseObjectTexture() && theObjectAspect != NULL)
|
||||
{
|
||||
if (theObjectAspect->Aspect()->ToMapTexture())
|
||||
{
|
||||
aFillAspect->SetTextureMap (theObjectAspect->Aspect()->TextureMap());
|
||||
aFillAspect->SetTextureMapOn();
|
||||
}
|
||||
else
|
||||
{
|
||||
aFillAspect->SetTextureMapOff();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
aFillAspect->SetTextureMap (myAspect->Texture());
|
||||
if (!myAspect->Texture().IsNull())
|
||||
{
|
||||
aFillAspect->SetTextureMapOn();
|
||||
}
|
||||
else
|
||||
{
|
||||
aFillAspect->SetTextureMapOff();
|
||||
}
|
||||
}
|
||||
|
||||
myOrientation.mat[0][0] = aLeft[0];
|
||||
myOrientation.mat[0][1] = aLeft[1];
|
||||
myOrientation.mat[0][2] = aLeft[2];
|
||||
myOrientation.mat[0][3] = 0.0f;
|
||||
if (myAspect->ToUseObjectShader() && theObjectAspect != NULL)
|
||||
{
|
||||
aFillAspect->SetShaderProgram (theObjectAspect->Aspect()->ShaderProgram());
|
||||
}
|
||||
else
|
||||
{
|
||||
aFillAspect->SetShaderProgram (myAspect->Shader());
|
||||
}
|
||||
|
||||
myOrientation.mat[1][0] = aNorm[0];
|
||||
myOrientation.mat[1][1] = aNorm[1];
|
||||
myOrientation.mat[1][2] = aNorm[2];
|
||||
myOrientation.mat[1][3] = 0.0f;
|
||||
myCappingAspect.SetAspect (aFillAspect);
|
||||
|
||||
myOrientation.mat[2][0] = F[0];
|
||||
myOrientation.mat[2][1] = F[1];
|
||||
myOrientation.mat[2][2] = F[2];
|
||||
myOrientation.mat[2][3] = 0.0f;
|
||||
|
||||
myOrientation.mat[3][0] = T[0];
|
||||
myOrientation.mat[3][1] = T[1];
|
||||
myOrientation.mat[3][2] = T[2];
|
||||
myOrientation.mat[3][3] = 1.0f;
|
||||
return &myCappingAspect;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : HatchingFaceAspect
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
const OpenGl_Aspects* OpenGl_CappingPlaneResource::HatchingFaceAspect() const
|
||||
{
|
||||
if (myAspect.IsNull())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const Standard_Size aHatchingState = myAspect->HatchingState();
|
||||
if (myHatchingState != aHatchingState)
|
||||
{
|
||||
if (myAspect->ToDrawHatch())
|
||||
{
|
||||
Handle(Graphic3d_Aspects) aFillAspect = myHatchingAspect.Aspect();
|
||||
|
||||
aFillAspect->SetInteriorStyle (myAspect->IsStippleHatch() ? Aspect_IS_HATCH : Aspect_IS_SOLID);
|
||||
aFillAspect->SetHatchStyle (myAspect->IsStippleHatch() ? myAspect->StippleHatch() : Handle(Graphic3d_HatchStyle)());
|
||||
aFillAspect->SetTextureMap (myAspect->IsTextureHatch() ? myAspect->TextureHatch() : Handle(Graphic3d_TextureMap)());
|
||||
aFillAspect->SetFrontMaterial (myAspect->HatchMaterial());
|
||||
aFillAspect->SetInteriorColor (myAspect->HatchMaterial().Color());
|
||||
if (myAspect->IsTextureHatch())
|
||||
{
|
||||
aFillAspect->SetTextureMapOn();
|
||||
}
|
||||
else
|
||||
{
|
||||
aFillAspect->SetTextureMapOff();
|
||||
}
|
||||
myHatchingAspect.SetAspect (aFillAspect);
|
||||
myHatchingState = aHatchingState;
|
||||
}
|
||||
}
|
||||
|
||||
return &myHatchingAspect;
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@
|
||||
#include <OpenGl_Resource.hxx>
|
||||
#include <OpenGl_Aspects.hxx>
|
||||
#include <OpenGl_Matrix.hxx>
|
||||
#include <Graphic3d_ClipPlane.hxx>
|
||||
#include <Graphic3d_AspectFillCapping.hxx>
|
||||
|
||||
class OpenGl_CappingPlaneResource;
|
||||
DEFINE_STANDARD_HANDLE (OpenGl_CappingPlaneResource, OpenGl_Resource)
|
||||
@@ -30,25 +30,23 @@ DEFINE_STANDARD_HANDLE (OpenGl_CappingPlaneResource, OpenGl_Resource)
|
||||
//! This resource holds data necessary for OpenGl_CappingAlgo.
|
||||
//! This object is implemented as OpenGl resource for the following reasons:
|
||||
//! - one instance should be shared between contexts.
|
||||
//! - instance associated to Graphic3d_ClipPlane data by id.
|
||||
//! - instance associated to Graphic3d_AspectFillCapping data.
|
||||
//! - should created and released within context (owns OpenGl elements and resources).
|
||||
class OpenGl_CappingPlaneResource : public OpenGl_Resource
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor.
|
||||
//! Create capping plane presentation associated to clipping plane data.
|
||||
//! @param thePlane [in] the plane data.
|
||||
Standard_EXPORT OpenGl_CappingPlaneResource (const Handle(Graphic3d_ClipPlane)& thePlane);
|
||||
//! Create and assign style.
|
||||
Standard_EXPORT OpenGl_CappingPlaneResource (const Handle(Graphic3d_AspectFillCapping)& theAspect);
|
||||
|
||||
//! Destroy object.
|
||||
Standard_EXPORT virtual ~OpenGl_CappingPlaneResource();
|
||||
|
||||
//! Update resource data in the passed context.
|
||||
//! @param theContext [in] the context
|
||||
//! @param theObjAspect [in] object aspect
|
||||
Standard_EXPORT void Update (const Handle(OpenGl_Context)& theContext,
|
||||
const Handle(Graphic3d_Aspects)& theObjAspect);
|
||||
//! Assign section style.
|
||||
Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectFillCapping)& theAspect);
|
||||
|
||||
//! Returns section style parameters.
|
||||
const Handle(Graphic3d_AspectFillCapping)& Aspect() const { return myAspect; }
|
||||
|
||||
//! Release associated OpenGl resources.
|
||||
//! @param theContext [in] the resource context.
|
||||
@@ -57,17 +55,23 @@ public:
|
||||
//! Returns estimated GPU memory usage - not implemented.
|
||||
virtual Standard_Size EstimatedDataSize() const Standard_OVERRIDE { return 0; }
|
||||
|
||||
//! Return parent clipping plane structure.
|
||||
const Handle(Graphic3d_ClipPlane)& Plane() const { return myPlaneRoot; }
|
||||
|
||||
//! @return aspect face for rendering capping surface.
|
||||
inline const OpenGl_Aspects* AspectFace() const { return myAspect; }
|
||||
|
||||
//! @return evaluated orientation matrix to transform infinite plane.
|
||||
inline const OpenGl_Matrix* Orientation() const { return &myOrientation; }
|
||||
|
||||
//! @return primitive array of vertices to render infinite plane.
|
||||
inline const OpenGl_PrimitiveArray& Primitives() const { return myPrimitives; }
|
||||
static OpenGl_PrimitiveArray* BuildInfinitPlaneVertices();
|
||||
|
||||
//! Returns true if capping should draw hatch layer.
|
||||
Standard_Boolean ToDrawHatch() const
|
||||
{
|
||||
return myAspect->ToDrawHatch()
|
||||
&& (myAspect->IsStippleHatch()
|
||||
|| myAspect->IsTextureHatch());
|
||||
}
|
||||
|
||||
//! Returns the shading aspect for drawing face of a clipping section itself.
|
||||
//! @param theObjectAspect [in] the aspect of an object if it requires combining.
|
||||
Standard_EXPORT const OpenGl_Aspects* CappingFaceAspect (const OpenGl_Aspects* theObjectAspect) const;
|
||||
|
||||
//! Returns the shading aspect for drawing hatch layer of a section.
|
||||
Standard_EXPORT const OpenGl_Aspects* HatchingFaceAspect() const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -79,14 +83,11 @@ private:
|
||||
|
||||
private:
|
||||
|
||||
OpenGl_PrimitiveArray myPrimitives; //!< vertices and texture coordinates for rendering
|
||||
OpenGl_Matrix myOrientation; //!< plane transformation matrix.
|
||||
OpenGl_Aspects* myAspect; //!< capping face aspect.
|
||||
Handle(Graphic3d_ClipPlane) myPlaneRoot; //!< parent clipping plane structure.
|
||||
Handle(Graphic3d_Aspects) myFillAreaAspect;//!< own capping aspect
|
||||
gp_XYZ myLocalOrigin; //!< layer origin
|
||||
unsigned int myEquationMod; //!< modification counter for plane equation.
|
||||
unsigned int myAspectMod; //!< modification counter for aspect.
|
||||
Handle(Graphic3d_AspectFillCapping) myAspect; //!< Section style settings from application's level.
|
||||
mutable OpenGl_Aspects myCappingAspect; //!< GL aspect for shading base layer of a capping section.
|
||||
mutable OpenGl_Aspects myHatchingAspect; //!< GL aspect for shading hatching layer (additional to base) of a capping section.
|
||||
mutable Standard_Size myHatchingState;
|
||||
gp_XYZ myLocalOrigin; //!< layer origin
|
||||
|
||||
public:
|
||||
|
||||
|
@@ -31,7 +31,6 @@
|
||||
#include <OpenGl_FrameStats.hxx>
|
||||
#include <OpenGl_Sampler.hxx>
|
||||
#include <OpenGl_ShaderManager.hxx>
|
||||
#include <OpenGl_TextureSetPairIterator.hxx>
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
#include <OpenGl_Aspects.hxx>
|
||||
#include <Graphic3d_TransformUtils.hxx>
|
||||
@@ -1045,47 +1044,32 @@ void OpenGl_Context::ReadGlVersion (Standard_Integer& theGlVerMajor,
|
||||
theGlVerMajor = 0;
|
||||
theGlVerMinor = 0;
|
||||
|
||||
bool toCheckVer3 = true;
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
// WebGL 1.0 prints annoying invalid enumeration warnings to console.
|
||||
toCheckVer3 = false;
|
||||
if (EMSCRIPTEN_WEBGL_CONTEXT_HANDLE aWebGlCtx = emscripten_webgl_get_current_context())
|
||||
#ifdef GL_MAJOR_VERSION
|
||||
// available since OpenGL 3.0 and OpenGL 3.0 ES
|
||||
GLint aMajor = 0, aMinor = 0;
|
||||
glGetIntegerv (GL_MAJOR_VERSION, &aMajor);
|
||||
glGetIntegerv (GL_MINOR_VERSION, &aMinor);
|
||||
// glGetError() sometimes does not report an error here even if
|
||||
// GL does not know GL_MAJOR_VERSION and GL_MINOR_VERSION constants.
|
||||
// This happens on some renderers like e.g. Cygwin MESA.
|
||||
// Thus checking additionally if GL has put anything to
|
||||
// the output variables.
|
||||
if (::glGetError() == GL_NO_ERROR && aMajor != 0 && aMinor != 0)
|
||||
{
|
||||
EmscriptenWebGLContextAttributes anAttribs = {};
|
||||
if (emscripten_webgl_get_context_attributes (aWebGlCtx, &anAttribs) == EMSCRIPTEN_RESULT_SUCCESS)
|
||||
theGlVerMajor = aMajor;
|
||||
theGlVerMinor = aMinor;
|
||||
return;
|
||||
}
|
||||
for (GLenum anErr = ::glGetError(), aPrevErr = GL_NO_ERROR;; aPrevErr = anErr, anErr = ::glGetError())
|
||||
{
|
||||
if (anErr == GL_NO_ERROR
|
||||
|| anErr == aPrevErr)
|
||||
{
|
||||
toCheckVer3 = anAttribs.majorVersion >= 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Available since OpenGL 3.0 and OpenGL ES 3.0.
|
||||
if (toCheckVer3)
|
||||
{
|
||||
GLint aMajor = 0, aMinor = 0;
|
||||
glGetIntegerv (GL_MAJOR_VERSION, &aMajor);
|
||||
glGetIntegerv (GL_MINOR_VERSION, &aMinor);
|
||||
// glGetError() sometimes does not report an error here even if
|
||||
// GL does not know GL_MAJOR_VERSION and GL_MINOR_VERSION constants.
|
||||
// This happens on some renderers like e.g. Cygwin MESA.
|
||||
// Thus checking additionally if GL has put anything to
|
||||
// the output variables.
|
||||
if (::glGetError() == GL_NO_ERROR && aMajor != 0 && aMinor != 0)
|
||||
{
|
||||
theGlVerMajor = aMajor;
|
||||
theGlVerMinor = aMinor;
|
||||
return;
|
||||
}
|
||||
for (GLenum anErr = ::glGetError(), aPrevErr = GL_NO_ERROR;; aPrevErr = anErr, anErr = ::glGetError())
|
||||
{
|
||||
if (anErr == GL_NO_ERROR
|
||||
|| anErr == aPrevErr)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Read version string.
|
||||
// Notice that only first two numbers split by point '2.1 XXXXX' are significant.
|
||||
// Following trash (after space) is vendor-specific.
|
||||
@@ -3429,56 +3413,93 @@ Handle(OpenGl_TextureSet) OpenGl_Context::BindTextures (const Handle(OpenGl_Text
|
||||
if (myActiveTextures != theTextures)
|
||||
{
|
||||
Handle(OpenGl_Context) aThisCtx (this);
|
||||
for (OpenGl_TextureSetPairIterator aSlotIter (myActiveTextures, theTextures); aSlotIter.More(); aSlotIter.Next())
|
||||
OpenGl_TextureSet::Iterator aTextureIterOld (myActiveTextures), aTextureIterNew (theTextures);
|
||||
for (;;)
|
||||
{
|
||||
const Graphic3d_TextureUnit aTexUnit = aSlotIter.Unit();
|
||||
const OpenGl_Texture* aTextureOld = aSlotIter.Texture1();
|
||||
const OpenGl_Texture* aTextureNew = aSlotIter.Texture2();
|
||||
if (aTextureNew == aTextureOld)
|
||||
if (!aTextureIterNew.More())
|
||||
{
|
||||
continue;
|
||||
for (; aTextureIterOld.More(); aTextureIterOld.Next())
|
||||
{
|
||||
if (const Handle(OpenGl_Texture)& aTextureOld = aTextureIterOld.Value())
|
||||
{
|
||||
aTextureOld->Unbind (aThisCtx, aTextureIterOld.Unit());
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (core11 != NULL)
|
||||
{
|
||||
OpenGl_Sampler::resetGlobalTextureParams (aThisCtx, *aTextureOld, aTextureOld->Sampler()->Parameters());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (aTextureNew != NULL
|
||||
&& aTextureNew->IsValid())
|
||||
const Handle(OpenGl_Texture)& aTextureNew = aTextureIterNew.Value();
|
||||
if (aTextureIterOld.More())
|
||||
{
|
||||
if (aTexUnit >= myMaxTexCombined)
|
||||
const Handle(OpenGl_Texture)& aTextureOld = aTextureIterOld.Value();
|
||||
if (aTextureNew == aTextureOld
|
||||
&& aTextureIterNew.Unit() == aTextureIterOld.Unit())
|
||||
{
|
||||
PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
TCollection_AsciiString("Texture unit ") + aTexUnit + " for " + aTextureNew->ResourceId() + " exceeds hardware limit " + myMaxTexCombined);
|
||||
aTextureIterNew.Next();
|
||||
aTextureIterOld.Next();
|
||||
continue;
|
||||
}
|
||||
else if (aTextureNew.IsNull()
|
||||
|| !aTextureNew->IsValid())
|
||||
{
|
||||
if (!aTextureOld.IsNull())
|
||||
{
|
||||
aTextureOld->Unbind (aThisCtx, aTextureIterOld.Unit());
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (core11 != NULL)
|
||||
{
|
||||
OpenGl_Sampler::resetGlobalTextureParams (aThisCtx, *aTextureOld, aTextureOld->Sampler()->Parameters());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
aTextureIterNew.Next();
|
||||
aTextureIterOld.Next();
|
||||
continue;
|
||||
}
|
||||
|
||||
aTextureNew->Bind (aThisCtx, aTexUnit);
|
||||
if (aTextureNew->Sampler()->ToUpdateParameters())
|
||||
{
|
||||
if (aTextureNew->Sampler()->IsImmutable())
|
||||
{
|
||||
aTextureNew->Sampler()->Init (aThisCtx, *aTextureNew);
|
||||
}
|
||||
else
|
||||
{
|
||||
OpenGl_Sampler::applySamplerParams (aThisCtx, aTextureNew->Sampler()->Parameters(), aTextureNew->Sampler().get(), aTextureNew->GetTarget(), aTextureNew->HasMipmaps());
|
||||
}
|
||||
}
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (core11 != NULL)
|
||||
{
|
||||
OpenGl_Sampler::applyGlobalTextureParams (aThisCtx, *aTextureNew, aTextureNew->Sampler()->Parameters());
|
||||
}
|
||||
#endif
|
||||
aTextureIterOld.Next();
|
||||
}
|
||||
else if (aTextureOld != NULL
|
||||
&& aTextureOld->IsValid())
|
||||
if (aTextureNew.IsNull())
|
||||
{
|
||||
aTextureOld->Unbind (aThisCtx, aTexUnit);
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (core11 != NULL)
|
||||
{
|
||||
OpenGl_Sampler::resetGlobalTextureParams (aThisCtx, *aTextureOld, aTextureOld->Sampler()->Parameters());
|
||||
}
|
||||
#endif
|
||||
aTextureIterNew.Next();
|
||||
continue;
|
||||
}
|
||||
|
||||
const Graphic3d_TextureUnit aTexUnit = aTextureIterNew.Unit();
|
||||
if (aTexUnit >= myMaxTexCombined)
|
||||
{
|
||||
PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
|
||||
TCollection_AsciiString("Texture unit ") + aTexUnit + " for " + aTextureNew->ResourceId() + " exceeds hardware limit " + myMaxTexCombined);
|
||||
aTextureIterNew.Next();
|
||||
continue;
|
||||
}
|
||||
|
||||
aTextureNew->Bind (aThisCtx, aTexUnit);
|
||||
if (aTextureNew->Sampler()->ToUpdateParameters())
|
||||
{
|
||||
if (aTextureNew->Sampler()->IsImmutable())
|
||||
{
|
||||
aTextureNew->Sampler()->Init (aThisCtx, *aTextureNew);
|
||||
}
|
||||
else
|
||||
{
|
||||
OpenGl_Sampler::applySamplerParams (aThisCtx, aTextureNew->Sampler()->Parameters(), aTextureNew->Sampler().get(), aTextureNew->GetTarget(), aTextureNew->HasMipmaps());
|
||||
}
|
||||
}
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (core11 != NULL)
|
||||
{
|
||||
OpenGl_Sampler::applyGlobalTextureParams (aThisCtx, *aTextureNew, aTextureNew->Sampler()->Parameters());
|
||||
}
|
||||
#endif
|
||||
aTextureIterNew.Next();
|
||||
}
|
||||
myActiveTextures = theTextures;
|
||||
}
|
||||
|
@@ -495,16 +495,6 @@ public:
|
||||
//! Either GL_CLAMP_TO_EDGE (1.2+) or GL_CLAMP (1.1).
|
||||
Standard_Integer TextureWrapClamp() const { return myTexClamp; }
|
||||
|
||||
//! @return true if texture parameters GL_TEXTURE_BASE_LEVEL/GL_TEXTURE_MAX_LEVEL are supported.
|
||||
Standard_Boolean HasTextureBaseLevel() const
|
||||
{
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
return IsGlGreaterEqual (1, 2);
|
||||
#else
|
||||
return IsGlGreaterEqual (3, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
//! @return maximum degree of anisotropy texture filter
|
||||
Standard_Integer MaxDegreeOfAnisotropy() const { return myAnisoMax; }
|
||||
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#include <OpenGl_Workspace.hxx>
|
||||
|
||||
#include <Graphic3d_ArrayOfPrimitives.hxx>
|
||||
#include <Graphic3d_AspectFillCapping.hxx>
|
||||
#include <Graphic3d_GroupDefinitionError.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Group,Graphic3d_Group)
|
||||
@@ -90,6 +91,20 @@ void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_Aspects)& th
|
||||
return;
|
||||
}
|
||||
|
||||
if (!theAspect.IsNull() && theAspect->IsKind (STANDARD_TYPE(Graphic3d_AspectFillCapping)))
|
||||
{
|
||||
Handle(Graphic3d_AspectFillCapping) aFillCappingAspect = Handle(Graphic3d_AspectFillCapping)::DownCast (theAspect);
|
||||
if (myAspectFillCapping == NULL)
|
||||
{
|
||||
myAspectFillCapping = new OpenGl_CappingPlaneResource (aFillCappingAspect);
|
||||
}
|
||||
else
|
||||
{
|
||||
myAspectFillCapping->SetAspect (aFillCappingAspect);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (myAspects == NULL)
|
||||
{
|
||||
myAspects = new OpenGl_Aspects (theAspect);
|
||||
|
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <NCollection_List.hxx>
|
||||
#include <OpenGl_Aspects.hxx>
|
||||
#include <OpenGl_CappingPlaneResource.hxx>
|
||||
#include <OpenGl_Element.hxx>
|
||||
|
||||
class OpenGl_Group;
|
||||
@@ -99,6 +100,17 @@ public:
|
||||
//! Is the group ray-tracable (contains ray-tracable elements)?
|
||||
Standard_Boolean IsRaytracable() const { return myIsRaytracable; }
|
||||
|
||||
//! Returns section style aspect.
|
||||
virtual Handle(Graphic3d_AspectFillCapping) FillCappingAspect() const Standard_OVERRIDE
|
||||
{
|
||||
return myAspectFillCapping != NULL
|
||||
? myAspectFillCapping->Aspect()
|
||||
: Handle(Graphic3d_AspectFillCapping)();
|
||||
}
|
||||
|
||||
//! Returns OpenGL capping filling aspect.
|
||||
const OpenGl_CappingPlaneResource* AspectFillCapping() const { return myAspectFillCapping; }
|
||||
|
||||
//! Dumps the content of me into the stream
|
||||
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||
|
||||
@@ -109,6 +121,7 @@ protected:
|
||||
protected:
|
||||
|
||||
OpenGl_Aspects* myAspects;
|
||||
OpenGl_CappingPlaneResource* myAspectFillCapping;
|
||||
OpenGl_ElementNode* myFirst;
|
||||
OpenGl_ElementNode* myLast;
|
||||
Standard_Boolean myIsRaytracable;
|
||||
|
@@ -263,8 +263,8 @@ void OpenGl_Sampler::applySamplerParams (const Handle(OpenGl_Context)& theCtx,
|
||||
setParameter (theCtx, theSampler, theTarget, GL_TEXTURE_MAX_ANISOTROPY_EXT, aDegree);
|
||||
}
|
||||
|
||||
if (theCtx->HasTextureBaseLevel()
|
||||
&& (theSampler == NULL || !theSampler->isValidSampler()))
|
||||
if (theCtx->IsGlGreaterEqual(1, 2) &&
|
||||
(theSampler == NULL || !theSampler->isValidSampler()))
|
||||
{
|
||||
setParameter (theCtx, theSampler, theTarget, GL_TEXTURE_BASE_LEVEL, theParams->BaseLevel());
|
||||
setParameter (theCtx, theSampler, theTarget, GL_TEXTURE_MAX_LEVEL, theParams->MaxLevel());
|
||||
|
@@ -20,7 +20,6 @@
|
||||
class OpenGl_Texture;
|
||||
|
||||
//! Class holding array of textures to be mapped as a set.
|
||||
//! Textures should be defined in ascending order of texture units within the set.
|
||||
class OpenGl_TextureSet : public Standard_Transient
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(OpenGl_TextureSet, Standard_Transient)
|
||||
@@ -100,18 +99,12 @@ public:
|
||||
//! Return the first texture.
|
||||
Handle(OpenGl_Texture)& ChangeFirst() { return myTextures.ChangeFirst().Texture; }
|
||||
|
||||
//! Return the first texture unit.
|
||||
Graphic3d_TextureUnit FirstUnit() const { return myTextures.First().Unit; }
|
||||
|
||||
//! Return the last texture.
|
||||
const Handle(OpenGl_Texture)& Last() const { return myTextures.Last().Texture; }
|
||||
|
||||
//! Return the last texture.
|
||||
Handle(OpenGl_Texture)& ChangeLast() { return myTextures.ChangeLast().Texture; }
|
||||
|
||||
//! Return the last texture unit.
|
||||
Graphic3d_TextureUnit LastUnit() const { return myTextures.Last().Unit; }
|
||||
|
||||
//! Return the last texture unit.
|
||||
Graphic3d_TextureUnit& ChangeLastUnit() { return myTextures.ChangeLast().Unit; }
|
||||
|
||||
|
@@ -1,104 +0,0 @@
|
||||
// Copyright (c) 2020 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _OpenGl_TextureSetPairIterator_Header
|
||||
#define _OpenGl_TextureSetPairIterator_Header
|
||||
|
||||
#include <OpenGl_TextureSet.hxx>
|
||||
|
||||
//! Class for iterating pair of texture sets through each defined texture slot.
|
||||
//! Note that iterator considers texture slots being in ascending order within OpenGl_TextureSet.
|
||||
class OpenGl_TextureSetPairIterator
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor.
|
||||
OpenGl_TextureSetPairIterator (const Handle(OpenGl_TextureSet)& theSet1,
|
||||
const Handle(OpenGl_TextureSet)& theSet2)
|
||||
: myIter1 (theSet1),
|
||||
myIter2 (theSet2),
|
||||
myTexture1 (NULL),
|
||||
myTexture2 (NULL),
|
||||
myUnitLower (IntegerLast()),
|
||||
myUnitUpper (IntegerFirst()),
|
||||
myUnitCurrent (0)
|
||||
{
|
||||
if (!theSet1.IsNull()
|
||||
&& !theSet1->IsEmpty())
|
||||
{
|
||||
myUnitLower = Min (myUnitLower, theSet1->FirstUnit());
|
||||
myUnitUpper = Max (myUnitUpper, theSet1->LastUnit());
|
||||
}
|
||||
if (!theSet2.IsNull()
|
||||
&& !theSet2->IsEmpty())
|
||||
{
|
||||
myUnitLower = Min (myUnitLower, theSet2->FirstUnit());
|
||||
myUnitUpper = Max (myUnitUpper, theSet2->LastUnit());
|
||||
}
|
||||
myUnitCurrent = myUnitLower;
|
||||
myTexture1 = (myIter1.More() && myIter1.Unit() == myUnitCurrent)
|
||||
? myIter1.ChangeValue().get()
|
||||
: NULL;
|
||||
myTexture2 = (myIter2.More() && myIter2.Unit() == myUnitCurrent)
|
||||
? myIter2.ChangeValue().get()
|
||||
: NULL;
|
||||
}
|
||||
|
||||
//! Return TRUE if there are more texture units to pass through.
|
||||
bool More() const { return myUnitCurrent <= myUnitUpper; }
|
||||
|
||||
//! Return current texture unit.
|
||||
Graphic3d_TextureUnit Unit() const { return (Graphic3d_TextureUnit )myUnitCurrent; }
|
||||
|
||||
//! Access texture from first texture set.
|
||||
const OpenGl_Texture* Texture1() const { return myTexture1; }
|
||||
|
||||
//! Access texture from second texture set.
|
||||
const OpenGl_Texture* Texture2() const { return myTexture2; }
|
||||
|
||||
//! Move iterator position to the next pair.
|
||||
void Next()
|
||||
{
|
||||
++myUnitCurrent;
|
||||
myTexture1 = myTexture2 = NULL;
|
||||
for (; myIter1.More(); myIter1.Next())
|
||||
{
|
||||
if (myIter1.Unit() >= myUnitCurrent)
|
||||
{
|
||||
myTexture1 = myIter1.Unit() == myUnitCurrent ? myIter1.ChangeValue().get() : NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (; myIter2.More(); myIter2.Next())
|
||||
{
|
||||
if (myIter2.Unit() >= myUnitCurrent)
|
||||
{
|
||||
myTexture2 = myIter2.Unit() == myUnitCurrent ? myIter2.ChangeValue().get() : NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
OpenGl_TextureSet::Iterator myIter1;
|
||||
OpenGl_TextureSet::Iterator myIter2;
|
||||
OpenGl_Texture* myTexture1;
|
||||
OpenGl_Texture* myTexture2;
|
||||
Standard_Integer myUnitLower;
|
||||
Standard_Integer myUnitUpper;
|
||||
Standard_Integer myUnitCurrent;
|
||||
|
||||
};
|
||||
|
||||
#endif //_OpenGl_TextureSetPairIterator_Header
|
@@ -15,6 +15,7 @@
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
|
||||
#include <Graphic3d_AspectFillArea3d.hxx>
|
||||
#include <Graphic3d_AspectFillCapping.hxx>
|
||||
#include <Graphic3d_AspectMarker3d.hxx>
|
||||
#include <Graphic3d_AspectText3d.hxx>
|
||||
#include <Prs3d_ArrowAspect.hxx>
|
||||
@@ -109,7 +110,9 @@ Prs3d_Drawer::Prs3d_Drawer()
|
||||
myHasOwnDimLengthModelUnits (Standard_False),
|
||||
myHasOwnDimAngleModelUnits (Standard_False),
|
||||
myHasOwnDimLengthDisplayUnits (Standard_False),
|
||||
myHasOwnDimAngleDisplayUnits (Standard_False)
|
||||
myHasOwnDimAngleDisplayUnits (Standard_False),
|
||||
|
||||
myHasOwnFillCappingAspect (Standard_False)
|
||||
{
|
||||
myDimensionModelUnits.SetLengthUnits ("m");
|
||||
myDimensionModelUnits.SetAngleUnits ("rad");
|
||||
@@ -431,6 +434,27 @@ void Prs3d_Drawer::SetDimensionAspect (const Handle(Prs3d_DimensionAspect)& theA
|
||||
myHasOwnDimensionAspect = !myDimensionAspect.IsNull();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : FillCappingAspect
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
|
||||
const Handle(Graphic3d_AspectFillCapping)& Prs3d_Drawer::FillCappingAspect()
|
||||
{
|
||||
return myFillCappingAspect;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetFillCappingAspect
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
|
||||
void Prs3d_Drawer::SetFillCappingAspect (const Handle(Graphic3d_AspectFillCapping)& theAspect)
|
||||
{
|
||||
myFillCappingAspect = theAspect;
|
||||
myHasOwnFillCappingAspect = !myFillCappingAspect.IsNull();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetDimLengthModelUnits
|
||||
// purpose :
|
||||
|
@@ -31,6 +31,7 @@
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <GeomAbs_Shape.hxx>
|
||||
|
||||
class Graphic3d_AspectFillCapping;
|
||||
class Prs3d_IsoAspect;
|
||||
class Prs3d_LineAspect;
|
||||
class Prs3d_TextAspect;
|
||||
@@ -792,6 +793,16 @@ public:
|
||||
//! the appearance of dimensions that overrides the one in the link.
|
||||
Standard_Boolean HasOwnDimensionAspect() const { return myHasOwnDimensionAspect; }
|
||||
|
||||
//! Returns style for filling capping section created by clipping planes.
|
||||
Standard_EXPORT const Handle(Graphic3d_AspectFillCapping)& FillCappingAspect();
|
||||
|
||||
//! Set style of filling capping section created by clipping planes.
|
||||
Standard_EXPORT void SetFillCappingAspect (const Handle(Graphic3d_AspectFillCapping)& theStyle);
|
||||
|
||||
//! Returns true if the drawer has its own attribute for
|
||||
//! the appearance of dimensions that overrides the one in the link.
|
||||
Standard_Boolean HasOwnFillCappingAspect() const { return myHasOwnFillCappingAspect; }
|
||||
|
||||
//! Sets dimension length model units for computing of dimension presentation.
|
||||
//! The method sets value owned by the drawer that will be used during
|
||||
//! visualization instead of the one set in link.
|
||||
@@ -984,6 +995,10 @@ protected:
|
||||
Prs3d_DimensionUnits myDimensionDisplayUnits;
|
||||
Standard_Boolean myHasOwnDimLengthDisplayUnits;
|
||||
Standard_Boolean myHasOwnDimAngleDisplayUnits;
|
||||
|
||||
Handle(Graphic3d_AspectFillCapping) myFillCappingAspect;
|
||||
Standard_Boolean myHasOwnFillCappingAspect;
|
||||
|
||||
};
|
||||
|
||||
Standard_DEPRECATED("Class name is deprecated - use Prs3d_Drawer instead")
|
||||
|
@@ -283,6 +283,7 @@ namespace
|
||||
static Standard_Boolean shadeFromShape (const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Handle(Graphic3d_AspectFillCapping)& theCappingStyle,
|
||||
const Standard_Boolean theHasTexels,
|
||||
const gp_Pnt2d& theUVOrigin,
|
||||
const gp_Pnt2d& theUVRepeat,
|
||||
@@ -298,6 +299,9 @@ namespace
|
||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePrs);
|
||||
aGroup->SetClosed (theIsClosed);
|
||||
aGroup->SetGroupPrimitivesAspect (theDrawer->ShadingAspect()->Aspect());
|
||||
if (!theCappingStyle.IsNull())
|
||||
aGroup->SetGroupPrimitivesAspect (theCappingStyle);
|
||||
|
||||
aGroup->AddPrimitiveArray (aPArray);
|
||||
return Standard_True;
|
||||
}
|
||||
@@ -517,11 +521,12 @@ void StdPrs_ShadedShape::ExploreSolids (const TopoDS_Shape& theShape,
|
||||
void StdPrs_ShadedShape::Add (const Handle(Prs3d_Presentation)& thePrs,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Handle(Graphic3d_AspectFillCapping)& theCappingStyle,
|
||||
const StdPrs_Volume theVolume)
|
||||
{
|
||||
gp_Pnt2d aDummy;
|
||||
StdPrs_ShadedShape::Add (thePrs, theShape, theDrawer,
|
||||
Standard_False, aDummy, aDummy, aDummy, theVolume);
|
||||
Standard_False, aDummy, aDummy, aDummy, theCappingStyle, theVolume);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -535,6 +540,7 @@ void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePrs,
|
||||
const gp_Pnt2d& theUVOrigin,
|
||||
const gp_Pnt2d& theUVRepeat,
|
||||
const gp_Pnt2d& theUVScale,
|
||||
const Handle(Graphic3d_AspectFillCapping)& theCappingStyle,
|
||||
const StdPrs_Volume theVolume)
|
||||
{
|
||||
if (theShape.IsNull())
|
||||
@@ -572,20 +578,20 @@ void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePrs,
|
||||
|
||||
if (aClosed.NbChildren() > 0)
|
||||
{
|
||||
shadeFromShape (aClosed, thePrs, theDrawer,
|
||||
shadeFromShape (aClosed, thePrs, theDrawer, theCappingStyle,
|
||||
theHasTexels, theUVOrigin, theUVRepeat, theUVScale, true);
|
||||
}
|
||||
|
||||
if (anOpened.NbChildren() > 0)
|
||||
{
|
||||
shadeFromShape (anOpened, thePrs, theDrawer,
|
||||
shadeFromShape (anOpened, thePrs, theDrawer, theCappingStyle,
|
||||
theHasTexels, theUVOrigin, theUVRepeat, theUVScale, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// if the shape type is not compound, composolid or solid, use autodetection back-facing filled
|
||||
shadeFromShape (theShape, thePrs, theDrawer,
|
||||
shadeFromShape (theShape, thePrs, theDrawer, theCappingStyle,
|
||||
theHasTexels, theUVOrigin, theUVRepeat, theUVScale,
|
||||
theVolume == StdPrs_Volume_Closed);
|
||||
}
|
||||
|
@@ -38,13 +38,25 @@ public:
|
||||
//! @param theVolumeType defines the way how to interpret input shapes - as Closed volumes (to activate back-face
|
||||
//! culling and capping plane algorithms), as Open volumes (shells or solids with holes)
|
||||
//! or to perform Autodetection (would split input shape into two groups)
|
||||
Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation, const TopoDS_Shape& theShape, const Handle(Prs3d_Drawer)& theDrawer, const StdPrs_Volume theVolume = StdPrs_Volume_Autodetection);
|
||||
Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Handle(Graphic3d_AspectFillCapping)& theCappingStyle = Handle(Graphic3d_AspectFillCapping)(),
|
||||
StdPrs_Volume theVolume = StdPrs_Volume_Autodetection);
|
||||
|
||||
//! Shades <theShape> with texture coordinates.
|
||||
//! @param theVolumeType defines the way how to interpret input shapes - as Closed volumes (to activate back-face
|
||||
//! culling and capping plane algorithms), as Open volumes (shells or solids with holes)
|
||||
//! or to perform Autodetection (would split input shape into two groups)
|
||||
Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation, const TopoDS_Shape& theShape, const Handle(Prs3d_Drawer)& theDrawer, const Standard_Boolean theHasTexels, const gp_Pnt2d& theUVOrigin, const gp_Pnt2d& theUVRepeat, const gp_Pnt2d& theUVScale, const StdPrs_Volume theVolume = StdPrs_Volume_Autodetection);
|
||||
Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Standard_Boolean theHasTexels,
|
||||
const gp_Pnt2d& theUVOrigin,
|
||||
const gp_Pnt2d& theUVRepeat,
|
||||
const gp_Pnt2d& theUVScale,
|
||||
const Handle(Graphic3d_AspectFillCapping)& theCappingStyle = Handle(Graphic3d_AspectFillCapping)(),
|
||||
const StdPrs_Volume theVolume = StdPrs_Volume_Autodetection);
|
||||
|
||||
//! Searches closed and unclosed subshapes in shape structure and puts them
|
||||
//! into two compounds for separate processing of closed and unclosed sub-shapes
|
||||
|
@@ -9276,6 +9276,371 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
//===============================================================================================
|
||||
//function : setCappingParams
|
||||
//purpose :
|
||||
//===============================================================================================
|
||||
static Standard_Boolean setCappingParams (const TCollection_AsciiString& theChangeArg,
|
||||
const Handle(Graphic3d_AspectFillCapping)& theCappingStyle,
|
||||
const char** theChangeArgs,
|
||||
Standard_Integer aNbChangeArgs,
|
||||
Standard_Integer& anArgIter)
|
||||
{
|
||||
if (theCappingStyle.IsNull())
|
||||
return Standard_False;
|
||||
|
||||
Standard_Boolean toEnable = Standard_True;
|
||||
if (theChangeArg == "-useobjectmaterial"
|
||||
|| theChangeArg == "-useobjectmat"
|
||||
|| theChangeArg == "-useobjmat"
|
||||
|| theChangeArg == "-useobjmaterial")
|
||||
{
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
if (ViewerTest::ParseOnOff (theChangeArgs[1], toEnable))
|
||||
{
|
||||
theCappingStyle->SetUseObjectMaterial (toEnable == Standard_True);
|
||||
anArgIter += 1;
|
||||
}
|
||||
}
|
||||
else if (theChangeArg == "-useobjecttexture"
|
||||
|| theChangeArg == "-useobjecttex"
|
||||
|| theChangeArg == "-useobjtexture"
|
||||
|| theChangeArg == "-useobjtex")
|
||||
{
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
if (ViewerTest::ParseOnOff (theChangeArgs[1], toEnable))
|
||||
{
|
||||
theCappingStyle->SetUseObjectTexture (toEnable == Standard_True);
|
||||
anArgIter += 1;
|
||||
}
|
||||
}
|
||||
else if (theChangeArg == "-useobjectshader"
|
||||
|| theChangeArg == "-useobjshader")
|
||||
{
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
if (ViewerTest::ParseOnOff (theChangeArgs[1], toEnable))
|
||||
{
|
||||
theCappingStyle->SetUseObjectShader (toEnable == Standard_True);
|
||||
anArgIter += 1;
|
||||
}
|
||||
}
|
||||
else if (theChangeArg == "-color"
|
||||
|| theChangeArg == "color")
|
||||
{
|
||||
Quantity_Color aColor;
|
||||
Standard_Integer aNbParsed = ViewerTest::ParseColor (aNbChangeArgs - 1,
|
||||
theChangeArgs + 1,
|
||||
aColor);
|
||||
if (aNbParsed == 0)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Graphic3d_MaterialAspect aMat = theCappingStyle->Material();
|
||||
aMat.SetAmbientColor (aColor);
|
||||
aMat.SetDiffuseColor (aColor);
|
||||
theCappingStyle->SetMaterial (aMat);
|
||||
anArgIter += aNbParsed;
|
||||
}
|
||||
else if ((theChangeArg == "-transparency"
|
||||
|| theChangeArg == "-transp")
|
||||
&& aNbChangeArgs >= 2)
|
||||
{
|
||||
TCollection_AsciiString aValStr (theChangeArgs[1]);
|
||||
if (aValStr.IsRealValue())
|
||||
{
|
||||
Graphic3d_MaterialAspect aMat = theCappingStyle->Material();
|
||||
aMat.SetTransparency ((float )aValStr.RealValue());
|
||||
theCappingStyle->SetMaterial (aMat);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Syntax error at '" << aValStr << "'\n";
|
||||
return Standard_False;
|
||||
}
|
||||
anArgIter += 1;
|
||||
}
|
||||
else if (theChangeArg == "-texname"
|
||||
|| theChangeArg == "texname")
|
||||
{
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
TCollection_AsciiString aTextureName (theChangeArgs[1]);
|
||||
Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName);
|
||||
if (!aTexture->IsDone())
|
||||
{
|
||||
theCappingStyle->SetTexture (Handle(Graphic3d_TextureMap)());
|
||||
}
|
||||
else
|
||||
{
|
||||
aTexture->EnableModulate();
|
||||
aTexture->EnableRepeat();
|
||||
theCappingStyle->SetTexture (aTexture.get());
|
||||
}
|
||||
anArgIter += 1;
|
||||
}
|
||||
else if (theChangeArg == "-texscale"
|
||||
|| theChangeArg == "texscale")
|
||||
{
|
||||
const Handle(Graphic3d_TextureMap)& aHatchTexture = theCappingStyle->Texture();
|
||||
|
||||
if (aHatchTexture.IsNull())
|
||||
{
|
||||
std::cout << "Error: no texture is set.\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
if (aNbChangeArgs < 3)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Standard_ShortReal aSx = (Standard_ShortReal)Draw::Atof (theChangeArgs[1]);
|
||||
Standard_ShortReal aSy = (Standard_ShortReal)Draw::Atof (theChangeArgs[2]);
|
||||
aHatchTexture->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy));
|
||||
anArgIter += 2;
|
||||
}
|
||||
else if (theChangeArg == "-texorigin"
|
||||
|| theChangeArg == "texorigin") // texture origin
|
||||
{
|
||||
const Handle(Graphic3d_TextureMap)& aHatchTexture = theCappingStyle->Texture();
|
||||
|
||||
if (aHatchTexture.IsNull())
|
||||
{
|
||||
std::cout << "Error: no texture is set.\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
if (aNbChangeArgs < 3)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Standard_ShortReal aTx = (Standard_ShortReal)Draw::Atof (theChangeArgs[1]);
|
||||
Standard_ShortReal aTy = (Standard_ShortReal)Draw::Atof (theChangeArgs[2]);
|
||||
|
||||
aHatchTexture->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy));
|
||||
anArgIter += 2;
|
||||
}
|
||||
else if (theChangeArg == "-texrotate"
|
||||
|| theChangeArg == "texrotate") // texture rotation
|
||||
{
|
||||
const Handle(Graphic3d_TextureMap)& aHatchTexture = theCappingStyle->Texture();
|
||||
|
||||
if (aHatchTexture.IsNull())
|
||||
{
|
||||
std::cout << "Error: no texture is set.\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Standard_ShortReal aRot = (Standard_ShortReal)Draw::Atof (theChangeArgs[1]);
|
||||
aHatchTexture->GetParams()->SetRotation (aRot);
|
||||
anArgIter += 1;
|
||||
}
|
||||
else if (theChangeArg == "-hatch"
|
||||
|| theChangeArg == "hatch")
|
||||
{
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
if (ViewerTest::ParseOnOff (theChangeArgs[1], toEnable))
|
||||
{
|
||||
theCappingStyle->SetToDrawHatch (toEnable == Standard_True);
|
||||
anArgIter += 1;
|
||||
}
|
||||
}
|
||||
else if (theChangeArg == "-hatchtexture"
|
||||
|| theChangeArg == "hatchtexture")
|
||||
{
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
TCollection_AsciiString aTextureName (theChangeArgs[1]);
|
||||
Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName);
|
||||
if (!aTexture->IsDone())
|
||||
{
|
||||
theCappingStyle->SetHatchStyle (Handle(Graphic3d_TextureMap)());
|
||||
}
|
||||
else
|
||||
{
|
||||
aTexture->EnableModulate();
|
||||
aTexture->EnableRepeat();
|
||||
theCappingStyle->SetHatchStyle (aTexture.get());
|
||||
theCappingStyle->SetToDrawHatch (true);
|
||||
}
|
||||
anArgIter += 1;
|
||||
}
|
||||
else if (theChangeArg == "-hatchstipple"
|
||||
|| theChangeArg == "hatchstipple")
|
||||
{
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theCappingStyle->SetHatchStyle ((Aspect_HatchStyle)Draw::Atoi (theChangeArgs[1]));
|
||||
theCappingStyle->SetToDrawHatch (true);
|
||||
anArgIter += 1;
|
||||
}
|
||||
else if (theChangeArg == "-hatchcolor"
|
||||
|| theChangeArg == "hatchcolor")
|
||||
{
|
||||
Quantity_Color aColor;
|
||||
Standard_Integer aNbParsed = ViewerTest::ParseColor (aNbChangeArgs - 1,
|
||||
theChangeArgs + 1,
|
||||
aColor);
|
||||
if (aNbParsed == 0)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Graphic3d_MaterialAspect aMat = theCappingStyle->HatchMaterial();
|
||||
aMat.SetAmbientColor (aColor);
|
||||
aMat.SetDiffuseColor (aColor);
|
||||
theCappingStyle->SetHatchMaterial (aMat);
|
||||
anArgIter += aNbParsed;
|
||||
}
|
||||
|
||||
else if (theChangeArg == "-hatchscale"
|
||||
|| theChangeArg == "hatchscale")
|
||||
{
|
||||
const Handle(Graphic3d_TextureMap)& aHatchTexture = theCappingStyle->TextureHatch();
|
||||
|
||||
if (aHatchTexture.IsNull())
|
||||
{
|
||||
std::cout << "Error: no texture is set.\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
if (aNbChangeArgs < 3)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Standard_ShortReal aSx = (Standard_ShortReal)Draw::Atof (theChangeArgs[1]);
|
||||
Standard_ShortReal aSy = (Standard_ShortReal)Draw::Atof (theChangeArgs[2]);
|
||||
aHatchTexture->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy));
|
||||
anArgIter += 2;
|
||||
}
|
||||
else if (theChangeArg == "-hatchorigin"
|
||||
|| theChangeArg == "hatchorigin") // texture origin
|
||||
{
|
||||
const Handle(Graphic3d_TextureMap)& aHatchTexture = theCappingStyle->TextureHatch();
|
||||
|
||||
if (aHatchTexture.IsNull())
|
||||
{
|
||||
std::cout << "Error: no texture is set.\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
if (aNbChangeArgs < 3)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Standard_ShortReal aTx = (Standard_ShortReal)Draw::Atof (theChangeArgs[1]);
|
||||
Standard_ShortReal aTy = (Standard_ShortReal)Draw::Atof (theChangeArgs[2]);
|
||||
|
||||
aHatchTexture->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy));
|
||||
anArgIter += 2;
|
||||
}
|
||||
else if (theChangeArg == "-hatchrotate"
|
||||
|| theChangeArg == "hatchrotate") // texture rotation
|
||||
{
|
||||
const Handle(Graphic3d_TextureMap)& aHatchTexture = theCappingStyle->TextureHatch();
|
||||
|
||||
if (aHatchTexture.IsNull())
|
||||
{
|
||||
std::cout << "Error: no texture is set.\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Standard_ShortReal aRot = (Standard_ShortReal)Draw::Atof (theChangeArgs[1]);
|
||||
aHatchTexture->GetParams()->SetRotation (aRot);
|
||||
anArgIter += 1;
|
||||
}
|
||||
else if (theChangeArg == "-hatchzoompers"
|
||||
|| theChangeArg == "hatchzoompers")
|
||||
{
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
if (ViewerTest::ParseOnOff (theChangeArgs[1], toEnable))
|
||||
{
|
||||
theCappingStyle->SetHatchZoomPeristent (toEnable == Standard_True);
|
||||
anArgIter += 1;
|
||||
}
|
||||
}
|
||||
else if (theChangeArg == "-hatchrotatepers"
|
||||
|| theChangeArg == "hatchrotatepers")
|
||||
{
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
if (ViewerTest::ParseOnOff (theChangeArgs[1], toEnable))
|
||||
{
|
||||
theCappingStyle->SetHatchRotationPeristent (toEnable == Standard_True);
|
||||
anArgIter += 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//===============================================================================================
|
||||
//function : VClipPlane
|
||||
//purpose :
|
||||
@@ -9572,70 +9937,6 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
|
||||
// just skip otherwise (old syntax)
|
||||
}
|
||||
}
|
||||
else if (aChangeArg == "-useobjectmaterial"
|
||||
|| aChangeArg == "-useobjectmat"
|
||||
|| aChangeArg == "-useobjmat"
|
||||
|| aChangeArg == "-useobjmaterial")
|
||||
{
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
|
||||
{
|
||||
aClipPlane->SetUseObjectMaterial (toEnable == Standard_True);
|
||||
anArgIter += 1;
|
||||
}
|
||||
}
|
||||
else if (aChangeArg == "-useobjecttexture"
|
||||
|| aChangeArg == "-useobjecttex"
|
||||
|| aChangeArg == "-useobjtexture"
|
||||
|| aChangeArg == "-useobjtex")
|
||||
{
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
|
||||
{
|
||||
aClipPlane->SetUseObjectTexture (toEnable == Standard_True);
|
||||
anArgIter += 1;
|
||||
}
|
||||
}
|
||||
else if (aChangeArg == "-useobjectshader"
|
||||
|| aChangeArg == "-useobjshader")
|
||||
{
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
|
||||
{
|
||||
aClipPlane->SetUseObjectShader (toEnable == Standard_True);
|
||||
anArgIter += 1;
|
||||
}
|
||||
}
|
||||
else if (aChangeArg == "-color"
|
||||
|| aChangeArg == "color")
|
||||
{
|
||||
Quantity_Color aColor;
|
||||
Standard_Integer aNbParsed = ViewerTest::ParseColor (aNbChangeArgs - 1,
|
||||
aChangeArgs + 1,
|
||||
aColor);
|
||||
if (aNbParsed == 0)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return 1;
|
||||
}
|
||||
aClipPlane->SetCappingColor (aColor);
|
||||
anArgIter += aNbParsed;
|
||||
}
|
||||
else if (aNbChangeArgs >= 1
|
||||
&& (aChangeArg == "-material"
|
||||
|| aChangeArg == "material"))
|
||||
@@ -9647,53 +9948,10 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
|
||||
std::cout << "Syntax error: unknown material '" << aChangeArgs[1] << "'.\n";
|
||||
return 1;
|
||||
}
|
||||
aClipPlane->SetCappingMaterial (aMatName);
|
||||
//aClipPlane->SetCappingMaterial (aMatName);
|
||||
}
|
||||
else if ((aChangeArg == "-transparency"
|
||||
|| aChangeArg == "-transp")
|
||||
&& aNbChangeArgs >= 2)
|
||||
{
|
||||
TCollection_AsciiString aValStr (aChangeArgs[1]);
|
||||
Handle(Graphic3d_AspectFillArea3d) anAspect = aClipPlane->CappingAspect();
|
||||
if (aValStr.IsRealValue())
|
||||
{
|
||||
Graphic3d_MaterialAspect aMat = aClipPlane->CappingMaterial();
|
||||
aMat.SetTransparency ((float )aValStr.RealValue());
|
||||
anAspect->SetAlphaMode (Graphic3d_AlphaMode_BlendAuto);
|
||||
aClipPlane->SetCappingMaterial (aMat);
|
||||
}
|
||||
else
|
||||
{
|
||||
aValStr.LowerCase();
|
||||
Graphic3d_AlphaMode aMode = Graphic3d_AlphaMode_BlendAuto;
|
||||
if (aValStr == "opaque")
|
||||
{
|
||||
aMode = Graphic3d_AlphaMode_Opaque;
|
||||
}
|
||||
else if (aValStr == "mask")
|
||||
{
|
||||
aMode = Graphic3d_AlphaMode_Mask;
|
||||
}
|
||||
else if (aValStr == "blend")
|
||||
{
|
||||
aMode = Graphic3d_AlphaMode_Blend;
|
||||
}
|
||||
else if (aValStr == "blendauto")
|
||||
{
|
||||
aMode = Graphic3d_AlphaMode_BlendAuto;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Syntax error at '" << aValStr << "'\n";
|
||||
return 1;
|
||||
}
|
||||
anAspect->SetAlphaMode (aMode);
|
||||
aClipPlane->SetCappingAspect (anAspect);
|
||||
}
|
||||
anArgIter += 1;
|
||||
}
|
||||
else if (aChangeArg == "-texname"
|
||||
|| aChangeArg == "texname")
|
||||
else if (aChangeArg == "-overrideaspect"
|
||||
|| aChangeArg == "overrideaspect")
|
||||
{
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
@@ -9701,104 +9959,11 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
|
||||
return 1;
|
||||
}
|
||||
|
||||
TCollection_AsciiString aTextureName (aChangeArgs[1]);
|
||||
Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName);
|
||||
if (!aTexture->IsDone())
|
||||
if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
|
||||
{
|
||||
aClipPlane->SetCappingTexture (NULL);
|
||||
aClipPlane->SetToOverrideCappingAspect (toEnable == Standard_True);
|
||||
anArgIter += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
aTexture->EnableModulate();
|
||||
aTexture->EnableRepeat();
|
||||
aClipPlane->SetCappingTexture (aTexture);
|
||||
}
|
||||
anArgIter += 1;
|
||||
}
|
||||
else if (aChangeArg == "-texscale"
|
||||
|| aChangeArg == "texscale")
|
||||
{
|
||||
if (aClipPlane->CappingTexture().IsNull())
|
||||
{
|
||||
std::cout << "Error: no texture is set.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (aNbChangeArgs < 3)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_ShortReal aSx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
|
||||
Standard_ShortReal aSy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
|
||||
aClipPlane->CappingTexture()->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy));
|
||||
anArgIter += 2;
|
||||
}
|
||||
else if (aChangeArg == "-texorigin"
|
||||
|| aChangeArg == "texorigin") // texture origin
|
||||
{
|
||||
if (aClipPlane->CappingTexture().IsNull())
|
||||
{
|
||||
std::cout << "Error: no texture is set.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (aNbChangeArgs < 3)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_ShortReal aTx = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
|
||||
Standard_ShortReal aTy = (Standard_ShortReal)Draw::Atof (aChangeArgs[2]);
|
||||
|
||||
aClipPlane->CappingTexture()->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy));
|
||||
anArgIter += 2;
|
||||
}
|
||||
else if (aChangeArg == "-texrotate"
|
||||
|| aChangeArg == "texrotate") // texture rotation
|
||||
{
|
||||
if (aClipPlane->CappingTexture().IsNull())
|
||||
{
|
||||
std::cout << "Error: no texture is set.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_ShortReal aRot = (Standard_ShortReal)Draw::Atof (aChangeArgs[1]);
|
||||
aClipPlane->CappingTexture()->GetParams()->SetRotation (aRot);
|
||||
anArgIter += 1;
|
||||
}
|
||||
else if (aChangeArg == "-hatch"
|
||||
|| aChangeArg == "hatch")
|
||||
{
|
||||
if (aNbChangeArgs < 2)
|
||||
{
|
||||
std::cout << "Syntax error: need more arguments.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TCollection_AsciiString aHatchStr (aChangeArgs[1]);
|
||||
aHatchStr.LowerCase();
|
||||
if (aHatchStr == "on")
|
||||
{
|
||||
aClipPlane->SetCappingHatchOn();
|
||||
}
|
||||
else if (aHatchStr == "off")
|
||||
{
|
||||
aClipPlane->SetCappingHatchOff();
|
||||
}
|
||||
else
|
||||
{
|
||||
aClipPlane->SetCappingHatch ((Aspect_HatchStyle)Draw::Atoi (aChangeArgs[1]));
|
||||
}
|
||||
anArgIter += 1;
|
||||
}
|
||||
else if (aChangeArg == "-delete"
|
||||
|| aChangeArg == "delete")
|
||||
@@ -9876,7 +10041,7 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
|
||||
anArgIter = anArgIter + anIt - 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (!setCappingParams (aChangeArg, aClipPlane->CappingSectionStyle(), aChangeArgs, aNbChangeArgs, anArgIter))
|
||||
{
|
||||
std::cout << "Syntax error: unknown argument '" << aChangeArg << "'.\n";
|
||||
return 1;
|
||||
@@ -9887,6 +10052,69 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
|
||||
return 0;
|
||||
}
|
||||
|
||||
//===============================================================================================
|
||||
//function : VSetCapping
|
||||
//purpose :
|
||||
//===============================================================================================
|
||||
static int VSetCapping (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
|
||||
{
|
||||
if (theArgsNb < 2)
|
||||
{
|
||||
std::cout << "Syntax error: the wrong number of input parameters.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TCollection_AsciiString aName (theArgVec[1]);
|
||||
gp_Pln aWorkingPlane;
|
||||
Standard_Boolean toUpdate = Standard_True;
|
||||
|
||||
NCollection_DataMap<TCollection_AsciiString, Standard_Real> aRealParams;
|
||||
NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString> aStringParams;
|
||||
|
||||
Handle(AIS_InteractiveObject) anObject;
|
||||
if (GetMapOfAIS().Find2 (aName, anObject))
|
||||
{
|
||||
if (anObject.IsNull())
|
||||
{
|
||||
std::cout << "Syntax error: no presentation with this name.\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
Handle(Graphic3d_AspectFillCapping) aFillCapping = anObject->Attributes()->FillCappingAspect();
|
||||
for (Standard_Integer anArgIter = 2; anArgIter < theArgsNb; ++anArgIter)
|
||||
{
|
||||
const char** aChangeArgs = theArgVec + anArgIter;
|
||||
Standard_Integer aNbChangeArgs = theArgsNb - anArgIter;
|
||||
TCollection_AsciiString aChangeArg (aChangeArgs[0]);
|
||||
aChangeArg.LowerCase();
|
||||
|
||||
Standard_Boolean toEnable = Standard_True;
|
||||
if (ViewerTest::ParseOnOff (aChangeArgs[0], toEnable))
|
||||
{
|
||||
if (!toEnable)
|
||||
anObject->Attributes()->SetFillCappingAspect (NULL);
|
||||
else
|
||||
{
|
||||
if (aFillCapping.IsNull())
|
||||
{
|
||||
aFillCapping = new Graphic3d_AspectFillCapping();
|
||||
anObject->Attributes()->SetFillCappingAspect (aFillCapping);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!setCappingParams (aChangeArg, aFillCapping, aChangeArgs, aNbChangeArgs, anArgIter))
|
||||
{
|
||||
std::cout << "Syntax error: unknown argument '" << aChangeArg << "'.\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
ViewerTest::GetAISContext()->Redisplay (anObject, Standard_False);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//===============================================================================================
|
||||
//function : VZRange
|
||||
//purpose :
|
||||
@@ -14374,6 +14602,16 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
||||
"\n\t\t: [-color R G B] [-transparency Value] [-hatch {on|off|ID}]"
|
||||
"\n\t\t: [-texName Texture] [-texScale SX SY] [-texOrigin TX TY]"
|
||||
"\n\t\t: [-texRotate Angle]"
|
||||
/*"\n\t\t: [-overrideAspect {0|1}]"
|
||||
"\n\t\t: [-color R G B]"
|
||||
"\n\t\t: [-texture Texture] [-texScale SX SY]"
|
||||
"\n\t\t: [-texOrigin TX TY] [-texRotate Angle]"
|
||||
"\n\t\t: [-hatch {on|off}] [-hatchStipple mask]"
|
||||
"\n\t\t: [-hatchColor R G B] [-hatchTexture texture]"
|
||||
"\n\t\t: [-hatchScale SX SY] [-hatchOrigin TX TY]"
|
||||
"\n\t\t: [-hatchRotate Angle]"
|
||||
"\n\t\t: [-hatchZoomPers {0|1}]"
|
||||
"\n\t\t: [-hatchRotatePers {0|1}]"*/
|
||||
"\n\t\t: [-useObjMaterial {0|1}] [-useObjTexture {0|1}]"
|
||||
"\n\t\t: [-useObjShader {0|1}]"
|
||||
"\n\t\t: Clipping planes management:"
|
||||
@@ -14386,17 +14624,53 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
||||
"\n\t\t: -clone SourcePlane NewPlane clone the plane definition."
|
||||
"\n\t\t: Capping options:"
|
||||
"\n\t\t: -capping {off|on|0|1} turn capping on/off"
|
||||
"\n\t\t: -overrideAspect override presentation aspect (if defined)"
|
||||
"\n\t\t: -color R G B set capping color"
|
||||
"\n\t\t: -transparency Value set capping transparency 0..1"
|
||||
"\n\t\t: -texName Texture set capping texture"
|
||||
"\n\t\t: -texScale SX SY set capping tex scale"
|
||||
"\n\t\t: -texOrigin TX TY set capping tex origin"
|
||||
"\n\t\t: -texRotate Angle set capping tex rotation"
|
||||
"\n\t\t: -hatch {on|off|ID} set capping hatching mask"
|
||||
"\n\t\t: -hatch {on|off} turn on/off hatch style on capping"
|
||||
"\n\t\t: -hatchStipple ID set stipple mask for drawing hatch"
|
||||
"\n\t\t: -hatchColor R G B set color for hatch material"
|
||||
"\n\t\t: -hatchTexture Texture set texture (semi-opaque) for drawing hatch"
|
||||
"\n\t\t: -hatchScale SX SY set hatch texture scale"
|
||||
"\n\t\t: -hatchOrigin TX TY set hatch texture origin"
|
||||
"\n\t\t: -hatchRotate Angle set hatch texture rotation"
|
||||
"\n\t\t: -hatchZoomPers allow hatch tetxure mapping to be constant when zooming"
|
||||
"\n\t\t: -hatchRotatePers allow hatch tetxure mapping to be constant when rotating"
|
||||
"\n\t\t: -useObjMaterial {off|on|0|1} use material of clipped object"
|
||||
"\n\t\t: -useObjTexture {off|on|0|1} use texture of clipped object"
|
||||
"\n\t\t: -useObjShader {off|on|0|1} use shader program of object",
|
||||
__FILE__, VClipPlane, group);
|
||||
|
||||
theCommands.Add("vsetcapping",
|
||||
"vsetcapping name [{0|1}]"
|
||||
"\n\t\t: Sets capping parameters for all, selected or named objects."
|
||||
"\n\t\t: Capping options:"
|
||||
"\n\t\t: -capping {off|on|0|1} turn capping on/off"
|
||||
"\n\t\t: -overrideAspect override presentation aspect (if defined)"
|
||||
"\n\t\t: -color R G B set capping color"
|
||||
"\n\t\t: -transparency Value set capping transparency 0..1"
|
||||
"\n\t\t: -texName Texture set capping texture"
|
||||
"\n\t\t: -texScale SX SY set capping tex scale"
|
||||
"\n\t\t: -texOrigin TX TY set capping tex origin"
|
||||
"\n\t\t: -texRotate Angle set capping tex rotation"
|
||||
"\n\t\t: -hatch {on|off} turn on/off hatch style on capping"
|
||||
"\n\t\t: -hatchStipple ID set stipple mask for drawing hatch"
|
||||
"\n\t\t: -hatchColor R G B set color for hatch material"
|
||||
"\n\t\t: -hatchTexture Texture set texture (semi-opaque) for drawing hatch"
|
||||
"\n\t\t: -hatchScale SX SY set hatch texture scale"
|
||||
"\n\t\t: -hatchOrigin TX TY set hatch texture origin"
|
||||
"\n\t\t: -hatchRotate Angle set hatch texture rotation"
|
||||
"\n\t\t: -hatchZoomPers allow hatch tetxure mapping to be constant when zooming"
|
||||
"\n\t\t: -hatchRotatePers allow hatch tetxure mapping to be constant when rotating"
|
||||
"\n\t\t: -useObjMaterial {off|on|0|1} use material of clipped object"
|
||||
"\n\t\t: -useObjTexture {off|on|0|1} use texture of clipped object"
|
||||
"\n\t\t: -useObjShader {off|on|0|1} use shader program of object",
|
||||
__FILE__, VSetCapping, group);
|
||||
|
||||
theCommands.Add("vdefaults",
|
||||
"vdefaults [-absDefl value]"
|
||||
"\n\t\t: [-devCoeff value]"
|
||||
|
@@ -46,6 +46,7 @@ vclipplane change pln2 equation -0.707 0.707 0 -25
|
||||
vclipplane change pln2 capping on
|
||||
vclipplane change pln2 capping color 0.5 0.5 0.9
|
||||
vclipplane change pln2 capping hatch on
|
||||
vclipplane change pln2 capping hatchStipple 7
|
||||
vclipplane set pln2 object b3
|
||||
|
||||
checkcolor $x3_coord $y3_coord 0.5 0.5 0.9
|
||||
|
@@ -71,5 +71,5 @@ vdisplay pp1 pp2
|
||||
vzoom 0.8
|
||||
|
||||
puts "Enable capping planes"
|
||||
vclipplane pln1 -set -equation 0 0 -1 $aPln1Z -capping 1 -color 0.5 0.5 0.5 -texname $aHatch -texscale 0.02 -0.02 -useObjMaterial 1
|
||||
vclipplane pln2 -set -equation 0 1 0 [expr -$aPln2Y] -capping 1 -color 0.8 0.8 0.9 -texname $aHatch -texscale 0.02 -0.02
|
||||
vclipplane pln1 -set -equation 0 0 -1 $aPln1Z -capping 1 -color 0.5 0.5 0.5 -hatchtexture $aHatch -hatchscale 0.02 -0.02 -useObjMaterial 1
|
||||
vclipplane pln2 -set -equation 0 1 0 [expr -$aPln2Y] -capping 1 -color 0.8 0.8 0.9 -hatchtexture $aHatch -hatchscale 0.02 -0.02
|
||||
|
@@ -1,16 +0,0 @@
|
||||
puts "============="
|
||||
puts "0031315: Visualization - marker texture is lost after multi-textured object"
|
||||
puts "============="
|
||||
|
||||
pload MODELING VISUALIZATION
|
||||
vclear
|
||||
vinit View1
|
||||
box b 1 2 3
|
||||
vdisplay -dispMode 1 -highMode 1 b
|
||||
vtexture b -tex0 3 -tex1 4
|
||||
vfit
|
||||
vpoint p0 -1 0 0
|
||||
vaspects p0 -setMarkerSize 5
|
||||
if { [vreadpixel 15 310 -rgb -name] != "BLACK" } { puts "Error: Black color is expected" }
|
||||
|
||||
vdump ${imagedir}/${casename}.png
|