// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-#include <AIS_Shape.ixx>
+#include <AIS_Shape.hxx>
-
-#include <Standard_ErrorHandler.hxx>
-#include <OSD_Timer.hxx>
-#include <TColStd_ListIteratorOfListOfInteger.hxx>
-
-#include <Quantity_Color.hxx>
-
-#include <gp_Pnt.hxx>
-#include <Bnd_Box.hxx>
+#include <AIS_GraphicTool.hxx>
+#include <AIS_InteractiveContext.hxx>
+#include <Aspect_TypeOfLine.hxx>
#include <BRep_Builder.hxx>
-#include <BRepTools_ShapeSet.hxx>
-#include <BRepTools.hxx>
#include <BRepBndLib.hxx>
-#include <TopExp.hxx>
-#include <TopExp_Explorer.hxx>
-
-#include <Aspect_TypeOfLine.hxx>
-#include <Graphic3d_Structure.hxx>
-#include <Graphic3d_Group.hxx>
+#include <BRepTools.hxx>
+#include <BRepTools_ShapeSet.hxx>
+#include <Geom_Transformation.hxx>
+#include <gp_Pnt.hxx>
+#include <Graphic3d_ArrayOfPolylines.hxx>
+#include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_AspectLine3d.hxx>
-#include <Graphic3d_AspectText3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
-#include <Graphic3d_AspectFillArea3d.hxx>
-#include <Graphic3d_ArrayOfPolylines.hxx>
+#include <Graphic3d_AspectText3d.hxx>
+#include <Graphic3d_Group.hxx>
#include <Graphic3d_MaterialAspect.hxx>
-
+#include <Graphic3d_SequenceOfGroup.hxx>
+#include <Graphic3d_Structure.hxx>
+#include <Message.hxx>
+#include <Message_Messenger.hxx>
+#include <HLRBRep.hxx>
+#include <OSD_Timer.hxx>
+#include <Precision.hxx>
+#include <Prs3d.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_IsoAspect.hxx>
#include <Prs3d_Presentation.hxx>
+#include <Prs3d_Projector.hxx>
#include <Prs3d_Root.hxx>
#include <Prs3d_ShadingAspect.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_IsoAspect.hxx>
-
-#include <StdPrs_WFShape.hxx>
-#include <StdPrs_WFDeflectionShape.hxx>
-#include <StdPrs_ShadedShape.hxx>
-#include <StdPrs_HLRShape.hxx>
-#include <StdPrs_HLRPolyShape.hxx>
-
-#include <PrsMgr_ModedPresentation.hxx>
-
+#include <StdPrs_BndBox.hxx>
+#include <StdPrs_ToolTriangulatedShape.hxx>
+#include <Quantity_Color.hxx>
+#include <Select3D_SensitiveBox.hxx>
#include <Select3D_SensitiveEntity.hxx>
+#include <Standard_ErrorHandler.hxx>
+#include <Standard_Failure.hxx>
+#include <Standard_Type.hxx>
+#include <StdPrs_HLRPolyShape.hxx>
+#include <StdPrs_HLRShape.hxx>
+#include <StdPrs_ShadedShape.hxx>
+#include <StdPrs_WFShape.hxx>
#include <StdSelect.hxx>
-#include <StdSelect_BRepSelectionTool.hxx>
#include <StdSelect_BRepOwner.hxx>
+#include <StdSelect_BRepSelectionTool.hxx>
#include <StdSelect_DisplayMode.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TopExp.hxx>
-#include <AIS_GraphicTool.hxx>
-#include <AIS_InteractiveContext.hxx>
-#include <AIS_Drawer.hxx>
-#include <HLRBRep.hxx>
-#include <Precision.hxx>
-
-#include <Standard_Failure.hxx>
-#include <Standard_ErrorHandler.hxx>
-#include <Select3D_SensitiveBox.hxx>
-#include <TopoDS_Iterator.hxx>
+IMPLEMENT_STANDARD_RTTIEXT(AIS_Shape,AIS_InteractiveObject)
-static Standard_Boolean myFirstCompute;
+// Auxiliary macros
+#define replaceAspectWithDef(theMap, theAspect) \
+ if (myDrawer->Link()->theAspect()->Aspect() != myDrawer->theAspect()->Aspect()) \
+ { \
+ theMap.Bind (myDrawer->theAspect()->Aspect(), myDrawer->Link()->theAspect()->Aspect()); \
+ }
-Standard_Real AIS_Shape::GetDeflection(const TopoDS_Shape& aShape,
- const Handle(Prs3d_Drawer)& aDrawer)
-{
- // WARNING: this same piece of code appears several times in Prs3d classes
- Standard_Real aDeflection = aDrawer->MaximalChordialDeviation();
- if (aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE) {
- Bnd_Box B;
- BRepBndLib::Add(aShape, B, Standard_False);
- if ( ! B.IsVoid() )
- {
- Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
- B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
- aDeflection = Max( aXmax-aXmin, Max(aYmax-aYmin, aZmax-aZmin)) *
- aDrawer->DeviationCoefficient() * 4;
- }
+// Auxiliary macros for replaceWithNewOwnAspects()
+#define replaceAspectWithOwn(theMap, theAspect) \
+ if (myDrawer->Link()->theAspect()->Aspect() != myDrawer->theAspect()->Aspect()) \
+ { \
+ theMap.Bind (myDrawer->Link()->theAspect()->Aspect(), myDrawer->theAspect()->Aspect()); \
}
- return aDeflection;
-}
-void AIS_Shape::DisplayBox(const Handle(Prs3d_Presentation)& aPrs,
- const Bnd_Box& B,
- const Handle(Prs3d_Drawer)& aDrawer)
+//=======================================================================
+//function : replaceWithNewOwnAspects
+//purpose :
+//=======================================================================
+void AIS_Shape::replaceWithNewOwnAspects()
{
- static const Standard_Integer Indx[][3] =
- { { 0, 0, 0 }, { 1, 0, 0 }, { 1, 0, 1 }, { 0, 0, 1 },
- { 0, 1, 1 }, { 1, 1, 1 }, { 1, 1, 0 }, { 0, 1, 0 },
- { 0, 0, 0 }, { 0, 0, 1 }, { 1, 0, 1 }, { 1, 1, 1 },
- { 0, 1, 1 }, { 0, 1, 0 }, { 1, 1, 0 }, { 1, 0, 0 } };
-
- if ( B.IsVoid() )
- return; // nothing to show
-
- Standard_Real X[2],Y[2],Z[2];
- B.Get(X[0], Y[0], Z[0], X[1], Y[1], Z[1]);
-
- Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(aPrs);
- Quantity_Color Q;
- Aspect_TypeOfLine A;
- Standard_Real W;
- aDrawer->LineAspect()->Aspect()->Values(Q,A,W);
-
- G->SetGroupPrimitivesAspect(new Graphic3d_AspectLine3d(Q,Aspect_TOL_DOTDASH,W));
-
- Handle(Graphic3d_ArrayOfPolylines) aPolyline = new Graphic3d_ArrayOfPolylines(16);
- Standard_Integer i(0);
- for(;i<16;i++)
- aPolyline->AddVertex(X[Indx[i][0]],Y[Indx[i][1]],Z[Indx[i][2]]);
- G->AddPrimitiveArray(aPolyline);
-}
+ Graphic3d_MapOfAspectsToAspects aReplaceMap;
-static Standard_Boolean IsInList(const TColStd_ListOfInteger& LL, const Standard_Integer aMode)
-{
- TColStd_ListIteratorOfListOfInteger It(LL);
- for(;It.More();It.Next()){
- if(It.Value()==aMode)
- return Standard_True;}
- return Standard_False;
+ replaceAspectWithOwn (aReplaceMap, ShadingAspect);
+ replaceAspectWithOwn (aReplaceMap, LineAspect);
+ replaceAspectWithOwn (aReplaceMap, WireAspect);
+ replaceAspectWithOwn (aReplaceMap, FreeBoundaryAspect);
+ replaceAspectWithOwn (aReplaceMap, UnFreeBoundaryAspect);
+ replaceAspectWithOwn (aReplaceMap, SeenLineAspect);
+ replaceAspectWithOwn (aReplaceMap, FaceBoundaryAspect);
+ replaceAspectWithOwn (aReplaceMap, PointAspect);
+
+ replaceAspects (aReplaceMap);
}
//==================================================
-// Function:
+// Function: AIS_Shape
// Purpose :
//==================================================
-
-AIS_Shape::
-AIS_Shape(const TopoDS_Shape& shap):
-AIS_InteractiveObject(PrsMgr_TOP_ProjectorDependant),
-myshape(shap),
-myCompBB(Standard_True),
-myInitAng(0.)
+AIS_Shape::AIS_Shape(const TopoDS_Shape& theShape)
+: AIS_InteractiveObject (PrsMgr_TOP_ProjectorDependant),
+ myshape (theShape),
+ myUVOrigin(0.0, 0.0),
+ myUVRepeat(1.0, 1.0),
+ myUVScale (1.0, 1.0),
+ myInitAng (0.0),
+ myCompBB (Standard_True)
{
- myFirstCompute = Standard_True;
- SetHilightMode(0);
- myDrawer->SetShadingAspectGlobal(Standard_False);
+ //
}
-//=======================================================================
-//function : Type
-//purpose :
-//=======================================================================
-AIS_KindOfInteractive AIS_Shape::Type() const
-{return AIS_KOI_Shape;}
-
-
-//=======================================================================
-//function : Signature
-//purpose :
-//=======================================================================
-Standard_Integer AIS_Shape::Signature() const
-{return 0;}
-
-//=======================================================================
-//function : AcceptShapeDecomposition
-//purpose :
-//=======================================================================
-Standard_Boolean AIS_Shape::AcceptShapeDecomposition() const
-{return Standard_True;}
-
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
const Handle(Prs3d_Presentation)& aPrs,
- const Standard_Integer aMode)
+ const Standard_Integer theMode)
{
- aPrs->Clear();
if(myshape.IsNull()) return;
// wire,edge,vertex -> pas de HLR + priorite display superieure
aPrs->SetDisplayPriority(TheType+2);
}
// Shape vide -> Assemblage vide.
- if (myshape.ShapeType() == TopAbs_COMPOUND) {
- TopoDS_Iterator anExplor (myshape);
+ if (myshape.ShapeType() == TopAbs_COMPOUND && myshape.NbChildren() == 0)
+ {
+ return;
+ }
- if (!anExplor.More()) {
- return;
- }
+ if (IsInfinite())
+ {
+ aPrs->SetInfiniteState (Standard_True); //not taken in account during FITALL
}
- if (IsInfinite()) aPrs->SetInfiniteState(Standard_True); //not taken in account duting FITALL
- switch (aMode) {
- case 0:{
- try { OCC_CATCH_SIGNALS StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer); }
- catch (Standard_Failure) {
-#ifdef DEB
- cout << "AIS_Shape::Compute() failed"<< endl;
-#endif
- cout << "a Shape should be incorrect : No Compute can be maked on it "<< endl;
-// presentation of the bounding box is calculated
-// Compute(aPresentationManager,aPrs,2);
+ switch (theMode)
+ {
+ case AIS_WireFrame:
+ {
+ StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (myshape, myDrawer, Standard_True);
+ try
+ {
+ OCC_CATCH_SIGNALS
+ StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
+ }
+ catch (Standard_Failure const& anException)
+ {
+ Message::DefaultMessenger()->Send (TCollection_AsciiString()
+ + "Error: AIS_Shape::Compute() wireframe presentation builder has failed ("
+ + anException.GetMessageString() + ")", Message_Fail);
+ }
+ break;
}
- break;
- }
- case 1:
+ case AIS_Shaded:
{
- Standard_Real anAnglePrev, anAngleNew, aCoeffPrev, aCoeffNew;
- Standard_Boolean isOwnDeviationAngle = OwnDeviationAngle (anAngleNew, anAnglePrev);
- Standard_Boolean isOwnDeviationCoefficient = OwnDeviationCoefficient(aCoeffNew, aCoeffPrev);
- if ((isOwnDeviationAngle && Abs (anAngleNew - anAnglePrev) > Precision::Angular())
- || (isOwnDeviationCoefficient && Abs (aCoeffNew - aCoeffPrev) > Precision::Confusion()))
+ StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (myshape, myDrawer, Standard_True);
+ if ((Standard_Integer) myshape.ShapeType() > 4)
{
- BRepTools::Clean (myshape);
+ StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
}
-
- //shading only on face...
- if ((Standard_Integer) myshape.ShapeType()>4)
- StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
- else {
- myDrawer->SetShadingAspectGlobal(Standard_False);
- if (IsInfinite()) StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
- else {
+ else
+ {
+ if (IsInfinite())
+ {
+ StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
+ }
+ else
+ {
+ try
+ {
+ OCC_CATCH_SIGNALS
+ StdPrs_ShadedShape::Add (aPrs, myshape, myDrawer,
+ myDrawer->ShadingAspect()->Aspect()->ToMapTexture()
+ && !myDrawer->ShadingAspect()->Aspect()->TextureMap().IsNull(),
+ myUVOrigin, myUVRepeat, myUVScale);
+ }
+ catch (Standard_Failure const& anException)
{
- try {
- OCC_CATCH_SIGNALS
- StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer);
- }
- catch (Standard_Failure) {
-#ifdef DEB
- cout << "AIS_Shape::Compute() in ShadingMode failed"<< endl;
-#endif
- StdPrs_WFShape::Add(aPrs,myshape,myDrawer);
- }
+ Message::DefaultMessenger()->Send (TCollection_AsciiString()
+ + "Error: AIS_Shape::Compute() shaded presentation builder has failed ("
+ + anException.GetMessageString() + ")", Message_Fail);
+ StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
}
}
}
- Standard_Real value = Transparency() ;
- if( value > 0. ) {
- SetTransparency( value );
+ Standard_Real aTransparency = Transparency() ;
+ if (aTransparency > 0.0)
+ {
+ SetTransparency (aTransparency);
}
break;
}
- case 2:
+
+ // Bounding box.
+ case 2:
{
- // bounding box
- if (IsInfinite()) StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
- else DisplayBox(aPrs,BoundingBox(),myDrawer);
+ if (IsInfinite())
+ {
+ StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
+ }
+ else
+ {
+ StdPrs_BndBox::Add (aPrs, BoundingBox(), myDrawer);
+ }
}
- } // end switch
- aPrs->ReCompute(); // for hidden line recomputation if necessary...
-}
+ }
-//=======================================================================
-//function : Compute
-//purpose : Hidden Line Removal
-//=======================================================================
-void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
- const Handle(Prs3d_Presentation)& aPresentation)
-{
- Compute(aProjector,aPresentation,myshape);
+ // Recompute hidden line presentation (if necessary).
+ aPrs->ReCompute();
}
//=======================================================================
-//function : Compute
-//purpose :
+//function : computeHlrPresentation
+//purpose :
//=======================================================================
-
-void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
- const Handle(Geom_Transformation)& TheTrsf,
- const Handle(Prs3d_Presentation)& aPresentation)
+void AIS_Shape::computeHlrPresentation (const Handle(Prs3d_Projector)& theProjector,
+ const Handle(Prs3d_Presentation)& thePrs,
+ const TopoDS_Shape& theShape,
+ const Handle(Prs3d_Drawer)& theDrawer)
{
- const TopLoc_Location& loc = myshape.Location();
- TopoDS_Shape shbis = myshape.Located(TopLoc_Location(TheTrsf->Trsf())*loc);
- Compute(aProjector,aPresentation,shbis);
-}
+ if (theShape.IsNull())
+ {
+ return;
+ }
-//=======================================================================
-//function : Compute
-//purpose :
-//=======================================================================
+ switch (theShape.ShapeType())
+ {
+ case TopAbs_VERTEX:
+ case TopAbs_EDGE:
+ case TopAbs_WIRE:
+ {
+ thePrs->SetDisplayPriority (4);
+ StdPrs_WFShape::Add (thePrs, theShape, theDrawer);
+ return;
+ }
+ case TopAbs_COMPOUND:
+ {
+ if (theShape.NbChildren() == 0)
+ {
+ return;
+ }
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
-void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
- const Handle(Prs3d_Presentation)& aPresentation,
- const TopoDS_Shape& SH)
-{
- if (SH.ShapeType() == TopAbs_COMPOUND) {
- TopoDS_Iterator anExplor (SH);
+ const Handle(Prs3d_Drawer)& aDefDrawer = theDrawer->Link();
+ if (aDefDrawer->DrawHiddenLine())
+ {
+ theDrawer->EnableDrawHiddenLine();
+ }
+ else
+ {
+ theDrawer->DisableDrawHiddenLine();
+ }
- if (!anExplor.More()) // Shape vide -> Assemblage vide.
- return;
+ const Aspect_TypeOfDeflection aPrevDef = aDefDrawer->TypeOfDeflection();
+ aDefDrawer->SetTypeOfDeflection (Aspect_TOD_RELATIVE);
+ if (theDrawer->IsAutoTriangulation())
+ {
+ StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (theShape, theDrawer, Standard_True);
}
- Handle (Prs3d_Drawer) defdrawer = GetContext()->DefaultDrawer();
- if (defdrawer->DrawHiddenLine())
- {myDrawer->EnableDrawHiddenLine();}
- else {myDrawer->DisableDrawHiddenLine();}
-
- Aspect_TypeOfDeflection prevdef = defdrawer->TypeOfDeflection();
- defdrawer->SetTypeOfDeflection(Aspect_TOD_RELATIVE);
-
-// coefficients for calculation
-
- Standard_Real prevangle, newangle ,prevcoeff,newcoeff ;
- Standard_Boolean isOwnHLRDeviationAngle = OwnHLRDeviationAngle(newangle,prevangle);
- Standard_Boolean isOwnHLRDeviationCoefficient = OwnHLRDeviationCoefficient(newcoeff,prevcoeff);
- if (((Abs (newangle - prevangle) > Precision::Angular()) && isOwnHLRDeviationAngle) ||
- ((Abs (newcoeff - prevcoeff) > Precision::Confusion()) && isOwnHLRDeviationCoefficient)) {
-#ifdef DEB
- cout << "AIS_Shape : compute"<<endl;
- cout << "newangle : " << newangle << " # de " << "prevangl : " << prevangle << " OU "<<endl;
- cout << "newcoeff : " << newcoeff << " # de " << "prevcoeff : " << prevcoeff << endl;
-#endif
- BRepTools::Clean(SH);
- }
-
{
- try {
+ try
+ {
OCC_CATCH_SIGNALS
- switch (TypeOfHLR()) {
+ switch (theDrawer->TypeOfHLR())
+ {
case Prs3d_TOH_Algo:
- StdPrs_HLRShape::Add (aPresentation, SH, myDrawer, aProjector);
+ StdPrs_HLRShape::Add (thePrs, theShape, theDrawer, theProjector);
break;
case Prs3d_TOH_PolyAlgo:
default:
- StdPrs_HLRPolyShape::Add (aPresentation, SH, myDrawer, aProjector);
+ StdPrs_HLRPolyShape::Add (thePrs, theShape, theDrawer, theProjector);
break;
}
}
- catch (Standard_Failure) {
-#ifdef DEB
- cout <<"AIS_Shape::Compute(Proj) HLR Algorithm failed" << endl;
-#endif
- StdPrs_WFShape::Add(aPresentation,SH,myDrawer);
+ catch (Standard_Failure const& anException)
+ {
+ Message::DefaultMessenger()->Send (TCollection_AsciiString()
+ + "Error: AIS_Shape::Compute() HLR Algorithm has failed ("
+ + anException.GetMessageString() + ")", Message_Fail);
+ StdPrs_WFShape::Add (thePrs, theShape, theDrawer);
}
}
- defdrawer->SetTypeOfDeflection (prevdef);
-}
-
-//=======================================================================
-//function : SelectionType
-//purpose : gives the type according to the Index of Selection Mode
-//=======================================================================
-
-TopAbs_ShapeEnum AIS_Shape::SelectionType(const Standard_Integer aMode)
-{
- switch(aMode){
- case 1:
- return TopAbs_VERTEX;
- case 2:
- return TopAbs_EDGE;
- case 3:
- return TopAbs_WIRE;
- case 4:
- return TopAbs_FACE;
- case 5:
- return TopAbs_SHELL;
- case 6:
- return TopAbs_SOLID;
- case 7:
- return TopAbs_COMPSOLID;
- case 8:
- return TopAbs_COMPOUND;
- case 0:
- default:
- return TopAbs_SHAPE;
- }
-
-}
-//=======================================================================
-//function : SelectionType
-//purpose : gives the SelectionMode according to the Type od Decomposition...
-//=======================================================================
-Standard_Integer AIS_Shape::SelectionMode(const TopAbs_ShapeEnum aType)
-{
- switch(aType){
- case TopAbs_VERTEX:
- return 1;
- case TopAbs_EDGE:
- return 2;
- case TopAbs_WIRE:
- return 3;
- case TopAbs_FACE:
- return 4;
- case TopAbs_SHELL:
- return 5;
- case TopAbs_SOLID:
- return 6;
- case TopAbs_COMPSOLID:
- return 7;
- case TopAbs_COMPOUND:
- return 8;
- case TopAbs_SHAPE:
- default:
- return 0;
- }
+ aDefDrawer->SetTypeOfDeflection (aPrevDef);
}
-
//=======================================================================
//function : ComputeSelection
//purpose :
const Standard_Integer aMode)
{
if(myshape.IsNull()) return;
- if (myshape.ShapeType() == TopAbs_COMPOUND) {
- TopoDS_Iterator anExplor (myshape);
-
- if (!anExplor.More()) // empty Shape -> empty Assembly.
- return;
+ if (myshape.ShapeType() == TopAbs_COMPOUND && myshape.NbChildren() == 0)
+ {
+ // empty Shape -> empty Assembly.
+ return;
}
- static TopAbs_ShapeEnum TypOfSel;
- TypOfSel = AIS_Shape::SelectionType(aMode);
+ TopAbs_ShapeEnum TypOfSel = AIS_Shape::SelectionType(aMode);
TopoDS_Shape shape = myshape;
- if( HasTransformation() ) {
- Handle(Geom_Transformation) trsf = Transformation();
- shape = shape.Located(TopLoc_Location(trsf->Trsf())*shape.Location());
- }
// POP protection against crash in low layers
- Standard_Real aDeflection = GetDeflection(shape, myDrawer);
- Standard_Boolean autoTriangulation = Standard_True;
- try {
+ Standard_Real aDeflection = Prs3d::GetDeflection(shape, myDrawer);
+ try
+ {
OCC_CATCH_SIGNALS
StdSelect_BRepSelectionTool::Load(aSelection,
this,
TypOfSel,
aDeflection,
myDrawer->HLRAngle(),
- autoTriangulation);
- } catch ( Standard_Failure ) {
-// cout << "a Shape should be incorrect : A Selection on the Bnd is activated "<<endl;
- if ( aMode == 0 ) {
+ myDrawer->IsAutoTriangulation());
+ }
+ catch (Standard_Failure const& anException)
+ {
+ Message::DefaultMessenger()->Send (TCollection_AsciiString()
+ + "Error: AIS_Shape::ComputeSelection(" + aMode + ") has failed ("
+ + anException.GetMessageString() + ")", Message_Fail);
+ if (aMode == 0)
+ {
+ aSelection->Clear();
Bnd_Box B = BoundingBox();
Handle(StdSelect_BRepOwner) aOwner = new StdSelect_BRepOwner(shape,this);
Handle(Select3D_SensitiveBox) aSensitiveBox = new Select3D_SensitiveBox(aOwner,B);
StdSelect::SetDrawerForBRepOwner(aSelection,myDrawer);
}
-Quantity_NameOfColor AIS_Shape::Color() const {
-Quantity_Color aColor;
- Color(aColor);
- return aColor.Name();
-}
-
void AIS_Shape::Color( Quantity_Color& aColor ) const {
aColor = myDrawer->ShadingAspect()->Color(myCurrentFacingModel);
}
return myDrawer->ShadingAspect()->Transparency(myCurrentFacingModel);
}
-//=======================================================================
-//function : SetColor
-//purpose :
-//=======================================================================
-
-void AIS_Shape::SetColor(const Quantity_NameOfColor aCol)
-{
- SetColor(Quantity_Color(aCol));
-}
-
//=======================================================================
//function : setColor
//purpose :
//=======================================================================
-void AIS_Shape::setColor (const Handle(AIS_Drawer)& theDrawer,
- const Quantity_Color& theColor) const
+bool AIS_Shape::setColor (const Handle(Prs3d_Drawer)& theDrawer,
+ const Quantity_Color& theColor) const
{
- if (!theDrawer->HasShadingAspect())
- {
- theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
- *theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
- }
- if (!theDrawer->HasLineAspect())
- {
- theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
- *theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
- }
- if (!theDrawer->HasWireAspect())
- {
- theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
- *theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect();
- }
- if (!theDrawer->HasPointAspect())
- {
- theDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, Quantity_NOC_BLACK, 1.0));
- *theDrawer->PointAspect()->Aspect() = *theDrawer->Link()->PointAspect()->Aspect();
- }
- // disable dedicated line aspects
- theDrawer->SetFreeBoundaryAspect (theDrawer->LineAspect());
- theDrawer->SetUnFreeBoundaryAspect(theDrawer->LineAspect());
- theDrawer->SetSeenLineAspect (theDrawer->LineAspect());
+ bool toRecompute = false;
+ toRecompute = theDrawer->SetupOwnShadingAspect() || toRecompute;
+ toRecompute = theDrawer->SetOwnLineAspects() || toRecompute;
+ toRecompute = theDrawer->SetupOwnPointAspect() || toRecompute;
// override color
theDrawer->ShadingAspect()->SetColor (theColor, myCurrentFacingModel);
- theDrawer->SetShadingAspectGlobal (Standard_False);
theDrawer->LineAspect()->SetColor (theColor);
theDrawer->WireAspect()->SetColor (theColor);
theDrawer->PointAspect()->SetColor (theColor);
+ theDrawer->FreeBoundaryAspect()->SetColor (theColor);
+ theDrawer->UnFreeBoundaryAspect()->SetColor (theColor);
+ theDrawer->SeenLineAspect()->SetColor (theColor);
+ theDrawer->FaceBoundaryAspect()->SetColor (theColor);
+ return toRecompute;
}
//=======================================================================
void AIS_Shape::SetColor (const Quantity_Color& theColor)
{
- setColor (myDrawer, theColor);
- myOwnColor = theColor;
+ const bool toRecompute = setColor (myDrawer, theColor);
+ myDrawer->SetColor (theColor);
hasOwnColor = Standard_True;
- // fast shading modification...
- if (!GetContext().IsNull())
+ if (!toRecompute
+ || !myDrawer->HasLink())
{
- if (GetContext()->MainPrsMgr()->HasPresentation (this, AIS_Shaded))
- {
- Handle(Prs3d_Presentation) aPrs = GetContext()->MainPrsMgr()->Presentation (this, AIS_Shaded)->Presentation();
- Handle(Graphic3d_Group) aCurGroup = Prs3d_Root::CurrentGroup (aPrs);
- Handle(Graphic3d_AspectFillArea3d) anAreaAspect = myDrawer->ShadingAspect()->Aspect();
- Handle(Graphic3d_AspectLine3d) aLineAspect = myDrawer->LineAspect()->Aspect();
- Handle(Graphic3d_AspectMarker3d) aPointAspect = myDrawer->PointAspect()->Aspect();
-
- // Set aspects for presentation and for group
- aPrs->SetPrimitivesAspect (anAreaAspect);
- aPrs->SetPrimitivesAspect (aLineAspect);
- aPrs->SetPrimitivesAspect (aPointAspect);
- // Check if aspect of given type is set for the group,
- // because setting aspect for group with no already set aspect
- // can lead to loss of presentation data
- if (aCurGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
- {
- aCurGroup->SetGroupPrimitivesAspect (anAreaAspect);
- }
- if (aCurGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_LINE))
- {
- aCurGroup->SetGroupPrimitivesAspect (aLineAspect);
- }
- if (aCurGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_MARKER))
- {
- aCurGroup->SetGroupPrimitivesAspect (aPointAspect);
- }
- }
+ SynchronizeAspects();
}
-
- LoadRecomputable (AIS_WireFrame);
- LoadRecomputable (2);
+ else
+ {
+ replaceWithNewOwnAspects();
+ }
+ recomputeComputed();
}
//=======================================================================
{
if (!HasColor())
{
- myToRecomputeModes.Clear();
return;
}
+
hasOwnColor = Standard_False;
+ myDrawer->SetColor (myDrawer->HasLink() ? myDrawer->Link()->Color() : Quantity_Color (Quantity_NOC_WHITE));
+ Graphic3d_MapOfAspectsToAspects aReplaceMap;
if (!HasWidth())
{
- Handle(Prs3d_LineAspect) anEmptyAsp;
- myDrawer->SetLineAspect (anEmptyAsp);
- myDrawer->SetWireAspect (anEmptyAsp);
- myDrawer->SetFreeBoundaryAspect (anEmptyAsp);
- myDrawer->SetUnFreeBoundaryAspect(anEmptyAsp);
- myDrawer->SetSeenLineAspect (anEmptyAsp);
+ replaceAspectWithDef (aReplaceMap, LineAspect);
+ replaceAspectWithDef (aReplaceMap, WireAspect);
+ replaceAspectWithDef (aReplaceMap, FreeBoundaryAspect);
+ replaceAspectWithDef (aReplaceMap, UnFreeBoundaryAspect);
+ replaceAspectWithDef (aReplaceMap, SeenLineAspect);
+ replaceAspectWithDef (aReplaceMap, FaceBoundaryAspect);
+ myDrawer->SetLineAspect (Handle(Prs3d_LineAspect)());
+ myDrawer->SetWireAspect (Handle(Prs3d_LineAspect)());
+ myDrawer->SetFreeBoundaryAspect (Handle(Prs3d_LineAspect)());
+ myDrawer->SetUnFreeBoundaryAspect(Handle(Prs3d_LineAspect)());
+ myDrawer->SetSeenLineAspect (Handle(Prs3d_LineAspect)());
+ myDrawer->SetFaceBoundaryAspect (Handle(Prs3d_LineAspect)());
}
else
{
- Quantity_Color aColor;
- AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, aColor);
+ Quantity_Color aColor = Quantity_NOC_YELLOW;
+ if (myDrawer->HasLink())
+ {
+ AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, aColor);
+ }
myDrawer->LineAspect()->SetColor (aColor);
- AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Wire, aColor);
+ aColor = Quantity_NOC_RED;
+ if (myDrawer->HasLink())
+ {
+ AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Wire, aColor);
+ }
myDrawer->WireAspect()->SetColor (aColor);
- AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Free, aColor);
+ aColor = Quantity_NOC_GREEN;
+ if (myDrawer->HasLink())
+ {
+ AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Free, aColor);
+ }
myDrawer->FreeBoundaryAspect()->SetColor (aColor);
- AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_UnFree, aColor);
+ aColor = Quantity_NOC_YELLOW;
+ if (myDrawer->HasLink())
+ {
+ AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_UnFree, aColor);
+ }
myDrawer->UnFreeBoundaryAspect()->SetColor (aColor);
- AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Seen, aColor);
+ if (myDrawer->HasLink())
+ {
+ AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Seen, aColor);
+ }
myDrawer->SeenLineAspect()->SetColor (aColor);
+ aColor = Quantity_NOC_BLACK;
+ if (myDrawer->HasLink())
+ {
+ AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_FaceBoundary, aColor);
+ }
+ myDrawer->FaceBoundaryAspect()->SetColor (aColor);
}
- if (HasMaterial()
- || IsTransparent())
+ if (!myDrawer->HasOwnShadingAspect())
{
- Graphic3d_MaterialAspect mat = AIS_GraphicTool::GetMaterial(HasMaterial()? myDrawer : myDrawer->Link());
+ //
+ }
+ else if (HasMaterial()
+ || IsTransparent()
+ || myDrawer->ShadingAspect()->Aspect()->ToMapTexture())
+ {
+ const Graphic3d_MaterialAspect aDefaultMat (Graphic3d_NOM_BRASS);
+ Graphic3d_MaterialAspect mat = aDefaultMat;
+ Quantity_Color anInteriorColors[2] = {Quantity_NOC_CYAN1, Quantity_NOC_CYAN1};
+ if (myDrawer->HasLink())
+ {
+ anInteriorColors[0] = myDrawer->Link()->ShadingAspect()->Aspect()->InteriorColor();
+ anInteriorColors[1] = myDrawer->Link()->ShadingAspect()->Aspect()->BackInteriorColor();
+ }
+ if (HasMaterial() || myDrawer->HasLink())
+ {
+ const Handle(Graphic3d_AspectFillArea3d)& aSrcAspect = (HasMaterial() ? myDrawer : myDrawer->Link())->ShadingAspect()->Aspect();
+ mat = myCurrentFacingModel != Aspect_TOFM_BACK_SIDE
+ ? aSrcAspect->FrontMaterial()
+ : aSrcAspect->BackMaterial();
+ }
if (HasMaterial())
{
- Quantity_Color aColor = myDrawer->Link()->ShadingAspect()->Color (myCurrentFacingModel);
+ const Quantity_Color aColor = myDrawer->HasLink()
+ ? myDrawer->Link()->ShadingAspect()->Color (myCurrentFacingModel)
+ : aDefaultMat.AmbientColor();
mat.SetColor (aColor);
}
if (IsTransparent())
{
Standard_Real aTransp = myDrawer->ShadingAspect()->Transparency (myCurrentFacingModel);
- mat.SetTransparency (aTransp);
+ mat.SetTransparency (Standard_ShortReal(aTransp));
}
- myDrawer->ShadingAspect()->SetMaterial (mat ,myCurrentFacingModel);
+ myDrawer->ShadingAspect()->SetMaterial (mat, myCurrentFacingModel);
+ myDrawer->ShadingAspect()->Aspect()->SetInteriorColor (anInteriorColors[0]);
+ myDrawer->ShadingAspect()->Aspect()->SetBackInteriorColor(anInteriorColors[1]);
}
else
{
+ replaceAspectWithDef (aReplaceMap, ShadingAspect);
myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
}
- myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)());
-
- if (!GetContext().IsNull())
+ if (myDrawer->HasOwnPointAspect())
{
- if (GetContext()->MainPrsMgr()->HasPresentation (this, AIS_Shaded))
- {
- Handle(Prs3d_Presentation) aPrs = GetContext()->MainPrsMgr()->Presentation (this, AIS_Shaded)->Presentation();
- Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (aPrs);
-
- Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->Link()->ShadingAspect()->Aspect();
- Handle(Graphic3d_AspectLine3d) aLineAsp = myDrawer->Link()->LineAspect()->Aspect();
- Quantity_Color aColor;
- AIS_GraphicTool::GetInteriorColor (myDrawer->Link(), aColor);
- anAreaAsp->SetInteriorColor (aColor);
- aPrs->SetPrimitivesAspect (anAreaAsp);
- aPrs->SetPrimitivesAspect (aLineAsp);
- // Check if aspect of given type is set for the group,
- // because setting aspect for group with no already set aspect
- // can lead to loss of presentation data
- if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
- {
- aGroup->SetGroupPrimitivesAspect (anAreaAsp);
- }
- if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_LINE))
- {
- aGroup->SetGroupPrimitivesAspect (aLineAsp);
- }
- }
+ replaceAspectWithDef (aReplaceMap, PointAspect);
+ myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)());
}
- LoadRecomputable (AIS_WireFrame);
- LoadRecomputable (2);
+ replaceAspects (aReplaceMap);
+ SynchronizeAspects();
+ recomputeComputed();
}
//=======================================================================
//purpose :
//=======================================================================
-void AIS_Shape::setWidth (const Handle(AIS_Drawer)& theDrawer,
- const Standard_Real theLineWidth) const
+bool AIS_Shape::setWidth (const Handle(Prs3d_Drawer)& theDrawer,
+ const Standard_Real theLineWidth) const
{
- if (!theDrawer->HasLineAspect())
- {
- theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
- *theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
- }
- if (!theDrawer->HasWireAspect())
- {
- theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
- *theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect();
- }
- // disable dedicated line aspects
- theDrawer->SetFreeBoundaryAspect (theDrawer->LineAspect());
- theDrawer->SetUnFreeBoundaryAspect(theDrawer->LineAspect());
- theDrawer->SetSeenLineAspect (theDrawer->LineAspect());
+ bool toRecompute = theDrawer->SetOwnLineAspects();
// override width
theDrawer->LineAspect()->SetWidth (theLineWidth);
theDrawer->WireAspect()->SetWidth (theLineWidth);
+ theDrawer->FreeBoundaryAspect()->SetWidth (theLineWidth);
+ theDrawer->UnFreeBoundaryAspect()->SetWidth (theLineWidth);
+ theDrawer->SeenLineAspect()->SetWidth (theLineWidth);
+ theDrawer->FaceBoundaryAspect()->SetWidth (theLineWidth);
+ return toRecompute;
}
//=======================================================================
void AIS_Shape::SetWidth (const Standard_Real theLineWidth)
{
- setWidth (myDrawer, theLineWidth);
- myOwnWidth = theLineWidth;
- LoadRecomputable (AIS_WireFrame); // means that it is necessary to recompute only the wireframe....
- LoadRecomputable (2); // and the bounding box...
+ myOwnWidth = (Standard_ShortReal )theLineWidth;
+
+ if (!setWidth (myDrawer, theLineWidth)
+ || !myDrawer->HasLink())
+ {
+ SynchronizeAspects();
+ }
+ else
+ {
+ replaceWithNewOwnAspects();
+ }
+ recomputeComputed();
}
//=======================================================================
void AIS_Shape::UnsetWidth()
{
- if (myOwnWidth == 0.0)
+ if (myOwnWidth == 0.0f)
{
- myToRecomputeModes.Clear();
return;
}
- myOwnWidth = 0.0;
-
- Handle(Prs3d_LineAspect) anEmptyAsp;
-
+ myOwnWidth = 0.0f;
if (!HasColor())
{
- myDrawer->SetLineAspect (anEmptyAsp);
- myDrawer->SetWireAspect (anEmptyAsp);
- myDrawer->SetFreeBoundaryAspect (anEmptyAsp);
- myDrawer->SetUnFreeBoundaryAspect(anEmptyAsp);
- myDrawer->SetSeenLineAspect (anEmptyAsp);
+ Graphic3d_MapOfAspectsToAspects aReplaceMap;
+ replaceAspectWithDef (aReplaceMap, LineAspect);
+ replaceAspectWithDef (aReplaceMap, WireAspect);
+ replaceAspectWithDef (aReplaceMap, FreeBoundaryAspect);
+ replaceAspectWithDef (aReplaceMap, UnFreeBoundaryAspect);
+ replaceAspectWithDef (aReplaceMap, SeenLineAspect);
+ replaceAspectWithDef (aReplaceMap, FaceBoundaryAspect);
+ myDrawer->SetLineAspect (Handle(Prs3d_LineAspect)());
+ myDrawer->SetWireAspect (Handle(Prs3d_LineAspect)());
+ myDrawer->SetFreeBoundaryAspect (Handle(Prs3d_LineAspect)());
+ myDrawer->SetUnFreeBoundaryAspect(Handle(Prs3d_LineAspect)());
+ myDrawer->SetSeenLineAspect (Handle(Prs3d_LineAspect)());
+ myDrawer->SetFaceBoundaryAspect (Handle(Prs3d_LineAspect)());
+ replaceAspects (aReplaceMap);
}
else
{
- myDrawer->LineAspect() ->SetWidth (AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line));
- myDrawer->WireAspect() ->SetWidth (AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Wire));
- myDrawer->FreeBoundaryAspect() ->SetWidth (AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Free));
- myDrawer->UnFreeBoundaryAspect()->SetWidth (AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_UnFree));
- myDrawer->SeenLineAspect() ->SetWidth (AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Seen));
+ myDrawer->LineAspect() ->SetWidth (myDrawer->HasLink() ?
+ AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) : 1.);
+ myDrawer->WireAspect() ->SetWidth (myDrawer->HasLink() ?
+ AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Wire) : 1.);
+ myDrawer->FreeBoundaryAspect() ->SetWidth (myDrawer->HasLink() ?
+ AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Free) : 1.);
+ myDrawer->UnFreeBoundaryAspect()->SetWidth (myDrawer->HasLink() ?
+ AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_UnFree) : 1.);
+ myDrawer->SeenLineAspect() ->SetWidth (myDrawer->HasLink() ?
+ AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Seen) : 1.);
+ myDrawer->FaceBoundaryAspect() ->SetWidth (myDrawer->HasLink() ?
+ AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_FaceBoundary) : 1.);
+ SynchronizeAspects();
}
- LoadRecomputable (AIS_WireFrame);
+ recomputeComputed();
}
//=======================================================================
-//function : SetMaterial
-//purpose :
+//function : setMaterial
+//purpose :
//=======================================================================
-void AIS_Shape::SetMaterial(const Graphic3d_NameOfMaterial aMat)
+void AIS_Shape::setMaterial (const Handle(Prs3d_Drawer)& theDrawer,
+ const Graphic3d_MaterialAspect& theMaterial,
+ const Standard_Boolean theToKeepColor,
+ const Standard_Boolean theToKeepTransp) const
{
- SetMaterial(Graphic3d_MaterialAspect(aMat));
+ const Quantity_Color aColor = theDrawer->ShadingAspect()->Material (myCurrentFacingModel).Color();
+ const Standard_Real aTransp = theDrawer->ShadingAspect()->Transparency (myCurrentFacingModel);
+ theDrawer->SetupOwnShadingAspect();
+ theDrawer->ShadingAspect()->SetMaterial (theMaterial, myCurrentFacingModel);
+
+ if (theToKeepColor)
+ {
+ theDrawer->ShadingAspect()->SetColor (aColor, myCurrentFacingModel);
+ }
+ if (theToKeepTransp)
+ {
+ theDrawer->ShadingAspect()->SetTransparency (aTransp, myCurrentFacingModel);
+ }
}
//=======================================================================
void AIS_Shape::SetMaterial (const Graphic3d_MaterialAspect& theMat)
{
- if (!myDrawer->HasShadingAspect())
- {
- myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
- *myDrawer->ShadingAspect()->Aspect() = *myDrawer->Link()->ShadingAspect()->Aspect();
- }
+ const bool toRecompute = !myDrawer->HasOwnShadingAspect();
+ setMaterial (myDrawer, theMat, HasColor(), IsTransparent());
hasOwnMaterial = Standard_True;
- myDrawer->ShadingAspect()->SetMaterial (theMat, myCurrentFacingModel);
- if (HasColor())
+ if (!toRecompute
+ || !myDrawer->HasLink())
{
- myDrawer->ShadingAspect()->SetColor (myOwnColor, myCurrentFacingModel);
+ SynchronizeAspects();
}
- myDrawer->ShadingAspect()->SetTransparency (myTransparency, myCurrentFacingModel);
-
- if (!GetContext().IsNull())
+ else
{
- if (GetContext()->MainPrsMgr()->HasPresentation (this, AIS_Shaded))
- {
- Handle(Prs3d_Presentation) aPrs = GetContext()->MainPrsMgr()->Presentation (this, AIS_Shaded)->Presentation();
- Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (aPrs);
-
- Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
- aPrs->SetPrimitivesAspect (anAreaAsp);
- // Check if aspect of given type is set for the group,
- // because setting aspect for group with no already set aspect
- // can lead to loss of presentation data
- if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
- {
- aGroup->SetGroupPrimitivesAspect (anAreaAsp);
- }
- }
- myRecomputeEveryPrs = Standard_False; // no mode to recalculate :only viewer update
- myToRecomputeModes.Clear();
+ replaceWithNewOwnAspects();
}
}
return;
}
- if (HasColor()
- || IsTransparent())
+ if (!myDrawer->HasOwnShadingAspect())
+ {
+ //
+ }
+ else if (HasColor()
+ || IsTransparent()
+ || myDrawer->ShadingAspect()->Aspect()->ToMapTexture())
{
- myDrawer->ShadingAspect()->SetMaterial (myDrawer->Link()->ShadingAspect()->Material (myCurrentFacingModel),
- myCurrentFacingModel);
+ if(myDrawer->HasLink())
+ {
+ myDrawer->ShadingAspect()->SetMaterial (myDrawer->Link()->ShadingAspect()->Material (myCurrentFacingModel),
+ myCurrentFacingModel);
+ }
if (HasColor())
{
- myDrawer->ShadingAspect()->SetColor (myOwnColor, myCurrentFacingModel);
- myDrawer->ShadingAspect()->SetTransparency (myTransparency, myCurrentFacingModel);
+ myDrawer->ShadingAspect()->SetColor (myDrawer->Color(), myCurrentFacingModel);
+ myDrawer->ShadingAspect()->SetTransparency (myDrawer->Transparency(), myCurrentFacingModel);
}
+ SynchronizeAspects();
}
else
{
+ Graphic3d_MapOfAspectsToAspects aReplaceMap;
+ replaceAspectWithDef (aReplaceMap, ShadingAspect);
myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
+ replaceAspects (aReplaceMap);
}
- hasOwnMaterial = Standard_False;
-
- if (!GetContext().IsNull())
- {
- if (GetContext()->MainPrsMgr()->HasPresentation (this, AIS_Shaded))
- {
- Handle(Prs3d_Presentation) aPrs = GetContext()->MainPrsMgr()->Presentation (this, AIS_Shaded)->Presentation();
- Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (aPrs);
- Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
- aPrs->SetPrimitivesAspect (anAreaAsp);
- // Check if aspect of given type is set for the group,
- // because setting aspect for group with no already set aspect
- // can lead to loss of presentation data
- if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
- {
- aGroup->SetGroupPrimitivesAspect (anAreaAsp);
- }
- }
- }
- myRecomputeEveryPrs = Standard_False; // no mode to recalculate :only viewer update
- myToRecomputeModes.Clear();
}
//=======================================================================
//purpose :
//=======================================================================
-void AIS_Shape::setTransparency (const Handle(AIS_Drawer)& theDrawer,
- const Standard_Real theValue) const
+void AIS_Shape::setTransparency (const Handle(Prs3d_Drawer)& theDrawer,
+ const Standard_Real theValue) const
{
- if (!theDrawer->HasShadingAspect())
- {
- theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
- *theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
- }
-
+ theDrawer->SetupOwnShadingAspect();
// override transparency
theDrawer->ShadingAspect()->SetTransparency (theValue, myCurrentFacingModel);
}
void AIS_Shape::SetTransparency (const Standard_Real theValue)
{
+ const bool toRecompute = !myDrawer->HasOwnShadingAspect();
setTransparency (myDrawer, theValue);
- myTransparency = theValue;
+ myDrawer->SetTransparency ((Standard_ShortReal )theValue);
- if (!GetContext().IsNull())
+ if (!toRecompute
+ || !myDrawer->HasLink())
{
- if (GetContext()->MainPrsMgr()->HasPresentation (this, AIS_Shaded))
- {
- Handle(Prs3d_Presentation) aPrs = GetContext()->MainPrsMgr()->Presentation (this, AIS_Shaded)->Presentation();
- Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (aPrs);
- Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
- aPrs->SetPrimitivesAspect (anAreaAsp);
- // force highest priority for transparent objects
- aPrs->SetDisplayPriority (10);
- // Check if aspect of given type is set for the group,
- // because setting aspect for group with no already set aspect
- // can lead to loss of presentation data
- if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
- {
- aGroup->SetGroupPrimitivesAspect (anAreaAsp);
- }
- }
+ SynchronizeAspects();
+ }
+ else
+ {
+ replaceWithNewOwnAspects();
}
- myRecomputeEveryPrs = Standard_False; // no mode to recalculate - only viewer update
- myToRecomputeModes.Clear();
}
//=======================================================================
void AIS_Shape::UnsetTransparency()
{
- myTransparency = 0.0;
- if (!myDrawer->HasShadingAspect())
+ myDrawer->SetTransparency (0.0f);
+ if (!myDrawer->HasOwnShadingAspect())
{
return;
}
- else if (HasColor() || HasMaterial())
+ else if (HasColor()
+ || HasMaterial()
+ || myDrawer->ShadingAspect()->Aspect()->ToMapTexture())
{
myDrawer->ShadingAspect()->SetTransparency (0.0, myCurrentFacingModel);
+ SynchronizeAspects();
}
else
{
+ Graphic3d_MapOfAspectsToAspects aReplaceMap;
+ replaceAspectWithDef (aReplaceMap, ShadingAspect);
myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
+ replaceAspects (aReplaceMap);
}
-
- if (!GetContext().IsNull())
- {
- if (GetContext()->MainPrsMgr()->HasPresentation (this, AIS_Shaded))
- {
- Handle(Prs3d_Presentation) aPrs = GetContext()->MainPrsMgr()->Presentation (this, AIS_Shaded)->Presentation();
- Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (aPrs);
- Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
- aPrs->SetPrimitivesAspect (anAreaAsp);
- // Check if aspect of given type is set for the group,
- // because setting aspect for group with no already set aspect
- // can lead to loss of presentation data
- if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
- {
- aGroup->SetGroupPrimitivesAspect (anAreaAsp);
- }
- aPrs->ResetDisplayPriority();
- }
- }
- myRecomputeEveryPrs = Standard_False; // no mode to recalculate :only viewer update
- myToRecomputeModes.Clear();
-}
-
-//=======================================================================
-//function : LoadRecomputable
-//purpose :
-//=======================================================================
-
-void AIS_Shape::LoadRecomputable(const Standard_Integer TheMode)
-{
- myRecomputeEveryPrs = Standard_False;
- if(!IsInList(myToRecomputeModes,TheMode))
- myToRecomputeModes.Append(TheMode);
}
//=======================================================================
const Bnd_Box& AIS_Shape::BoundingBox()
{
- if (myshape.ShapeType() == TopAbs_COMPOUND) {
- TopoDS_Iterator anExplor (myshape);
-
- if (!anExplor.More()) { // empty Shape -> empty Assembly.
- myBB.SetVoid();
- return myBB;
- }
+ if (myshape.ShapeType() == TopAbs_COMPOUND && myshape.NbChildren() == 0)
+ {
+ // empty Shape -> empty Assembly.
+ myBB.SetVoid ();
+ return myBB;
}
if(myCompBB) {
Standard_Boolean AIS_Shape::SetOwnDeviationCoefficient ()
{
- Standard_Boolean itSet = myDrawer->IsOwnDeviationCoefficient();
+ Standard_Boolean itSet = myDrawer->HasOwnDeviationCoefficient();
if(itSet) myDrawer->SetDeviationCoefficient();
return itSet;
}
Standard_Boolean AIS_Shape::SetOwnHLRDeviationCoefficient ()
{
- Standard_Boolean itSet = myDrawer->IsOwnHLRDeviationCoefficient();
+ Standard_Boolean itSet = myDrawer->HasOwnHLRDeviationCoefficient();
if(itSet) myDrawer->SetHLRDeviationCoefficient();
return itSet;
Standard_Boolean AIS_Shape::SetOwnDeviationAngle ()
{
- Standard_Boolean itSet = myDrawer->IsOwnDeviationAngle();
+ Standard_Boolean itSet = myDrawer->HasOwnDeviationAngle();
if(itSet) myDrawer->SetDeviationAngle();
return itSet;
Standard_Boolean AIS_Shape::SetOwnHLRDeviationAngle ()
{
- Standard_Boolean itSet = myDrawer->IsOwnHLRDeviationAngle();
+ Standard_Boolean itSet = myDrawer->HasOwnHLRDeviationAngle();
if(itSet) myDrawer->SetHLRAngle();
return itSet;
void AIS_Shape::SetOwnDeviationCoefficient ( const Standard_Real aCoefficient )
{
myDrawer->SetDeviationCoefficient( aCoefficient );
- SetToUpdate(0) ; // WireFrame
- SetToUpdate(1) ; // Shadding
+ SetToUpdate();
}
//=======================================================================
//purpose :
//=======================================================================
-void AIS_Shape::SetOwnDeviationAngle ( const Standard_Real anAngle )
+void AIS_Shape::SetOwnDeviationAngle (const Standard_Real theAngle)
{
-
- myDrawer->SetDeviationAngle(anAngle );
- SetToUpdate(0) ; // WireFrame
+ myDrawer->SetDeviationAngle (theAngle);
+ SetToUpdate (AIS_WireFrame);
}
//=======================================================================
//function : SetOwnDeviationAngle
SetOwnDeviationAngle(anAngle) ;
SetOwnDeviationCoefficient(OutDefl) ;
myInitAng = anAngle;
- SetToUpdate(0);
- SetToUpdate(1);
+ SetToUpdate();
}
//=======================================================================
{
aCoefficient = myDrawer->DeviationCoefficient();
aPreviousCoefficient = myDrawer->PreviousDeviationCoefficient ();
- return myDrawer->IsOwnDeviationCoefficient() ;
+ return myDrawer->HasOwnDeviationCoefficient() ;
}
//=======================================================================
{
aCoefficient = myDrawer->HLRDeviationCoefficient();
aPreviousCoefficient = myDrawer->PreviousHLRDeviationCoefficient ();
- return myDrawer->IsOwnHLRDeviationCoefficient();
+ return myDrawer->HasOwnHLRDeviationCoefficient();
}
{
anAngle = myDrawer->DeviationAngle();
aPreviousAngle = myDrawer->PreviousDeviationAngle ();
- return myDrawer->IsOwnDeviationAngle();
+ return myDrawer->HasOwnDeviationAngle();
}
//=======================================================================
{
anAngle = myDrawer->HLRAngle();
aPreviousAngle = myDrawer->PreviousHLRDeviationAngle ();
- return myDrawer->IsOwnHLRDeviationAngle();
+ return myDrawer->HasOwnHLRDeviationAngle();
}