#include <Graphic3d_MaterialAspect.hxx>
#include <Graphic3d_SequenceOfGroup.hxx>
+#include <Prs3d.hxx>
#include <Prs3d_Presentation.hxx>
#include <Prs3d_Root.hxx>
#include <Prs3d_ShadingAspect.hxx>
static Standard_Boolean myFirstCompute;
-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;
- }
- }
- return aDeflection;
-}
-
-void AIS_Shape::DisplayBox(const Handle(Prs3d_Presentation)& aPrs,
- const Bnd_Box& B,
- const Handle(Prs3d_Drawer)& aDrawer)
-{
- 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);
-}
-
static Standard_Boolean IsInList(const TColStd_ListOfInteger& LL, const Standard_Integer aMode)
{
TColStd_ListIteratorOfListOfInteger It(LL);
case 0:{
try { OCC_CATCH_SIGNALS StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer); }
catch (Standard_Failure) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout << "AIS_Shape::Compute() failed"<< endl;
-#endif
cout << "a Shape should be incorrect : No Compute can be maked on it "<< endl;
+#endif
// presentation of the bounding box is calculated
// Compute(aPresentationManager,aPrs,2);
}
StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer);
}
catch (Standard_Failure) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout << "AIS_Shape::Compute() in ShadingMode failed"<< endl;
#endif
StdPrs_WFShape::Add(aPrs,myshape,myDrawer);
{
// bounding box
if (IsInfinite()) StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
- else DisplayBox(aPrs,BoundingBox(),myDrawer);
+ else StdPrs_WFDeflectionRestrictedFace::AddBox (aPrs, BoundingBox(), myDrawer);
}
} // end switch
aPrs->ReCompute(); // for hidden line recomputation if necessary...
Standard_Boolean isOwnHLRDeviationCoefficient = OwnHLRDeviationCoefficient(newcoeff,prevcoeff);
if (((Abs (newangle - prevangle) > Precision::Angular()) && isOwnHLRDeviationAngle) ||
((Abs (newcoeff - prevcoeff) > Precision::Confusion()) && isOwnHLRDeviationCoefficient)) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout << "AIS_Shape : compute"<<endl;
cout << "newangle : " << newangle << " # de " << "prevangl : " << prevangle << " OU "<<endl;
cout << "newcoeff : " << newcoeff << " # de " << "prevcoeff : " << prevcoeff << endl;
}
}
catch (Standard_Failure) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout <<"AIS_Shape::Compute(Proj) HLR Algorithm failed" << endl;
#endif
StdPrs_WFShape::Add(aPresentation,SH,myDrawer);
static TopAbs_ShapeEnum TypOfSel;
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_Real aDeflection = Prs3d::GetDeflection(shape, myDrawer);
Standard_Boolean autoTriangulation = Standard_True;
try {
OCC_CATCH_SIGNALS
LoadRecomputable (AIS_WireFrame);
}
+//=======================================================================
+//function : setMaterial
+//purpose :
+//=======================================================================
+
+void AIS_Shape::setMaterial (const Handle(AIS_Drawer)& theDrawer,
+ const Graphic3d_MaterialAspect& theMaterial,
+ const Standard_Boolean theToKeepColor,
+ const Standard_Boolean theToKeepTransp) const
+{
+ const Quantity_Color aColor = theDrawer->ShadingAspect()->Material (myCurrentFacingModel).Color();
+ const Standard_Real aTransp = theDrawer->ShadingAspect()->Transparency (myCurrentFacingModel);
+ if (!theDrawer->HasShadingAspect())
+ {
+ theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
+ *theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
+ }
+ theDrawer->ShadingAspect()->SetMaterial (theMaterial, myCurrentFacingModel);
+
+ if (theToKeepColor)
+ {
+ theDrawer->ShadingAspect()->SetColor (aColor, myCurrentFacingModel);
+ }
+ if (theToKeepTransp)
+ {
+ theDrawer->ShadingAspect()->SetTransparency (aTransp, myCurrentFacingModel);
+ }
+}
+
//=======================================================================
//function : SetMaterial
//purpose :
void AIS_Shape::SetMaterial (const Graphic3d_MaterialAspect& theMat)
{
- if (!myDrawer->HasShadingAspect())
- {
- myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
- *myDrawer->ShadingAspect()->Aspect() = *myDrawer->Link()->ShadingAspect()->Aspect();
- }
+ setMaterial (myDrawer, theMat, HasColor(), IsTransparent());
hasOwnMaterial = Standard_True;
- myDrawer->ShadingAspect()->SetMaterial (theMat, myCurrentFacingModel);
- if (HasColor())
- {
- myDrawer->ShadingAspect()->SetColor (myOwnColor, myCurrentFacingModel);
- }
- myDrawer->ShadingAspect()->SetTransparency (myTransparency, myCurrentFacingModel);
-
// modify shading presentation without re-computation
const PrsMgr_Presentations& aPrsList = Presentations();
Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();