1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-07-25 12:55:50 +03:00
occt/src/AIS/AIS_Drawer.cxx
apl a2d5ab2e7f 0023407: Draw face outlines for XDE objects
FaceOutline aspect and flag added to AIS_Drawer, Prs3d_Drawer.cdl
FaceOutlines computed by StdPrs_ShadedShape and build upon the edge triangulation.
"vshowoutlines" draw command for testing outlines on AIS_Shapes,
"XShowOutlines" draw command for testing outlines on XCAF objects.
remarks corrected:
- FaceOutline renamed to FaceBoundary
- Graphic3d_ArrayOfSegments with edges used instead of Graphic3d_ArrayOfPolylines with bounds.
draw boundaries in separate Graphic3d_Group.
Adding test cases bugs/vis/CR23407_1 CR23407_2
2012-09-14 14:37:57 +04:00

321 lines
11 KiB
C++
Executable File

// Copyright (c) 1998-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <AIS_Drawer.ixx>
#include <Standard_ProgramError.hxx>
AIS_Drawer::AIS_Drawer():
myLink(new Prs3d_Drawer()),
hasLocalAttributes(Standard_False),
myhasOwnDeviationCoefficient(Standard_False),
myPreviousDeviationCoefficient(0.1),
myhasOwnHLRDeviationCoefficient (Standard_False),
myhasOwnDeviationAngle (Standard_False),
myhasOwnHLRDeviationAngle (Standard_False),
myHasOwnFaceBoundaryDraw (Standard_False)
{
SetMaximalParameterValue(500000.);
myLink->SetMaximalParameterValue(500000.);
}
Aspect_TypeOfDeflection AIS_Drawer::TypeOfDeflection () const
{
return myLink->TypeOfDeflection();
}
Standard_Boolean AIS_Drawer::IsoOnPlane() const
{
return myLink->IsoOnPlane();
}
Standard_Integer AIS_Drawer::Discretisation() const
{
return myLink->Discretisation();
}
Quantity_Length AIS_Drawer::MaximalChordialDeviation() const
{
return myLink->MaximalChordialDeviation();
}
//=======================================================================
//function : SetDeviationCoefficient
//purpose :
//=======================================================================
void AIS_Drawer::SetDeviationCoefficient ( const Standard_Real aCoefficient )
{
myPreviousDeviationCoefficient = DeviationCoefficient() ;
myOwnDeviationCoefficient = aCoefficient ;
myhasOwnDeviationCoefficient = Standard_True;
}
//=======================================================================
//function : SetHLRDeviationCoefficient
//purpose :
//=======================================================================
void AIS_Drawer::SetHLRDeviationCoefficient ( const Standard_Real aCoefficient )
{
myPreviousHLRDeviationCoefficient = HLRDeviationCoefficient() ;
myOwnHLRDeviationCoefficient = aCoefficient ;
myhasOwnHLRDeviationCoefficient = Standard_True;
}
//=======================================================================
//function : SetDeviationAngle
//purpose :
//=======================================================================
void AIS_Drawer::SetDeviationAngle ( const Standard_Real anAngle )
{
myPreviousDeviationAngle = DeviationAngle() ;
myOwnDeviationAngle = anAngle ;
myhasOwnDeviationAngle = Standard_True;
}
//=======================================================================
//function : SetHLRAngle
//purpose :
//=======================================================================
void AIS_Drawer::SetHLRAngle ( const Standard_Real anAngle )
{
myPreviousHLRDeviationAngle = HLRAngle() ;
myOwnHLRDeviationAngle = anAngle ;
myhasOwnHLRDeviationAngle = Standard_True;
}
/////// Get
//=======================================================================
//function : DeviationCoefficient
//purpose :
//=======================================================================
Standard_Real AIS_Drawer::DeviationCoefficient () const
{
return myhasOwnDeviationCoefficient? myOwnDeviationCoefficient :myLink->DeviationCoefficient();
}
//=======================================================================
//function : HLRDeviationCoefficient
//purpose :
//=======================================================================
Standard_Real AIS_Drawer::HLRDeviationCoefficient () const
{
return myhasOwnHLRDeviationCoefficient?myOwnHLRDeviationCoefficient : myLink->HLRDeviationCoefficient() ;
}
//=======================================================================
//function : DeviationAngle
//purpose :
//=======================================================================
Standard_Real AIS_Drawer::DeviationAngle () const
{
return myhasOwnDeviationAngle ? myOwnDeviationAngle : myLink->DeviationAngle();
}
//=======================================================================
//function : HLRAngle
//purpose :
//=======================================================================
Standard_Real AIS_Drawer::HLRAngle () const
{
return myhasOwnHLRDeviationAngle ? myOwnHLRDeviationAngle : myLink->HLRAngle();
}
Standard_Real AIS_Drawer::MaximalParameterValue () const
{ return myLink->MaximalParameterValue();}
Handle (Prs3d_IsoAspect) AIS_Drawer::UIsoAspect ()
{ return myUIsoAspect.IsNull() ? myLink->UIsoAspect (): myUIsoAspect;}
Handle (Prs3d_IsoAspect) AIS_Drawer::VIsoAspect ()
{ return myVIsoAspect.IsNull() ? myLink->VIsoAspect (): myVIsoAspect;}
Handle (Prs3d_LineAspect) AIS_Drawer::FreeBoundaryAspect ()
{return myFreeBoundaryAspect.IsNull() ? myLink->FreeBoundaryAspect (): myFreeBoundaryAspect;}
Standard_Boolean AIS_Drawer::FreeBoundaryDraw () const
{return myLink->FreeBoundaryDraw();}
Handle (Prs3d_LineAspect) AIS_Drawer::UnFreeBoundaryAspect ()
{return myUnFreeBoundaryAspect.IsNull() ? myLink->UnFreeBoundaryAspect (): myUnFreeBoundaryAspect;}
Standard_Boolean AIS_Drawer::UnFreeBoundaryDraw () const
{return myLink->UnFreeBoundaryDraw ();}
Handle (Prs3d_LineAspect) AIS_Drawer::WireAspect ()
{ return myWireAspect.IsNull()? myLink->WireAspect (): myWireAspect;}
Standard_Boolean AIS_Drawer::WireDraw () const
{ return myLink->WireDraw();}
Handle (Prs3d_LineAspect) AIS_Drawer::LineAspect ()
{ return myLineAspect.IsNull() ? myLink->LineAspect (): myLineAspect;}
Handle (Prs3d_TextAspect) AIS_Drawer::TextAspect ()
{ return myTextAspect.IsNull() ? myLink->TextAspect () : myTextAspect ;}
Handle (Prs3d_ShadingAspect) AIS_Drawer::ShadingAspect ()
{
return myShadingAspect.IsNull() ? myLink->ShadingAspect () : myShadingAspect ;
}
Standard_Boolean AIS_Drawer::ShadingAspectGlobal() const
{ return myLink->ShadingAspectGlobal();}
Standard_Boolean AIS_Drawer::LineArrowDraw () const
{ return myLink->LineArrowDraw();}
Handle (Prs3d_ArrowAspect) AIS_Drawer::ArrowAspect()
{return myArrowAspect.IsNull()? myLink->ArrowAspect () : myArrowAspect;}
Handle (Prs3d_PointAspect) AIS_Drawer::PointAspect()
{return myPointAspect.IsNull()? myLink->PointAspect () : myPointAspect;}
Standard_Boolean AIS_Drawer::DrawHiddenLine () const
{return myLink->DrawHiddenLine();}
Handle (Prs3d_LineAspect) AIS_Drawer::HiddenLineAspect ()
{return myHiddenLineAspect.IsNull()? myLink->HiddenLineAspect () : myHiddenLineAspect;}
Handle (Prs3d_LineAspect) AIS_Drawer::SeenLineAspect ()
{ return mySeenLineAspect.IsNull() ? myLink->SeenLineAspect (): mySeenLineAspect ;}
Handle (Prs3d_LineAspect) AIS_Drawer::VectorAspect ()
{return myVectorAspect.IsNull()? myLink->VectorAspect () : myVectorAspect;}
Handle (Prs3d_DatumAspect) AIS_Drawer::DatumAspect ()
{return myDatumAspect.IsNull()? myLink->DatumAspect () : myDatumAspect; }
Handle (Prs3d_PlaneAspect) AIS_Drawer::PlaneAspect ()
{return myPlaneAspect.IsNull() ? myLink->PlaneAspect (): myPlaneAspect;}
Handle (Prs3d_LengthAspect) AIS_Drawer::LengthAspect ()
{return myLengthAspect.IsNull()? myLink->LengthAspect () : myLengthAspect ;}
Handle (Prs3d_AngleAspect) AIS_Drawer::AngleAspect ()
{return myAngleAspect.IsNull()? myLink->AngleAspect () :myAngleAspect ;}
Handle (Prs3d_RadiusAspect) AIS_Drawer::RadiusAspect () const
{return myRadiusAspect.IsNull()? myLink->RadiusAspect():myRadiusAspect; }
Handle (Prs3d_LineAspect) AIS_Drawer::SectionAspect ()
{return mySectionAspect.IsNull()? myLink->SectionAspect (): mySectionAspect;}
const Handle (Prs3d_Drawer)& AIS_Drawer::Link()
{
if(myLink.IsNull()) myLink = new Prs3d_Drawer();
return myLink;
}
void AIS_Drawer::ClearLocalAttributes()
{
if(myLink.IsNull()) return;
// attention pas beau....
// The Handles
if(!myUIsoAspect.IsNull()) myUIsoAspect.Nullify();
if(!myVIsoAspect.IsNull()) myVIsoAspect.Nullify();
if(!myFreeBoundaryAspect.IsNull()) myFreeBoundaryAspect.Nullify();
if(!myUnFreeBoundaryAspect.IsNull()) myUnFreeBoundaryAspect.Nullify();
if(!myWireAspect.IsNull()) myWireAspect.Nullify();
if(!myLineAspect.IsNull()) myLineAspect.Nullify();
if(!myTextAspect.IsNull()) myTextAspect.Nullify();
if(!myShadingAspect.IsNull()) myShadingAspect.Nullify();
if(!myPointAspect.IsNull()) myPointAspect.Nullify();
if(!myPlaneAspect.IsNull()) myPlaneAspect.Nullify();
if(!myArrowAspect.IsNull()) myArrowAspect.Nullify();
if(!myHiddenLineAspect.IsNull()) myHiddenLineAspect.Nullify();
if(!mySeenLineAspect.IsNull()) mySeenLineAspect.Nullify();
if(!myVectorAspect.IsNull()) myVectorAspect .Nullify();
if(!myDatumAspect.IsNull()) myDatumAspect.Nullify();
if(!myLengthAspect.IsNull()) myLengthAspect.Nullify();
if(!myAngleAspect.IsNull()) myAngleAspect.Nullify();
if(!myRadiusAspect.IsNull()) myRadiusAspect.Nullify();
if(!mySectionAspect.IsNull()) mySectionAspect.Nullify();
if( myhasOwnHLRDeviationCoefficient ) myhasOwnHLRDeviationCoefficient = Standard_False;
if(myhasOwnHLRDeviationAngle ) myhasOwnHLRDeviationAngle = Standard_False;
if (!myFaceBoundaryAspect.IsNull()) myFaceBoundaryAspect.Nullify();
myHasOwnFaceBoundaryDraw = Standard_False;
hasLocalAttributes = Standard_False;
}
// =======================================================================
// function : SetFaceBoundaryDraw
// purpose :
// =======================================================================
void AIS_Drawer::SetFaceBoundaryDraw (const Standard_Boolean theIsEnabled)
{
myHasOwnFaceBoundaryDraw = Standard_True;
myFaceBoundaryDraw = theIsEnabled;
}
// =======================================================================
// function : IsFaceBoundaryDraw
// purpose :
// =======================================================================
Standard_Boolean AIS_Drawer::IsFaceBoundaryDraw() const
{
if (!IsOwnFaceBoundaryDraw ())
{
return myLink->IsFaceBoundaryDraw ();
}
return myFaceBoundaryDraw;
}
// =======================================================================
// function : SetFaceBoundaryAspect
// purpose :
// =======================================================================
void AIS_Drawer::SetFaceBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect)
{
myFaceBoundaryAspect = theAspect;
}
// =======================================================================
// function : FaceBoundaryAspect
// purpose :
// =======================================================================
Handle_Prs3d_LineAspect AIS_Drawer::FaceBoundaryAspect()
{
if (!IsOwnFaceBoundaryAspect ())
{
return myLink->FaceBoundaryAspect ();
}
return myFaceBoundaryAspect;
}