Graphic3d_ClipPlane - Graphic3d_AspectFillArea3d is now stored as class field.
OpenGl_CappingAlgo::RenderCapping() now handles special mode
preserving material from rendered object.
MeshVS_ElementalColorPrsBuilder::Build() now creates single primitives group
for triangles, thus Closed flag is correctly applied.
Redundant methods OpenGl_Structure::DrawGroups() and ::renderClosedGeometry()
have been removed.
Draw Harness, ViewerTest - vaspects now preserves display mode
and location when assigning sub-shape aspects.
The syntax of command vclipplane has been revised
(preserving compatibility with old syntax):
- Use "-param" style syntax for all arguments.
- Eliminate redundant arguments "change", "view", "object".
- Allow passing multiple parameters withing single call.
- Do not require "create" command - create new plane implicitly.
- "maxplanes" argument does not require view name anymore.
- "delete" does not throws TCL exception for non-existing plane.
- "view" argument without list now applies to active view.
- Handle * and ALL withing "delete" to remove all defined planes.
update test case bugs/vis/bug26028
Graphic3d_BufferType.hxx
Graphic3d_Camera.cxx
Graphic3d_Camera.hxx
+Graphic3d_CappingFlags.hxx
Graphic3d_CLight.hxx
Graphic3d_ClipPlane.cxx
Graphic3d_ClipPlane.hxx
--- /dev/null
+// Created on: 2016-08-04
+// Copyright (c) 2016 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_CappingFlags_HeaderFile
+#define _Graphic3d_CappingFlags_HeaderFile
+
+//! Enumeration of capping flags.
+enum Graphic3d_CappingFlags
+{
+ Graphic3d_CappingFlags_None = 0x0000, //!< no flags
+ Graphic3d_CappingFlags_ObjectMaterial = 0x0001, //!< use object material
+ Graphic3d_CappingFlags_ObjectTexture = 0x0002, //!< use object texture
+ Graphic3d_CappingFlags_ObjectShader = 0x0008, //!< use object GLSL program
+ Graphic3d_CappingFlags_ObjectAspect =
+ Graphic3d_CappingFlags_ObjectMaterial | Graphic3d_CappingFlags_ObjectTexture | Graphic3d_CappingFlags_ObjectShader //!< use entire fill area aspect from object
+};
+
+#endif // _Graphic3d_CappingFlags_HeaderFile
// commercial license or contractual agreement.
#include <Graphic3d_ClipPlane.hxx>
+
#include <Graphic3d_AspectFillArea3d.hxx>
#include <gp_Pln.hxx>
#include <Standard_Atomic.hxx>
-
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ClipPlane,Standard_Transient)
namespace
{
static volatile Standard_Integer THE_CLIP_PLANE_COUNTER = 0;
+
+ static Handle(Graphic3d_AspectFillArea3d) defaultAspect()
+ {
+ const Graphic3d_MaterialAspect aMaterial (Graphic3d_NOM_DEFAULT);
+ Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d();
+ anAspect->SetDistinguishOff();
+ anAspect->SetFrontMaterial (aMaterial);
+ anAspect->SetHatchStyle (Aspect_HS_HORIZONTAL);
+ anAspect->SetInteriorStyle (Aspect_IS_SOLID);
+ anAspect->SetInteriorColor (aMaterial.Color());
+ anAspect->SetSuppressBackFaces (false);
+ return anAspect;
+ }
}
// =======================================================================
// purpose :
// =======================================================================
Graphic3d_ClipPlane::Graphic3d_ClipPlane()
-: myEquation (0.0, 0.0, 1.0, 0.0),
+: myAspect (defaultAspect()),
+ myEquation (0.0, 0.0, 1.0, 0.0),
+ myFlags (Graphic3d_CappingFlags_None),
myIsOn (Standard_True),
myIsCapping (Standard_False),
- myMaterial (Graphic3d_NOM_DEFAULT),
- myHatch (Aspect_HS_HORIZONTAL),
- myHatchOn (Standard_False),
- myId(),
myEquationMod(0),
myAspectMod(0)
{
- MakeId();
+ makeId();
}
// =======================================================================
// purpose :
// =======================================================================
Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Equation& theEquation)
-: myEquation (theEquation),
+: myAspect (defaultAspect()),
+ myEquation (theEquation),
+ myFlags (Graphic3d_CappingFlags_None),
myIsOn (Standard_True),
myIsCapping (Standard_False),
- myMaterial (Graphic3d_NOM_DEFAULT),
- myHatch (Aspect_HS_HORIZONTAL),
- myHatchOn (Standard_False),
- myId(),
myEquationMod(0),
myAspectMod(0)
{
- MakeId();
+ makeId();
}
// =======================================================================
// =======================================================================
Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Graphic3d_ClipPlane& theOther)
: Standard_Transient(theOther),
+ myAspect (defaultAspect()),
myEquation (theOther.myEquation),
+ myFlags (theOther.myFlags),
myIsOn (theOther.myIsOn),
myIsCapping (theOther.myIsCapping),
- myMaterial (theOther.myMaterial),
- myTexture (theOther.myTexture),
- myHatch (theOther.myHatch),
- myHatchOn (theOther.myHatchOn),
- myId(),
myEquationMod (0),
myAspectMod (0)
{
- MakeId();
+ makeId();
+ *myAspect = *theOther.CappingAspect();
}
// =======================================================================
// purpose :
// =======================================================================
Graphic3d_ClipPlane::Graphic3d_ClipPlane(const gp_Pln& thePlane)
-: myEquation (),
+: myAspect (defaultAspect()),
+ myEquation (),
+ myFlags (Graphic3d_CappingFlags_None),
myIsOn (Standard_True),
myIsCapping (Standard_False),
- myMaterial (Graphic3d_NOM_DEFAULT),
- myHatch (Aspect_HS_HORIZONTAL),
- myHatchOn (Standard_False),
- myId(),
myEquationMod(0),
myAspectMod(0)
{
- MakeId();
+ makeId();
SetEquation (thePlane);
}
// =======================================================================
void Graphic3d_ClipPlane::SetCappingMaterial (const Graphic3d_MaterialAspect& theMat)
{
- myMaterial = theMat;
- myAspectMod++;
+ myAspect->SetFrontMaterial (theMat);
+ myAspect->SetInteriorColor (theMat.Color());
+ ++myAspectMod;
}
// =======================================================================
// =======================================================================
void Graphic3d_ClipPlane::SetCappingTexture (const Handle(Graphic3d_TextureMap)& theTexture)
{
- myTexture = theTexture;
- myAspectMod++;
+ myAspect->SetTextureMap (theTexture);
+ if (!theTexture.IsNull())
+ {
+ myAspect->SetTextureMapOn();
+ }
+ else
+ {
+ myAspect->SetTextureMapOff();
+ }
+ ++myAspectMod;
}
// =======================================================================
// =======================================================================
void Graphic3d_ClipPlane::SetCappingHatch (const Aspect_HatchStyle theStyle)
{
- myHatch = theStyle;
- myAspectMod++;
+ myAspect->SetHatchStyle (theStyle);
+ ++myAspectMod;
}
// =======================================================================
// =======================================================================
void Graphic3d_ClipPlane::SetCappingHatchOn()
{
- myHatchOn = Standard_True;
- myAspectMod++;
+ myAspect->SetInteriorStyle (Aspect_IS_HATCH);
+ ++myAspectMod;
}
// =======================================================================
// =======================================================================
void Graphic3d_ClipPlane::SetCappingHatchOff()
{
- myHatchOn = Standard_False;
- myAspectMod++;
+ myAspect->SetInteriorStyle (Aspect_IS_SOLID);
+ ++myAspectMod;
}
// =======================================================================
-// function : MakeId
+// function : SetCappingAspect
// purpose :
// =======================================================================
-void Graphic3d_ClipPlane::MakeId()
+void Graphic3d_ClipPlane::SetCappingAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect)
{
- myId = TCollection_AsciiString ("Graphic3d_ClipPlane_") //DynamicType()->Name()
- + TCollection_AsciiString (Standard_Atomic_Increment (&THE_CLIP_PLANE_COUNTER));
+ myAspect = theAspect;
+ ++myAspectMod;
}
// =======================================================================
-// function : CappingAspect
+// function : setCappingFlag
// purpose :
// =======================================================================
-Handle(Graphic3d_AspectFillArea3d) Graphic3d_ClipPlane::CappingAspect() const
+void Graphic3d_ClipPlane::setCappingFlag (bool theToUse, int theFlag)
{
- Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d();
- anAspect->SetDistinguishOff();
- anAspect->SetFrontMaterial (myMaterial);
- anAspect->SetTextureMap (myTexture);
- anAspect->SetHatchStyle (myHatch);
- anAspect->SetInteriorStyle (myHatchOn ? Aspect_IS_HATCH : Aspect_IS_SOLID);
- anAspect->SetInteriorColor (myMaterial.Color());
- anAspect->SetSuppressBackFaces (false);
- if (!myTexture.IsNull())
+ if (theToUse)
{
- anAspect->SetTextureMapOn();
+ myFlags |= theFlag;
}
else
{
- anAspect->SetTextureMapOff();
+ myFlags &= ~(theFlag);
}
- return anAspect;
+ ++myAspectMod;
+}
+
+// =======================================================================
+// function : makeId
+// purpose :
+// =======================================================================
+void Graphic3d_ClipPlane::makeId()
+{
+ myId = TCollection_AsciiString ("Graphic3d_ClipPlane_") //DynamicType()->Name()
+ + TCollection_AsciiString (Standard_Atomic_Increment (&THE_CLIP_PLANE_COUNTER));
}
#include <Standard_TypeDef.hxx>
#include <Standard_Transient.hxx>
#include <NCollection_Vec4.hxx>
-#include <Graphic3d_MaterialAspect.hxx>
+#include <Graphic3d_AspectFillArea3d.hxx>
+#include <Graphic3d_CappingFlags.hxx>
#include <Graphic3d_TextureMap.hxx>
#include <Aspect_HatchStyle.hxx>
class gp_Pln;
-class Graphic3d_AspectFillArea3d;
//! Container for properties describing graphic driver clipping planes.
//! It is up to application to create instances of this class and specify its
Standard_EXPORT void SetCappingMaterial (const Graphic3d_MaterialAspect& theMat);
//! @return capping material.
- const Graphic3d_MaterialAspect& CappingMaterial() const
- {
- return myMaterial;
- }
+ 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.
- const Handle(Graphic3d_TextureMap)& CappingTexture() const
- {
- return myTexture;
- }
+ const Handle(Graphic3d_TextureMap)& CappingTexture() const { return myAspect->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 myHatch;
- }
+ Aspect_HatchStyle CappingHatch() const { return myAspect->HatchStyle(); }
//! Turn on hatching.
Standard_EXPORT void SetCappingHatchOn();
Standard_EXPORT void SetCappingHatchOff();
//! @return True if hatching mask is turned on.
- Standard_Boolean IsHatchOn() const
- {
- return myHatchOn;
- }
+ 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
return myId;
}
- //! Compute and return capping aspect from the graphical attributes.
+public:
+
+ //! Return capping aspect.
//! @return capping surface rendering aspect.
- Standard_EXPORT Handle(Graphic3d_AspectFillArea3d) CappingAspect() const;
+ const Handle(Graphic3d_AspectFillArea3d)& CappingAspect() const { return myAspect; }
+
+ //! Assign capping aspect.
+ Standard_EXPORT void SetCappingAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect);
+
+ //! Flag indicating whether material for capping plane should be taken from object.
+ //! Default value: FALSE (use dedicated capping plane material).
+ bool ToUseObjectMaterial() const { return (myFlags & Graphic3d_CappingFlags_ObjectMaterial) != 0; }
+
+ //! Set flag for controlling the source of capping plane material.
+ void SetUseObjectMaterial (bool theToUse) { setCappingFlag (theToUse, Graphic3d_CappingFlags_ObjectMaterial); }
+
+ //! Flag indicating whether texture for capping plane should be taken from object.
+ //! Default value: FALSE.
+ bool ToUseObjectTexture() const { return (myFlags & Graphic3d_CappingFlags_ObjectTexture) != 0; }
+
+ //! Set flag for controlling the source of capping plane texture.
+ void SetUseObjectTexture (bool theToUse) { setCappingFlag (theToUse, Graphic3d_CappingFlags_ObjectTexture); }
+
+ //! Flag indicating whether shader program for capping plane should be taken from object.
+ //! Default value: FALSE.
+ bool ToUseObjectShader() const { return (myFlags & Graphic3d_CappingFlags_ObjectShader) != 0; }
+
+ //! Set flag for controlling the source of capping plane shader program.
+ void SetUseObjectShader(bool theToUse) { setCappingFlag (theToUse, Graphic3d_CappingFlags_ObjectShader); }
+
+ //! Return true if some fill area aspect properties should be taken from object.
+ bool ToUseObjectProperties() const { return myFlags != Graphic3d_CappingFlags_None; }
public: // @name modification counters
private:
- void MakeId();
+ //! Generate unique object id for OpenGL graphic resource manager.
+ void makeId();
+
+ //! Set capping flag.
+ Standard_EXPORT void setCappingFlag (bool theToUse, int theFlag);
private:
- Equation myEquation; //!< Plane equation vector.
- Standard_Boolean myIsOn; //!< State of the clipping plane.
- Standard_Boolean myIsCapping; //!< State of graphic driver capping.
- Graphic3d_MaterialAspect myMaterial; //!< Capping surface material.
- Handle(Graphic3d_TextureMap) myTexture; //!< Capping surface texture.
- Aspect_HatchStyle myHatch; //!< Capping surface hatch mask.
- Standard_Boolean myHatchOn; //!< Capping surface hatching flag.
- TCollection_AsciiString myId; //!< Resource id.
- unsigned int myEquationMod; //!< Modification counter for equation.
- unsigned int myAspectMod; //!< Modification counter of aspect.
+ Handle(Graphic3d_AspectFillArea3d) myAspect; //!< fill area aspect
+ TCollection_AsciiString myId; //!< resource id
+ Equation myEquation; //!< plane equation vector
+ unsigned int myFlags; //!< capping flags
+ Standard_Boolean myIsOn; //!< state of the clipping plane
+ Standard_Boolean myIsCapping; //!< state of graphic driver capping
+ unsigned int myEquationMod; //!< modification counter for equation
+ unsigned int myAspectMod; //!< modification counter of aspect
public:
}
// Draw elements with one color
- for ( MeshVS_DataMapIteratorOfDataMapOfColorMapOfInteger aColIter ( aColorsOfElements ); aColIter.More();
- aColIter.Next() )
+ Handle(Graphic3d_Group) aGGroup, aGroup2, aLGroup, aSGroup;
+ if (!aTwoColorsOfElements.IsEmpty())
{
- Standard_Integer aSize = aColIter.Value().Extent();
- if ( aSize<=0 )
+ aGroup2 = Prs3d_Root::NewGroup (Prs);
+ }
+ if (!aColorsOfElements.IsEmpty())
+ {
+ Handle(Graphic3d_AspectFillArea3d) aGroupFillAspect = new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID, anInteriorColor, anEdgeColor,
+ anEdgeType, anEdgeWidth, aMaterial[0], aMaterial[1]);
+ aGGroup = Prs3d_Root::NewGroup (Prs);
+ aLGroup = Prs3d_Root::NewGroup (Prs);
+ aGGroup->SetClosed (toSupressBackFaces == Standard_True);
+ aGGroup->SetGroupPrimitivesAspect (aGroupFillAspect);
+ }
+
+ if (anEdgeOn)
+ {
+ Handle(Graphic3d_AspectLine3d) anEdgeAspect = new Graphic3d_AspectLine3d (anEdgeColor, anEdgeType, anEdgeWidth);
+ aSGroup = Prs3d_Root::NewGroup (Prs);
+ aSGroup->SetGroupPrimitivesAspect (anEdgeAspect);
+ }
+
+ for (MeshVS_DataMapIteratorOfDataMapOfColorMapOfInteger aColIter (aColorsOfElements);
+ aColIter.More(); aColIter.Next())
+ {
+ if (aColIter.Value().IsEmpty())
+ {
continue;
+ }
TColStd_PackedMapOfInteger aCustomElements;
- Handle(Graphic3d_Group) aGGroup = Prs3d_Root::NewGroup (Prs);
- Handle(Graphic3d_Group) aLGroup = Prs3d_Root::NewGroup (Prs);
- Handle(Graphic3d_Group) aSGroup = Prs3d_Root::NewGroup (Prs);
-
Standard_Integer aNbFacePrimitives = 0;
Standard_Integer aNbVolmPrimitives = 0;
Standard_Integer aNbEdgePrimitives = 0;
Handle(Graphic3d_AspectLine3d) aLinkAspect =
new Graphic3d_AspectLine3d ( aColIter.Key(), aLineType, aLineWidth );
- Handle(Graphic3d_AspectLine3d) anEdgeAspect =
- new Graphic3d_AspectLine3d ( anEdgeColor, anEdgeType, anEdgeWidth );
-
aFillAspect->SetDistinguishOff ();
aFillAspect->SetInteriorColor ( aColIter.Key() );
aFillAspect->SetEdgeOff();
if (anEdgeOn)
{
aSGroup->AddPrimitiveArray (anEdgeSegments);
- aSGroup->SetGroupPrimitivesAspect (anEdgeAspect);
}
}
if (IsPolyL)
}
// Draw faces with two color
+ if (!aTwoColorsOfElements.IsEmpty())
+ {
+ Handle(Graphic3d_AspectFillArea3d) aGroupFillAspect2 = new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID, anInteriorColor, anEdgeColor,
+ anEdgeType, anEdgeWidth, aMaterial2[0], aMaterial2[1]);
+ aGroup2->SetClosed (Standard_False); // ignore toSupressBackFaces
+ aGroup2->SetGroupPrimitivesAspect (aGroupFillAspect2);
+ }
for ( MeshVS_DataMapIteratorOfDataMapOfTwoColorsMapOfInteger aColIter2 ( aTwoColorsOfElements );
aColIter2.More(); aColIter2.Next() )
{
- Handle(Graphic3d_Group) aGroup2 = Prs3d_Root::NewGroup (Prs);
- Handle(Graphic3d_Group) aGroup3 = Prs3d_Root::NewGroup (Prs);
-
- Standard_Integer aSize = aColIter2.Value().Extent();
- if ( aSize<=0 )
+ if (aColIter2.Value().IsEmpty())
+ {
continue;
+ }
Standard_Integer aNbFacePrimitives = 0;
Standard_Integer aNbEdgePrimitives = 0;
anAsp->SetEdgeOn();
else
anAsp->SetEdgeOff();*/
-
- Handle(Graphic3d_AspectLine3d) anEdgeAspect =
- new Graphic3d_AspectLine3d (anEdgeColor, anEdgeType, anEdgeWidth);
+ aGroup2->SetPrimitivesAspect (anAsp);
for( it.Reset(); it.More(); it.Next() )
{
}
}
- aGroup2->SetClosed (toSupressBackFaces == Standard_True);
aGroup2->AddPrimitiveArray (aFaceTriangles);
- aGroup2->SetGroupPrimitivesAspect (anAsp);
- aGroup3->AddPrimitiveArray (anEdgeSegments);
- aGroup3->SetGroupPrimitivesAspect (anEdgeAspect);
+ aSGroup->AddPrimitiveArray (anEdgeSegments);
}
}
static const GLint THE_FILLPRIM_FROM = GL_TRIANGLES;
static const GLint THE_FILLPRIM_TO = GL_TRIANGLE_FAN;
#endif
+
+ //! Render infinite capping plane.
+ //! @param theWorkspace [in] the GL workspace, context state.
+ //! @param thePlane [in] the graphical plane, for which the capping surface is rendered.
+ static void renderPlane (const Handle(OpenGl_Workspace)& theWorkspace,
+ const Handle(OpenGl_CappingPlaneResource)& thePlane,
+ const OpenGl_AspectFace* theAspectFace)
+ {
+ const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
+ thePlane->Update (aContext, theAspectFace != NULL ? theAspectFace->Aspect() : Handle(Graphic3d_AspectFillArea3d)());
+
+ const OpenGl_AspectFace* aFaceAspect = theWorkspace->AspectFace();
+ theWorkspace->SetAspectFace (thePlane->AspectFace());
+
+ // set identity model matrix
+ aContext->ModelWorldState.Push();
+ aContext->ModelWorldState.SetCurrent (OpenGl_Mat4::Map (*thePlane->Orientation()->mat));
+ aContext->ApplyModelViewMatrix();
+
+ thePlane->Primitives().Render (theWorkspace);
+
+ aContext->ModelWorldState.Pop();
+ aContext->ApplyModelViewMatrix();
+
+ theWorkspace->SetAspectFace (aFaceAspect);
+ }
+
+ //! Render capping for specific structure.
+ static void renderCappingForStructure (const Handle(OpenGl_Workspace)& theWorkspace,
+ const OpenGl_Structure& theStructure,
+ const Handle(OpenGl_CappingPlaneResource)& thePlane)
+ {
+ const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
+ const Graphic3d_SequenceOfHClipPlane& aContextPlanes = aContext->Clipping().Planes();
+ const Handle(Graphic3d_ClipPlane)& aRenderPlane = thePlane->Plane();
+ for (OpenGl_Structure::GroupIterator aGroupIter (theStructure.Groups()); aGroupIter.More(); aGroupIter.Next())
+ {
+ if (!aGroupIter.Value()->IsClosed())
+ {
+ continue;
+ }
+
+ // enable only the rendering plane to generate stencil mask
+ for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (aContextPlanes); aPlaneIt.More(); aPlaneIt.Next())
+ {
+ const Standard_Boolean isOn = (aPlaneIt.Value() == aRenderPlane);
+ aContext->ChangeClipping().SetEnabled (aContext, aPlaneIt.Value(), isOn);
+ }
+ aContext->ShaderManager()->UpdateClippingState();
+
+ glClear (GL_STENCIL_BUFFER_BIT);
+ glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
+
+ // override aspects, disable culling
+ theWorkspace->SetAspectFace (&theWorkspace->NoneCulling());
+ theWorkspace->ApplyAspectFace();
+
+ // evaluate number of pair faces
+ glDisable (GL_DEPTH_TEST);
+ glDepthMask (GL_FALSE);
+ glStencilFunc (GL_ALWAYS, 1, 0x01);
+ 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);
+ }
+ }
+ }
+
+ // override material, cull back faces
+ theWorkspace->SetAspectFace (&theWorkspace->FrontCulling());
+ theWorkspace->ApplyAspectFace();
+
+ // enable all clip plane except the rendered one
+ for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (aContextPlanes); aPlaneIt.More(); aPlaneIt.Next())
+ {
+ const Standard_Boolean isOn = (aPlaneIt.Value() != aRenderPlane);
+ aContext->ChangeClipping().SetEnabled (aContext, aPlaneIt.Value(), isOn);
+ }
+ aContext->ShaderManager()->UpdateClippingState();
+
+ // render capping plane using the generated stencil mask
+ glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+ glDepthMask (GL_TRUE);
+ glStencilFunc (GL_EQUAL, 1, 0x01);
+ glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP);
+ glEnable (GL_DEPTH_TEST);
+
+ renderPlane (theWorkspace, thePlane, aRenderPlane->ToUseObjectProperties()
+ ? aGroupIter.Value()->AspectFace()
+ : NULL);
+
+ aContext->ShaderManager()->RevertClippingState();
+ aContext->ShaderManager()->RevertClippingState();
+ }
+
+ if (theStructure.InstancedStructure() != NULL)
+ {
+ renderCappingForStructure (theWorkspace, *theStructure.InstancedStructure(), thePlane);
+ }
+ }
}
// =======================================================================
// check whether algorithm need to be performed
Standard_Boolean isCapping = Standard_False;
const Graphic3d_SequenceOfHClipPlane& aContextPlanes = aContext->Clipping().Planes();
- Graphic3d_SequenceOfHClipPlane::Iterator aCappingIt (aContextPlanes);
- for (; aCappingIt.More(); aCappingIt.Next())
+ for (Graphic3d_SequenceOfHClipPlane::Iterator aCappingIt (aContextPlanes); aCappingIt.More(); aCappingIt.Next())
{
const Handle(Graphic3d_ClipPlane)& aPlane = aCappingIt.Value();
if (aPlane->IsCapping())
glDepthFunc (GL_LESS);
// generate capping for every clip plane
- for (aCappingIt.Init (aContextPlanes); aCappingIt.More(); aCappingIt.Next())
+ for (Graphic3d_SequenceOfHClipPlane::Iterator aCappingIt (aContextPlanes); aCappingIt.More(); aCappingIt.Next())
{
// get plane being rendered
const Handle(Graphic3d_ClipPlane)& aRenderPlane = aCappingIt.Value();
continue;
}
- // enable only the rendering plane to generate stencil mask
- Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (aContextPlanes);
- for (; aPlaneIt.More(); aPlaneIt.Next())
+ // get resource for the plane
+ const TCollection_AsciiString& aResId = aRenderPlane->GetId();
+ Handle(OpenGl_CappingPlaneResource) aPlaneRes;
+ if (!aContext->GetResource (aResId, aPlaneRes))
{
- const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIt.Value();
- const Standard_Boolean isOn = (aPlane == aRenderPlane);
- aContext->ChangeClipping().SetEnabled (aContext, aPlane, isOn);
+ // share and register for release once the resource is no longer used
+ aPlaneRes = new OpenGl_CappingPlaneResource (aRenderPlane);
+ aContext->ShareResource (aResId, aPlaneRes);
}
- aContext->ShaderManager()->UpdateClippingState();
-
- glClear (GL_STENCIL_BUFFER_BIT);
- glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
-
- // override aspects, disable culling
- theWorkspace->SetAspectFace (&theWorkspace->NoneCulling());
- theWorkspace->ApplyAspectFace();
- // evaluate number of pair faces
- glDisable (GL_DEPTH_TEST);
- glDepthMask (GL_FALSE);
- glStencilFunc (GL_ALWAYS, 1, 0x01);
- glStencilOp (GL_KEEP, GL_INVERT, GL_INVERT);
-
- // render closed primitives
- theStructure.renderClosedGeometry (theWorkspace);
-
- // override material, cull back faces
- theWorkspace->SetAspectFace (&theWorkspace->FrontCulling());
- theWorkspace->ApplyAspectFace();
-
- // enable all clip plane except the rendered one
- for (aPlaneIt.Init (aContextPlanes); aPlaneIt.More(); aPlaneIt.Next())
- {
- const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIt.Value();
- const Standard_Boolean isOn = (aPlane != aRenderPlane);
- aContext->ChangeClipping().SetEnabled (aContext, aPlane, isOn);
- }
- aContext->ShaderManager()->UpdateClippingState();
+ renderCappingForStructure (theWorkspace, theStructure, aPlaneRes);
- // render capping plane using the generated stencil mask
- glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
- glDepthMask (GL_TRUE);
- glStencilFunc (GL_EQUAL, 1, 0x01);
- glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP);
- glEnable (GL_DEPTH_TEST);
-
- RenderPlane (theWorkspace, aRenderPlane);
-
- aContext->ShaderManager()->RevertClippingState();
- aContext->ShaderManager()->RevertClippingState();
+ // set delayed resource release
+ aPlaneRes.Nullify();
+ aContext->ReleaseResource (aResId, Standard_True);
}
// restore previous application state
glDisable (GL_STENCIL_TEST);
// enable clipping
- for (aCappingIt.Init (aContextPlanes); aCappingIt.More(); aCappingIt.Next())
+ for (Graphic3d_SequenceOfHClipPlane::Iterator aCappingIt (aContextPlanes); aCappingIt.More(); aCappingIt.Next())
{
aContext->ChangeClipping().SetEnabled (aContext, aCappingIt.Value(), Standard_True);
}
theWorkspace->SetRenderFilter (aRenderFilter);
}
-// =======================================================================
-// function : RenderPlane
-// purpose :
-// =======================================================================
-void OpenGl_CappingAlgo::RenderPlane (const Handle(OpenGl_Workspace)& theWorkspace,
- const Handle(Graphic3d_ClipPlane)& thePlane)
-{
- const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
-
- // get resource for the plane
- TCollection_AsciiString aResId = thePlane->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 (thePlane);
- aContext->ShareResource (aResId, aPlaneRes);
- }
-
- aPlaneRes->Update (aContext);
-
- const OpenGl_AspectFace* aFaceAspect = theWorkspace->AspectFace();
- const OpenGl_AspectFace* aPlaneAspect = aPlaneRes->AspectFace();
- if (aPlaneAspect != NULL)
- {
- theWorkspace->SetAspectFace (aPlaneAspect);
- }
-
- // set identity model matrix
- aContext->ModelWorldState.Push();
- aContext->ModelWorldState.SetCurrent (OpenGl_Mat4::Map (*aPlaneRes->Orientation()->mat));
- aContext->ApplyModelViewMatrix();
-
- aPlaneRes->Primitives().Render (theWorkspace);
-
- aContext->ModelWorldState.Pop();
- aContext->ApplyModelViewMatrix();
-
- theWorkspace->SetAspectFace (aFaceAspect);
-
- // set delayed resource release
- aPlaneRes.Nullify();
- aContext->ReleaseResource (aResId, Standard_True);
-}
-
// =======================================================================
// function : CanRender
// purpose :
// Forward declaration
class OpenGl_CappingAlgoFilter;
+class OpenGl_CappingPlaneResource;
class OpenGl_Structure;
+
DEFINE_STANDARD_HANDLE (OpenGl_CappingAlgoFilter, OpenGl_RenderFilter)
//! Capping surface rendering algorithm.
Standard_EXPORT static void RenderCapping (const Handle(OpenGl_Workspace)& theWorkspace,
const OpenGl_Structure& theStructure);
- //! 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.
- Standard_EXPORT static void RenderPlane (const Handle(OpenGl_Workspace)& theWorkspace,
- const Handle(Graphic3d_ClipPlane)& thePlane);
};
//! Graphical capping rendering algorithm filter.
// function : Update
// purpose :
// =======================================================================
-void OpenGl_CappingPlaneResource::Update (const Handle(OpenGl_Context)& theContext)
+void OpenGl_CappingPlaneResource::Update (const Handle(OpenGl_Context)& ,
+ const Handle(Graphic3d_AspectFillArea3d)& theObjAspect)
{
- UpdateTransform();
- UpdateAspect (theContext);
+ updateTransform();
+ updateAspect (theObjAspect);
}
// =======================================================================
}
// =======================================================================
-// function : UpdateAspect
+// function : updateAspect
// purpose :
// =======================================================================
-void OpenGl_CappingPlaneResource::UpdateAspect (const Handle(OpenGl_Context)& theContext)
+void OpenGl_CappingPlaneResource::updateAspect (const Handle(Graphic3d_AspectFillArea3d)& theObjAspect)
{
- Handle(Graphic3d_AspectFillArea3d) aCappingAsp = myPlaneRoot->CappingAspect();
- if (myAspect != NULL && !aCappingAsp.IsNull())
+ if (myAspect == NULL)
{
- if (myAspectMod == myPlaneRoot->MCountAspect())
- return; // noting to update
-
- myAspect->SetAspect (aCappingAsp);
- myAspectMod = myPlaneRoot->MCountAspect();
- return;
+ myAspect = new OpenGl_AspectFace();
+ myAspectMod = myPlaneRoot->MCountAspect() - 1; // mark out of sync
}
- // no more used
- if (myAspect != NULL && aCappingAsp.IsNull())
+ if (theObjAspect.IsNull())
{
- OpenGl_Element::Destroy (theContext.operator->(), myAspect);
- myAspectMod = myPlaneRoot->MCountAspect();
+ if (myAspectMod != myPlaneRoot->MCountAspect())
+ {
+ myAspect->SetAspect (myPlaneRoot->CappingAspect());
+ myAspectMod = myPlaneRoot->MCountAspect();
+ }
return;
}
- // first created
- if (myAspect == NULL && !aCappingAsp.IsNull())
+ if (myFillAreaAspect.IsNull())
{
- myAspect = new OpenGl_AspectFace();
- myAspect->SetAspect (aCappingAsp);
- myAspectMod = myPlaneRoot->MCountAspect();
+ myFillAreaAspect = new Graphic3d_AspectFillArea3d();
}
+ if (myAspectMod != myPlaneRoot->MCountAspect())
+ {
+ *myFillAreaAspect = *myPlaneRoot->CappingAspect();
+ }
+
+ if (myPlaneRoot->ToUseObjectMaterial())
+ {
+ // only front material currently supported by capping rendering
+ myFillAreaAspect->SetFrontMaterial (theObjAspect->FrontMaterial());
+ myFillAreaAspect->SetInteriorColor (theObjAspect->InteriorColor());
+ }
+ if (myPlaneRoot->ToUseObjectTexture())
+ {
+ if (theObjAspect->ToMapTexture())
+ {
+ myFillAreaAspect->SetTextureMap (theObjAspect->TextureMap());
+ myFillAreaAspect->SetTextureMapOn();
+ }
+ else
+ {
+ myFillAreaAspect->SetTextureMapOff();
+ }
+ }
+ if (myPlaneRoot->ToUseObjectShader())
+ {
+ myFillAreaAspect->SetShaderProgram (theObjAspect->ShaderProgram());
+ }
+
+ myAspect->SetAspect (myFillAreaAspect);
}
// =======================================================================
-// function : UpdateTransform
+// function : updateTransform
// purpose :
// =======================================================================
-void OpenGl_CappingPlaneResource::UpdateTransform()
+void OpenGl_CappingPlaneResource::updateTransform()
{
const Graphic3d_ClipPlane::Equation& anEquation = myPlaneRoot->GetEquation();
if (myEquationMod == myPlaneRoot->MCountEquation())
Standard_EXPORT virtual ~OpenGl_CappingPlaneResource();
//! Update resource data in the passed context.
- //! @param theContext [in] the context.
- Standard_EXPORT void Update (const Handle(OpenGl_Context)& theContext);
+ //! @param theContext [in] the context
+ //! @param theObjAspect [in] object aspect
+ Standard_EXPORT void Update (const Handle(OpenGl_Context)& theContext,
+ const Handle(Graphic3d_AspectFillArea3d)& theObjAspect);
//! Release associated OpenGl resources.
//! @param theContext [in] the resource context.
Standard_EXPORT virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE;
+ //! Return parent clipping plane structure.
+ const Handle(Graphic3d_ClipPlane)& Plane() const { return myPlaneRoot; }
+
//! @return aspect face for rendering capping surface.
inline const OpenGl_AspectFace* AspectFace() const { return myAspect; }
private:
//! Update precomputed plane orientation matrix.
- void UpdateTransform();
+ void updateTransform();
//! Update resources.
- //! @param theContext [in] the context.
- void UpdateAspect (const Handle(OpenGl_Context)& theContext);
+ void updateAspect (const Handle(Graphic3d_AspectFillArea3d)& theObjAspect);
private:
OpenGl_Matrix myOrientation; //!< plane transformation matrix.
OpenGl_AspectFace* myAspect; //!< capping face aspect.
Handle(Graphic3d_ClipPlane) myPlaneRoot; //!< parent clipping plane structure.
+ Handle(Graphic3d_AspectFillArea3d) myFillAreaAspect; //!< own capping aspect
unsigned int myEquationMod; //!< modification counter for plane equation.
unsigned int myAspectMod; //!< modification counter for aspect.
}
return Standard_False;
}
-
- // =======================================================================
- // function : IsRaytracedStructure
- // purpose : Checks to see if the structure contains ray-trace geometry
- // =======================================================================
- Standard_Boolean IsRaytracedStructure (const OpenGl_Structure* theStructure)
- {
- for (OpenGl_Structure::GroupIterator anIter (theStructure->DrawGroups()); anIter.More(); anIter.Next())
- {
- if (anIter.Value()->IsRaytracable())
- {
- return Standard_True;
- }
- }
- return Standard_False;
- }
}
//! Checks to see if the element contains ray-trace geometry.
Standard_Boolean IsRaytracedElement (const OpenGl_Element* theElement);
-
- //! Checks to see if the structure contains ray-trace geometry.
- Standard_Boolean IsRaytracedStructure (const OpenGl_Structure* theStructure);
}
//! Stores properties of surface material.
// =======================================================================
Standard_Boolean OpenGl_Structure::IsRaytracable() const
{
- if (!myGroups.IsEmpty())
+ if (!myGroups.IsEmpty()
+ && myIsRaytracable)
{
- return myIsRaytracable; // geometry structure
- }
- else if (myInstancedStructure != NULL)
- {
- return myInstancedStructure->IsRaytracable(); // instance structure
+ return Standard_True;
}
- return Standard_False; // has no any groups or structures
+ return myInstancedStructure != NULL
+ && myInstancedStructure->IsRaytracable();
}
// =======================================================================
// =======================================================================
void OpenGl_Structure::UpdateStateIfRaytracable (const Standard_Boolean toCheck) const
{
- myIsRaytracable = !toCheck || OpenGl_Raytrace::IsRaytracedStructure (this);
+ myIsRaytracable = !toCheck;
+ if (!myIsRaytracable)
+ {
+ for (OpenGl_Structure::GroupIterator anIter (myGroups); anIter.More(); anIter.Next())
+ {
+ if (anIter.Value()->IsRaytracable())
+ {
+ myIsRaytracable = Standard_True;
+ break;
+ }
+ }
+ }
if (IsRaytracable())
{
}
}
-// =======================================================================
-// function : renderClosedGeometry
-// purpose :
-// =======================================================================
-void OpenGl_Structure::renderClosedGeometry (const Handle(OpenGl_Workspace)& theWorkspace) const
-{
- if (myInstancedStructure != NULL)
- {
- myInstancedStructure->renderClosedGeometry (theWorkspace);
- }
-
- for (OpenGl_Structure::GroupIterator aGroupIter (myGroups); aGroupIter.More(); aGroupIter.Next())
- {
- if (aGroupIter.Value()->IsClosed())
- {
- aGroupIter.Value()->Render (theWorkspace);
- }
- }
-}
-
// =======================================================================
// function : Render
// purpose :
public:
- //! @return graphic groups
- virtual const Graphic3d_SequenceOfGroup& DrawGroups() const
- {
- return myGroups;
- }
-
//! Access graphic driver
OpenGl_GraphicDriver* GlDriver() const
{
Standard_EXPORT void Clear (const Handle(OpenGl_Context)& theGlCtx);
- //! Renders groups of structure without applying any attributes (i.e. transform, material etc).
- //! @param theWorkspace current workspace
- //! @param theHasClosed flag will be set to TRUE if structure contains at least one group of closed primitives
- virtual void renderGeometry (const Handle(OpenGl_Workspace)& theWorkspace,
- bool& theHasClosed) const;
-
- //! Renders groups of closed primitives without applying any attributes (i.e. transform, material etc).
- virtual void renderClosedGeometry (const Handle(OpenGl_Workspace)& theWorkspace) const;
-
//! Renders the structure.
virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
//! Updates ray-tracable status for structure and its parents.
void UpdateStateIfRaytracable (const Standard_Boolean toCheck = Standard_True) const;
+ //! Renders groups of structure without applying any attributes (i.e. transform, material etc).
+ //! @param theWorkspace current workspace
+ //! @param theHasClosed flag will be set to TRUE if structure contains at least one group of closed primitives
+ Standard_EXPORT void renderGeometry (const Handle(OpenGl_Workspace)& theWorkspace,
+ bool& theHasClosed) const;
+
protected:
Handle(OpenGl_Group) myHighlightBox;
#include <OpenGl_StructureShadow.hxx>
#include <Graphic3d_GraphicDriver.hxx>
+#include <Standard_ProgramError.hxx>
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_StructureShadow,OpenGl_Structure)
UpdateTransformation();
myInstancedStructure = const_cast<OpenGl_Structure*> (myParent->InstancedStructure());
TransformPersistence = myParent->TransformPersistence;
+
+ // reuse instanced structure API
+ myInstancedStructure = myParent.operator->();
+}
+
+// =======================================================================
+// function : Connect
+// purpose :
+// =======================================================================
+void OpenGl_StructureShadow::Connect (Graphic3d_CStructure& )
+{
+ Standard_ProgramError::Raise ("Error! OpenGl_StructureShadow::Connect() should not be called!");
+}
+
+// =======================================================================
+// function : Disconnect
+// purpose :
+// =======================================================================
+void OpenGl_StructureShadow::Disconnect (Graphic3d_CStructure& )
+{
+ Standard_ProgramError::Raise ("Error! OpenGl_StructureShadow::Disconnect() should not be called!");
}
Standard_EXPORT OpenGl_StructureShadow (const Handle(Graphic3d_StructureManager)& theManager,
const Handle(OpenGl_Structure)& theStructure);
- //! Return groups of parent structure.
- virtual const Graphic3d_SequenceOfGroup& DrawGroups() const Standard_OVERRIDE
- { return myParent->DrawGroups(); }
-
- //! Renders groups of parent structure.
- virtual void renderGeometry (const Handle(OpenGl_Workspace)& theWorkspace,
- bool& theHasClosed) const Standard_OVERRIDE
- {
- myParent->renderGeometry (theWorkspace, theHasClosed);
- }
-
- //! Renders closed groups of parent structure.
- virtual void renderClosedGeometry (const Handle(OpenGl_Workspace)& theWorkspace) const Standard_OVERRIDE
- {
- myParent->renderClosedGeometry (theWorkspace);
- }
+public:
+
+ //! Raise exception on API misuse.
+ virtual void Connect (Graphic3d_CStructure& ) Standard_OVERRIDE;
+
+ //! Raise exception on API misuse.
+ virtual void Disconnect (Graphic3d_CStructure& ) Standard_OVERRIDE;
private:
continue;
}
- for (OpenGl_Structure::GroupIterator aGroupIter (aStructure->DrawGroups()); aGroupIter.More(); aGroupIter.Next())
+ for (OpenGl_Structure::GroupIterator aGroupIter (aStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
{
// Extract OpenGL elements from the group (primitives arrays)
for (const OpenGl_ElementNode* aNode = aGroupIter.Value()->FirstNode(); aNode != NULL; aNode = aNode->next)
const Graphic3d_Mat4* theTransform,
const Handle(OpenGl_Context)& theGlContext)
{
- for (OpenGl_Structure::GroupIterator aGroupIter (theStructure->DrawGroups()); aGroupIter.More(); aGroupIter.Next())
+ for (OpenGl_Structure::GroupIterator aGroupIter (theStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
{
// Get group material
OpenGl_RaytraceMaterial aGroupMaterial;
if (aColoredPrs.IsNull())
{
aColoredPrs = new AIS_ColoredShape (aShapePrs);
+ if (aShapePrs->HasDisplayMode())
+ {
+ aColoredPrs->SetDisplayMode (aShapePrs->DisplayMode());
+ }
+ aColoredPrs->SetLocalTransformation (aShapePrs->LocalTransformation());
aCtx->Remove (aShapePrs, Standard_False);
GetMapOfAIS().UnBind2 (aName);
GetMapOfAIS().Bind (aColoredPrs, aName);
return 0;
}
+namespace
+{
+ typedef NCollection_DataMap<TCollection_AsciiString, Handle(Graphic3d_ClipPlane)> MapOfPlanes;
+
+ //! Remove registered clipping plane from all views and objects.
+ static void removePlane (MapOfPlanes& theRegPlanes,
+ const TCollection_AsciiString& theName)
+ {
+ Handle(Graphic3d_ClipPlane) aClipPlane;
+ if (!theRegPlanes.Find (theName, aClipPlane))
+ {
+ std::cout << "Warning: no such plane.\n";
+ return;
+ }
+
+ theRegPlanes.UnBind (theName);
+ for (ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIObjIt (GetMapOfAIS());
+ anIObjIt.More(); anIObjIt.Next())
+ {
+ Handle(PrsMgr_PresentableObject) aPrs = Handle(PrsMgr_PresentableObject)::DownCast (anIObjIt.Key1());
+ aPrs->RemoveClipPlane (aClipPlane);
+ }
+
+ for (NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator aViewIt(ViewerTest_myViews);
+ aViewIt.More(); aViewIt.Next())
+ {
+ const Handle(V3d_View)& aView = aViewIt.Key2();
+ aView->RemoveClipPlane(aClipPlane);
+ }
+
+ ViewerTest::RedrawAllViews();
+ }
+}
+
//===============================================================================================
//function : VClipPlane
//purpose :
static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
{
// use short-cut for created clip planes map of created (or "registered by name") clip planes
- typedef NCollection_DataMap<TCollection_AsciiString, Handle(Graphic3d_ClipPlane)> MapOfPlanes;
static MapOfPlanes aRegPlanes;
if (theArgsNb < 2)
{
- theDi << theArgVec[0] << ": command argument is required. Type help for more information.\n";
- return 1;
+ for (MapOfPlanes::Iterator aPlaneIter (aRegPlanes); aPlaneIter.More(); aPlaneIter.Next())
+ {
+ theDi << aPlaneIter.Key() << " ";
+ }
+ return 0;
}
TCollection_AsciiString aCommand (theArgVec[1]);
+ aCommand.LowerCase();
+ const Handle(V3d_View)& anActiveView = ViewerTest::CurrentView();
+ if (anActiveView.IsNull())
+ {
+ std::cout << "Error: no active view.\n";
+ return 1;
+ }
// print maximum number of planes for current viewer
- if (aCommand == "maxplanes")
+ if (aCommand == "-maxplanes"
+ || aCommand == "maxplanes")
{
- if (theArgsNb < 3)
- {
- theDi << theArgVec[0] << ": view name is required. Type help for more information.\n";
- return 1;
- }
-
- TCollection_AsciiString aViewName (theArgVec[2]);
-
- if (!ViewerTest_myViews.IsBound1 (aViewName))
- {
- theDi << theArgVec[0] << ": view is not found.\n";
- return 1;
- }
-
- const Handle(V3d_View)& aView = ViewerTest_myViews.Find1 (aViewName);
-
- theDi << theArgVec[0] << ": "
- << aView->Viewer()->Driver()->InquirePlaneLimit()
- << " plane slots provided by driver."
- << " Note that 2 more planes might be used (reserved for z-clipping).\n";
-
+ theDi << anActiveView->Viewer()->Driver()->InquirePlaneLimit()
+ << " plane slots provided by driver.\n";
return 0;
}
// create / delete plane instance
- if (aCommand == "create" || aCommand == "delete" || aCommand == "clone")
+ if (aCommand == "-create"
+ || aCommand == "create"
+ || aCommand == "-delete"
+ || aCommand == "delete"
+ || aCommand == "-clone"
+ || aCommand == "clone")
{
if (theArgsNb < 3)
{
- theDi << theArgVec[0] << ": plane name is required. Type help for more information.\n";
+ std::cout << "Syntax error: plane name is required.\n";
return 1;
}
- Standard_Boolean toCreate = (aCommand == "create");
- Standard_Boolean toClone = (aCommand == "clone");
+ Standard_Boolean toCreate = aCommand == "-create"
+ || aCommand == "create";
+ Standard_Boolean toClone = aCommand == "-clone"
+ || aCommand == "clone";
+ Standard_Boolean toDelete = aCommand == "-delete"
+ || aCommand == "delete";
TCollection_AsciiString aPlane (theArgVec[2]);
if (toCreate)
{
if (aRegPlanes.IsBound (aPlane))
{
- theDi << theArgVec[0] << ": plane name is in use.\n";
- return 1;
+ std::cout << "Warning: existing plane has been overridden.\n";
+ toDelete = true;
+ }
+ else
+ {
+ aRegPlanes.Bind (aPlane, new Graphic3d_ClipPlane());
+ return 0;
}
-
- aRegPlanes.Bind (aPlane, new Graphic3d_ClipPlane());
}
else if (toClone) // toClone
{
if (!aRegPlanes.IsBound (aPlane))
{
- theDi << theArgVec[0] << ": no such plane.\n";
+ std::cout << "Error: no such plane.\n";
return 1;
}
-
- if (theArgsNb < 4)
+ else if (theArgsNb < 4)
{
- theDi << theArgVec[0] << ": enter name for new plane. Type help for more information.\n";
+ std::cout << "Syntax error: enter name for new plane.\n";
return 1;
}
TCollection_AsciiString aClone (theArgVec[3]);
if (aRegPlanes.IsBound (aClone))
{
- theDi << theArgVec[0] << ": plane name is in use.\n";
+ std::cout << "Error: plane name is in use.\n";
return 1;
}
const Handle(Graphic3d_ClipPlane)& aClipPlane = aRegPlanes.Find (aPlane);
aRegPlanes.Bind (aClone, aClipPlane->Clone());
+ return 0;
}
- else// toDelete
- {
- if (!aRegPlanes.IsBound (aPlane))
- {
- theDi << theArgVec[0] << ": no such plane.\n";
- return 1;
- }
-
- Handle(Graphic3d_ClipPlane) aClipPlane = aRegPlanes.Find (aPlane);
- aRegPlanes.UnBind (aPlane);
- ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName anIObjIt (GetMapOfAIS());
- for (; anIObjIt.More(); anIObjIt.Next())
+ if (toDelete)
+ {
+ if (aPlane == "ALL"
+ || aPlane == "all"
+ || aPlane == "*")
{
- Handle(PrsMgr_PresentableObject) aPrs = Handle(PrsMgr_PresentableObject)::DownCast (anIObjIt.Key1());
- aPrs->RemoveClipPlane(aClipPlane);
+ for (MapOfPlanes::Iterator aPlaneIter (aRegPlanes); aPlaneIter.More();)
+ {
+ aPlane = aPlaneIter.Key();
+ removePlane (aRegPlanes, aPlane);
+ aPlaneIter = MapOfPlanes::Iterator (aRegPlanes);
+ }
}
-
- NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator aViewIt(ViewerTest_myViews);
- for (; aViewIt.More(); aViewIt.Next())
+ else
{
- const Handle(V3d_View)& aView = aViewIt.Key2();
- aView->RemoveClipPlane(aClipPlane);
+ removePlane (aRegPlanes, aPlane);
}
-
- ViewerTest::RedrawAllViews();
}
+ if (toCreate)
+ {
+ aRegPlanes.Bind (aPlane, new Graphic3d_ClipPlane());
+ }
return 0;
}
// set / unset plane command
- if (aCommand == "set" || aCommand == "unset")
+ if (aCommand == "set"
+ || aCommand == "unset")
{
- if (theArgsNb < 4)
- {
- theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
- return 1;
- }
-
- Standard_Boolean toSet = (aCommand == "set");
- TCollection_AsciiString aPlane (theArgVec [2]);
- if (!aRegPlanes.IsBound (aPlane))
+ if (theArgsNb < 5)
{
- theDi << theArgVec[0] << ": no such plane.\n";
+ std::cout << "Syntax error: need more arguments.\n";
return 1;
}
- const Handle(Graphic3d_ClipPlane)& aClipPlane = aRegPlanes.Find (aPlane);
-
- TCollection_AsciiString aTarget (theArgVec [3]);
- if (aTarget != "object" && aTarget != "view")
- {
- theDi << theArgVec[0] << ": invalid target.\n";
- return 1;
- }
-
- if (aTarget == "object" || aTarget == "view")
+ // redirect to new syntax
+ NCollection_Array1<const char*> anArgVec (1, theArgsNb - 1);
+ anArgVec.SetValue (1, theArgVec[0]);
+ anArgVec.SetValue (2, theArgVec[2]);
+ anArgVec.SetValue (3, aCommand == "set" ? "-set" : "-unset");
+ for (Standard_Integer anIt = 4; anIt < theArgsNb; ++anIt)
{
- if (theArgsNb < 5)
- {
- theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
- return 1;
- }
-
- Standard_Boolean isObject = (aTarget == "object");
-
- for (Standard_Integer anIt = 4; anIt < theArgsNb; ++anIt)
- {
- TCollection_AsciiString anEntityName (theArgVec[anIt]);
- if (isObject) // to object
- {
- if (!GetMapOfAIS().IsBound2 (anEntityName))
- {
- theDi << theArgVec[0] << ": can not find IO with name " << anEntityName << ".\n";
- continue;
- }
-
- Handle(AIS_InteractiveObject) aIObj =
- Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (anEntityName));
-
- if (toSet)
- aIObj->AddClipPlane (aClipPlane);
- else
- aIObj->RemoveClipPlane (aClipPlane);
- }
- else // to view
- {
- if (!ViewerTest_myViews.IsBound1 (anEntityName))
- {
- theDi << theArgVec[0] << ": can not find View with name " << anEntityName << ".\n";
- continue;
- }
-
- Handle(V3d_View) aView = ViewerTest_myViews.Find1(anEntityName);
- if (toSet)
- aView->AddClipPlane (aClipPlane);
- else
- aView->RemoveClipPlane (aClipPlane);
- }
- }
-
- ViewerTest::RedrawAllViews();
+ anArgVec.SetValue (anIt, theArgVec[anIt]);
}
- return 0;
+ return VClipPlane (theDi, anArgVec.Length(), &anArgVec.ChangeFirst());
}
// change plane command
- if (aCommand == "change")
+ TCollection_AsciiString aPlaneName;
+ Handle(Graphic3d_ClipPlane) aClipPlane;
+ Standard_Integer anArgIter = 0;
+ if (aCommand == "-change"
+ || aCommand == "change")
{
- if (theArgsNb < 4)
+ // old syntax support
+ if (theArgsNb < 3)
{
- theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
+ std::cout << "Syntax error: need more arguments.\n";
return 1;
}
- TCollection_AsciiString aPlane (theArgVec [2]);
- if (!aRegPlanes.IsBound (aPlane))
+ anArgIter = 3;
+ aPlaneName = theArgVec[2];
+ if (!aRegPlanes.Find (aPlaneName, aClipPlane))
{
- theDi << theArgVec[0] << ": no such plane.\n";
+ std::cout << "Error: no such plane '" << aPlaneName << "'.\n";
return 1;
}
+ }
+ else if (aRegPlanes.Find (theArgVec[1], aClipPlane))
+ {
+ anArgIter = 2;
+ aPlaneName = theArgVec[1];
+ }
+ else
+ {
+ anArgIter = 2;
+ aPlaneName = theArgVec[1];
+ aClipPlane = new Graphic3d_ClipPlane();
+ aRegPlanes.Bind (aPlaneName, aClipPlane);
+ theDi << "Created new plane " << aPlaneName << ".\n";
+ }
- const Handle(Graphic3d_ClipPlane)& aClipPlane = aRegPlanes.Find (aPlane);
+ if (theArgsNb - anArgIter < 1)
+ {
+ std::cout << "Syntax error: need more arguments.\n";
+ return 1;
+ }
- TCollection_AsciiString aChangeArg (theArgVec [3]);
- if (aChangeArg != "on" && aChangeArg != "off" && aChangeArg != "capping" && aChangeArg != "equation")
- {
- theDi << theArgVec[0] << ": invalid arguments. Type help for more information.\n";
- return 1;
- }
+ for (; anArgIter < theArgsNb; ++anArgIter)
+ {
+ const char** aChangeArgs = theArgVec + anArgIter;
+ Standard_Integer aNbChangeArgs = theArgsNb - anArgIter;
+ TCollection_AsciiString aChangeArg (aChangeArgs[0]);
+ aChangeArg.LowerCase();
- if (aChangeArg == "on" || aChangeArg == "off") // on / off
+ Standard_Boolean toEnable = Standard_True;
+ if (ViewerTest::ParseOnOff (aChangeArgs[0], toEnable))
{
- aClipPlane->SetOn (aChangeArg == "on");
+ aClipPlane->SetOn (toEnable);
}
- else if (aChangeArg == "equation") // change equation
+ else if (aChangeArg == "-equation"
+ || aChangeArg == "equation")
{
- if (theArgsNb < 8)
+ if (aNbChangeArgs < 5)
{
- theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
+ std::cout << "Syntax error: need more arguments.\n";
return 1;
}
- Standard_Real aCoeffA = Draw::Atof (theArgVec [4]);
- Standard_Real aCoeffB = Draw::Atof (theArgVec [5]);
- Standard_Real aCoeffC = Draw::Atof (theArgVec [6]);
- Standard_Real aCoeffD = Draw::Atof (theArgVec [7]);
+ Standard_Real aCoeffA = Draw::Atof (aChangeArgs [1]);
+ Standard_Real aCoeffB = Draw::Atof (aChangeArgs [2]);
+ Standard_Real aCoeffC = Draw::Atof (aChangeArgs [3]);
+ Standard_Real aCoeffD = Draw::Atof (aChangeArgs [4]);
aClipPlane->SetEquation (gp_Pln (aCoeffA, aCoeffB, aCoeffC, aCoeffD));
+ anArgIter += 4;
}
- else if (aChangeArg == "capping") // change capping aspects
+ else if (aChangeArg == "-capping"
+ || aChangeArg == "capping")
{
- if (theArgsNb < 5)
+ if (aNbChangeArgs < 2)
{
- theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
+ std::cout << "Syntax error: need more arguments.\n";
return 1;
}
- TCollection_AsciiString aCappingArg (theArgVec [4]);
- if (aCappingArg != "on" && aCappingArg != "off" &&
- aCappingArg != "color" && aCappingArg != "texname" &&
- aCappingArg != "texscale" && aCappingArg != "texorigin" &&
- aCappingArg != "texrotate" && aCappingArg != "hatch")
+ if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
{
- theDi << theArgVec[0] << ": invalid arguments. Type help for more information.\n";
+ aClipPlane->SetCapping (toEnable);
+ anArgIter += 1;
+ }
+ else
+ {
+ // 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 (aCappingArg == "on" || aCappingArg == "off") // on / off capping
+ if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
{
- aClipPlane->SetCapping (aCappingArg == "on");
+ aClipPlane->SetUseObjectMaterial (toEnable == Standard_True);
+ anArgIter += 1;
}
- else if (aCappingArg == "color") // color aspect for capping
+ }
+ else if (aChangeArg == "-useobjecttexture"
+ || aChangeArg == "-useobjecttex"
+ || aChangeArg == "-useobjtexture"
+ || aChangeArg == "-useobjtex")
+ {
+ if (aNbChangeArgs < 2)
{
- if (theArgsNb < 8)
- {
- theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
- return 1;
- }
+ std::cout << "Syntax error: need more arguments.\n";
+ return 1;
+ }
- Standard_Real aRed = Draw::Atof (theArgVec [5]);
- Standard_Real aGrn = Draw::Atof (theArgVec [6]);
- Standard_Real aBlu = Draw::Atof (theArgVec [7]);
+ 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;
+ }
- Graphic3d_MaterialAspect aMat = aClipPlane->CappingMaterial();
- Quantity_Color aColor (aRed, aGrn, aBlu, Quantity_TOC_RGB);
- aMat.SetAmbientColor (aColor);
- aMat.SetDiffuseColor (aColor);
- aClipPlane->SetCappingMaterial (aMat);
+ if (ViewerTest::ParseOnOff (aChangeArgs[1], toEnable))
+ {
+ aClipPlane->SetUseObjectShader (toEnable == Standard_True);
+ anArgIter += 1;
}
- else if (aCappingArg == "texname") // texture name
+ }
+ else if (aChangeArg == "-color"
+ || aChangeArg == "color")
+ {
+ Quantity_Color aColor;
+ Standard_Integer aNbParsed = ViewerTest::ParseColor (aNbChangeArgs - 1,
+ aChangeArgs + 1,
+ aColor);
+ if (aNbParsed == 0)
{
- if (theArgsNb < 6)
- {
- theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
- return 1;
- }
+ std::cout << "Syntax error: need more arguments.\n";
+ return 1;
+ }
- TCollection_AsciiString aTextureName (theArgVec [5]);
+ Graphic3d_MaterialAspect aMat = aClipPlane->CappingMaterial();
+ aMat.SetAmbientColor (aColor);
+ aMat.SetDiffuseColor (aColor);
+ aClipPlane->SetCappingMaterial (aMat);
+ anArgIter += aNbParsed;
+ }
+ else if (aChangeArg == "-texname"
+ || aChangeArg == "texname")
+ {
+ if (aNbChangeArgs < 2)
+ {
+ std::cout << "Syntax error: need more arguments.\n";
+ return 1;
+ }
- Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName);
- if (!aTexture->IsDone ())
- {
- aClipPlane->SetCappingTexture (NULL);
- }
- else
- {
- aTexture->EnableModulate();
- aTexture->EnableRepeat();
- aClipPlane->SetCappingTexture (aTexture);
- }
+ TCollection_AsciiString aTextureName (aChangeArgs[1]);
+ Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(aTextureName);
+ if (!aTexture->IsDone())
+ {
+ aClipPlane->SetCappingTexture (NULL);
}
- else if (aCappingArg == "texscale") // texture scale
+ else
{
- if (aClipPlane->CappingTexture().IsNull())
- {
- theDi << theArgVec[0] << ": no texture is set.\n";
- return 1;
- }
+ 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 (theArgsNb < 7)
- {
- theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
- return 1;
- }
+ if (aNbChangeArgs < 3)
+ {
+ std::cout << "Syntax error: need more arguments.\n";
+ return 1;
+ }
- Standard_ShortReal aSx = (Standard_ShortReal)atof (theArgVec [5]);
- Standard_ShortReal aSy = (Standard_ShortReal)atof (theArgVec [6]);
+ 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;
+ }
- aClipPlane->CappingTexture()->GetParams()->SetScale (Graphic3d_Vec2 (aSx, aSy));
+ if (aNbChangeArgs < 3)
+ {
+ std::cout << "Syntax error: need more arguments.\n";
+ return 1;
}
- else if (aCappingArg == "texorigin") // texture origin
+
+ 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())
{
- if (aClipPlane->CappingTexture().IsNull())
- {
- theDi << theArgVec[0] << ": no texture is set.\n";
- return 1;
- }
+ std::cout << "Error: no texture is set.\n";
+ return 1;
+ }
- if (theArgsNb < 7)
- {
- theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
- return 1;
- }
+ if (aNbChangeArgs < 2)
+ {
+ std::cout << "Syntax error: need more arguments.\n";
+ return 1;
+ }
- Standard_ShortReal aTx = (Standard_ShortReal)atof (theArgVec [5]);
- Standard_ShortReal aTy = (Standard_ShortReal)atof (theArgVec [6]);
+ 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;
+ }
- aClipPlane->CappingTexture()->GetParams()->SetTranslation (Graphic3d_Vec2 (aTx, aTy));
+ TCollection_AsciiString aHatchStr (aChangeArgs[1]);
+ aHatchStr.LowerCase();
+ if (aHatchStr == "on")
+ {
+ aClipPlane->SetCappingHatchOn();
+ }
+ else if (aHatchStr == "off")
+ {
+ aClipPlane->SetCappingHatchOff();
}
- else if (aCappingArg == "texrotate") // texture rotation
+ else
{
- if (aClipPlane->CappingTexture().IsNull())
+ aClipPlane->SetCappingHatch ((Aspect_HatchStyle)Draw::Atoi (aChangeArgs[1]));
+ }
+ anArgIter += 1;
+ }
+ else if (aChangeArg == "-delete"
+ || aChangeArg == "delete")
+ {
+ removePlane (aRegPlanes, aPlaneName);
+ return 0;
+ }
+ else if (aChangeArg == "-set"
+ || aChangeArg == "-unset")
+ {
+ // set / unset plane command
+ Standard_Boolean toSet = aChangeArg == "-set";
+ Standard_Integer anIt = 1;
+ for (; anIt < aNbChangeArgs; ++anIt)
+ {
+ TCollection_AsciiString anEntityName (aChangeArgs[anIt]);
+ if (anEntityName.IsEmpty()
+ || anEntityName.Value (1) == '-')
{
- theDi << theArgVec[0] << ": no texture is set.\n";
- return 1;
+ break;
}
-
- if (theArgsNb < 6)
+ else if (ViewerTest_myViews.IsBound1 (anEntityName))
{
- theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
- return 1;
+ Handle(V3d_View) aView = ViewerTest_myViews.Find1 (anEntityName);
+ if (toSet)
+ {
+ aView->AddClipPlane (aClipPlane);
+ }
+ else
+ {
+ aView->RemoveClipPlane (aClipPlane);
+ }
+ continue;
}
-
- Standard_ShortReal aRot = (Standard_ShortReal)atof (theArgVec[5]);
-
- aClipPlane->CappingTexture()->GetParams()->SetRotation (aRot);
- }
- else if (aCappingArg == "hatch") // hatch style
- {
- if (theArgsNb < 6)
+ else if (GetMapOfAIS().IsBound2 (anEntityName))
{
- theDi << theArgVec[0] << ": need more arguments. Type help for more information.\n";
- return 1;
+ Handle(AIS_InteractiveObject) aIObj = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (anEntityName));
+ if (toSet)
+ {
+ aIObj->AddClipPlane (aClipPlane);
+ }
+ else
+ {
+ aIObj->RemoveClipPlane (aClipPlane);
+ }
}
-
- TCollection_AsciiString aHatchStr (theArgVec [5]);
- if (aHatchStr == "on")
+ else
{
- aClipPlane->SetCappingHatchOn();
+ std::cout << "Error: object/view '" << anEntityName << "' is not found!\n";
+ return 1;
}
- else if (aHatchStr == "off")
+ }
+
+ if (anIt == 1)
+ {
+ // apply to active view
+ if (toSet)
{
- aClipPlane->SetCappingHatchOff();
+ anActiveView->AddClipPlane (aClipPlane);
}
else
{
- aClipPlane->SetCappingHatch ((Aspect_HatchStyle)atoi (theArgVec[5]));
+ anActiveView->RemoveClipPlane (aClipPlane);
}
}
+ else
+ {
+ anArgIter = anArgIter + anIt - 1;
+ }
+ }
+ else
+ {
+ std::cout << "Syntax error: unknown argument '" << aChangeArg << "'.\n";
+ return 1;
}
-
- ViewerTest::RedrawAllViews();
-
- return 0;
}
- theDi << theArgVec[0] << ": invalid command. Type help for more information.\n";
- return 1;
+ ViewerTest::RedrawAllViews();
+ return 0;
}
//===============================================================================================
"If shapes are not given HLR algoithm of given type is applied"
" to all shapes in the view\n",
__FILE__,VHLRType,group);
- theCommands.Add("vclipplane", "vclipplane usage: \n"
- " maxplanes <view_name> - get plane limit for view.\n"
- " create <plane_name> - create new plane.\n"
- " delete <plane_name> - delete plane.\n"
- " clone <source_plane> <plane_name> - clone the plane definition.\n"
- " set/unset <plane_name> object <object list> - set/unset plane for IO.\n"
- " set/unset <plane_name> view <view list> - set/unset plane for view.\n"
- " change <plane_name> on/off - turn clipping on/off.\n"
- " change <plane_name> equation <a> <b> <c> <d> - change plane equation.\n"
- " change <plane_name> capping on/off - turn capping on/off.\n"
- " change <plane_name> capping color <r> <g> <b> - set color.\n"
- " change <plane name> capping texname <texture> - set texture.\n"
- " change <plane_name> capping texscale <sx> <sy> - set tex scale.\n"
- " change <plane_name> capping texorigin <tx> <ty> - set tex origin.\n"
- " change <plane_name> capping texrotate <angle> - set tex rotation.\n"
- " change <plane_name> capping hatch on/off/<id> - set hatching mask.\n"
- " please use VSetTextureMode command to enable texture rendering in view.\n"
- , __FILE__, VClipPlane, group);
+ theCommands.Add("vclipplane",
+ "vclipplane planeName [{0|1}]"
+ "\n\t\t: [-equation A B C D]"
+ "\n\t\t: [-set|-unset [objects|views]]"
+ "\n\t\t: [-maxPlanes]"
+ "\n\t\t: [-capping {0|1}]"
+ "\n\t\t: [-color R G B] [-hatch {on|off|ID}]"
+ "\n\t\t: [-texName Texture] [-texScale SX SY] [-texOrigin TX TY]"
+ "\n\t\t: [-texRotate Angle]"
+ "\n\t\t: [-useObjMaterial {0|1}] [-useObjTexture {0|1}]"
+ "\n\t\t: [-useObjShader {0|1}]"
+ "\n\t\t: Clipping planes management:"
+ "\n\t\t: -maxPlanes print plane limit for view"
+ "\n\t\t: -delete delete plane with given name"
+ "\n\t\t: {off|on|0|1} turn clipping on/off"
+ "\n\t\t: -set|-unset set/unset plane for Object or View list;"
+ "\n\t\t: applied to active View when list is omitted"
+ "\n\t\t: -equation A B C D change plane equation"
+ "\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: -color R G B set capping color"
+ "\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: -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("vdefaults",
"vdefaults [-absDefl value]"
"\n\t\t: [-devCoeff value]"
set aColor3 [vreadpixel 225 150 rgb name]
set aColor4 [vreadpixel 325 200 rgb name]
-if { "$aColor0" != "GRAY61" || "$aColor1" != "GRAY61" || "$aColor2" != "GRAY61" || "$aColor3" != "GRAY61" || "$aColor4" != "GRAY61" } {
+# note that aColor2 is not expected to be capped
+if { "$aColor0" != "GRAY61" || "$aColor1" != "GRAY61" || "$aColor2" == "GRAY61" || "$aColor3" != "GRAY61" || "$aColor4" != "GRAY61" } {
puts "Error: capping color does not match"
}
--- /dev/null
+puts "========"
+puts "Capping plane perserving material"
+puts "========"
+
+set aHatch [locate_data_file images/hatch_1.png]
+
+pload MODELING VISUALIZATION
+
+puts "Create the geometry"
+box b0sole 10 10 0 30 30 70
+box b0hole 20 20 -10 10 10 90
+bcut b0 b0sole b0hole
+box b1 40 20 0 10 30 70
+box b2 20 40 0 20 10 70
+box b3 0 40 0 20 10 70
+box b4 0 10 0 10 30 70
+box b5 0 0 0 30 10 70
+
+set aNbParts 6
+set aColors { RED YELLOW GREEN GRAY MAGENTA1 ORANGE }
+
+compound b0 b1 b2 b3 b4 b5 cc
+
+puts "Create the viewer"
+vclear
+vclose ALL
+vinit name=View1 w=512 h=512
+
+vpoint p0 0 0 0
+vzbufftrihedron
+
+puts "Display the geometry as dedicated objects"
+for { set aPartIter 0 } { $aPartIter < $aNbParts } { incr aPartIter } {
+ vdisplay -noupdate -dispMode 1 b${aPartIter}
+ set aColor [lindex $aColors $aPartIter]
+ vsetcolor -noupdate b${aPartIter} $aColor
+}
+
+puts "Display the geometry as sole object"
+vdisplay -noupdate -dispMode 1 cc
+for { set aPartIter 0 } { $aPartIter < $aNbParts } { incr aPartIter } {
+ set aColor [lindex $aColors $aPartIter]
+ vaspects -noupdate cc -subShapes b${aPartIter} -setColor $aColor
+}
+# show also connected interactive object
+vconnectto co -70 0 0 cc
+vsetdispmode co 1
+vsetlocation cc 70 0 0
+vfit
+
+
+set aPln1Z 40
+set aPln2Y 15
+
+vremove -noupdate p1 p2 p3 pp1 pp2
+vpoint p1 0 0 1
+vpoint p2 1 0 1
+vpoint p3 0 1 1
+vplane pp1 p1 p2 p3
+vsetlocation -noupdate pp1 25 0 [expr $aPln1Z - 1]
+vremove -noupdate p1 p2 p3
+
+vpoint p1 0 1 0
+vpoint p2 1 1 0
+vpoint p3 0 1 1
+vplane pp2 p1 p2 p3
+vsetlocation -noupdate pp2 25 $aPln2Y 35
+vremove -noupdate p1 p2 p3
+verase pp1 pp2
+vfit
+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
+++ /dev/null
-vinit View1
\ No newline at end of file