mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-16 10:08:36 +03:00
0022302: BRepMesh_IncrimentalMesh calls for each face of shape on vdisplay
This commit is contained in:
parent
f10018adfe
commit
3c34883cdc
@ -84,13 +84,13 @@
|
|||||||
static Standard_Boolean myFirstCompute;
|
static Standard_Boolean myFirstCompute;
|
||||||
|
|
||||||
Standard_Real AIS_Shape::GetDeflection(const TopoDS_Shape& aShape,
|
Standard_Real AIS_Shape::GetDeflection(const TopoDS_Shape& aShape,
|
||||||
const Handle(Prs3d_Drawer)& aDrawer)
|
const Handle(Prs3d_Drawer)& aDrawer)
|
||||||
{
|
{
|
||||||
// WARNING: this same piece of code appears several times in Prs3d classes
|
// WARNING: this same piece of code appears several times in Prs3d classes
|
||||||
Standard_Real aDeflection;
|
Standard_Real aDeflection = aDrawer->MaximalChordialDeviation();
|
||||||
if (aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE) {
|
if (aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE) {
|
||||||
Bnd_Box B;
|
Bnd_Box B;
|
||||||
BRepBndLib::Add(aShape, B);
|
BRepBndLib::Add(aShape, B, Standard_False);
|
||||||
if ( ! B.IsVoid() )
|
if ( ! B.IsVoid() )
|
||||||
{
|
{
|
||||||
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
||||||
@ -98,17 +98,13 @@ Standard_Real AIS_Shape::GetDeflection(const TopoDS_Shape& aShape,
|
|||||||
aDeflection = Max( aXmax-aXmin, Max(aYmax-aYmin, aZmax-aZmin)) *
|
aDeflection = Max( aXmax-aXmin, Max(aYmax-aYmin, aZmax-aZmin)) *
|
||||||
aDrawer->DeviationCoefficient() * 4;
|
aDrawer->DeviationCoefficient() * 4;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
aDeflection = aDrawer->MaximalChordialDeviation();
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
aDeflection = aDrawer->MaximalChordialDeviation();
|
|
||||||
return aDeflection;
|
return aDeflection;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AIS_Shape::DisplayBox(const Handle(Prs3d_Presentation)& aPrs,
|
void AIS_Shape::DisplayBox(const Handle(Prs3d_Presentation)& aPrs,
|
||||||
const Bnd_Box& B,
|
const Bnd_Box& B,
|
||||||
const Handle(Prs3d_Drawer)& aDrawer)
|
const Handle(Prs3d_Drawer)& aDrawer)
|
||||||
{
|
{
|
||||||
Standard_Real X[2],Y[2],Z[2];
|
Standard_Real X[2],Y[2],Z[2];
|
||||||
Standard_Integer Indx [16] ;
|
Standard_Integer Indx [16] ;
|
||||||
@ -133,7 +129,7 @@ void AIS_Shape::DisplayBox(const Handle(Prs3d_Presentation)& aPrs,
|
|||||||
for(Standard_Integer k=0;k<=1;k++)
|
for(Standard_Integer k=0;k<=1;k++)
|
||||||
for(Standard_Integer j=0;j<=1;j++)
|
for(Standard_Integer j=0;j<=1;j++)
|
||||||
for(Standard_Integer i=0;i<=1;i++)
|
for(Standard_Integer i=0;i<=1;i++)
|
||||||
V(++Rank) = Graphic3d_Vertex(X[i],Y[j],Z[k]);
|
V(++Rank) = Graphic3d_Vertex(X[i],Y[j],Z[k]);
|
||||||
|
|
||||||
|
|
||||||
Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(aPrs);
|
Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(aPrs);
|
||||||
@ -210,8 +206,8 @@ Standard_Boolean AIS_Shape::AcceptShapeDecomposition() const
|
|||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
|
void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
|
||||||
const Handle(Prs3d_Presentation)& aPrs,
|
const Handle(Prs3d_Presentation)& aPrs,
|
||||||
const Standard_Integer aMode)
|
const Standard_Integer aMode)
|
||||||
{
|
{
|
||||||
aPrs->Clear();
|
aPrs->Clear();
|
||||||
if(myshape.IsNull()) return;
|
if(myshape.IsNull()) return;
|
||||||
@ -258,42 +254,42 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
|
|||||||
|
|
||||||
|
|
||||||
if (OwnDeviationAngle(newangle,prevangle) ||
|
if (OwnDeviationAngle(newangle,prevangle) ||
|
||||||
OwnDeviationCoefficient(newcoeff,prevcoeff))
|
OwnDeviationCoefficient(newcoeff,prevcoeff))
|
||||||
if (Abs (newangle - prevangle) > Precision::Angular() ||
|
if (Abs (newangle - prevangle) > Precision::Angular() ||
|
||||||
Abs (newcoeff - prevcoeff) > Precision::Confusion() ) {
|
Abs (newcoeff - prevcoeff) > Precision::Confusion() ) {
|
||||||
#ifdef DEB
|
#ifdef DEB
|
||||||
cout << "AIS_Shape : compute"<<endl;
|
cout << "AIS_Shape : compute"<<endl;
|
||||||
cout << "newangl : " << newangle << " # de " << "prevangl : " << prevangle << " OU "<<endl;
|
cout << "newangl : " << newangle << " # de " << "prevangl : " << prevangle << " OU "<<endl;
|
||||||
cout << "newcoeff : " << newcoeff << " # de " << "prevcoeff : " << prevcoeff << endl;
|
cout << "newcoeff : " << newcoeff << " # de " << "prevcoeff : " << prevcoeff << endl;
|
||||||
#endif
|
#endif
|
||||||
BRepTools::Clean(myshape);
|
BRepTools::Clean(myshape);
|
||||||
}
|
}
|
||||||
|
|
||||||
//shading only on face...
|
//shading only on face...
|
||||||
if ((Standard_Integer) myshape.ShapeType()>4)
|
if ((Standard_Integer) myshape.ShapeType()>4)
|
||||||
StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
|
StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
|
||||||
else {
|
else {
|
||||||
myDrawer->SetShadingAspectGlobal(Standard_False);
|
myDrawer->SetShadingAspectGlobal(Standard_False);
|
||||||
if (IsInfinite()) StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
|
if (IsInfinite()) StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
|
||||||
else {
|
else {
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
OCC_CATCH_SIGNALS
|
OCC_CATCH_SIGNALS
|
||||||
StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer);
|
StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer);
|
||||||
}
|
}
|
||||||
catch (Standard_Failure) {
|
catch (Standard_Failure) {
|
||||||
#ifdef DEB
|
#ifdef DEB
|
||||||
cout << "AIS_Shape::Compute() in ShadingMode failed"<< endl;
|
cout << "AIS_Shape::Compute() in ShadingMode failed"<< endl;
|
||||||
#endif
|
#endif
|
||||||
StdPrs_WFShape::Add(aPrs,myshape,myDrawer);
|
StdPrs_WFShape::Add(aPrs,myshape,myDrawer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef BUC60918
|
#ifdef BUC60918
|
||||||
Standard_Real value = Transparency() ;
|
Standard_Real value = Transparency() ;
|
||||||
if( value > 0. ) {
|
if( value > 0. ) {
|
||||||
SetTransparency( value );
|
SetTransparency( value );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
@ -317,8 +313,8 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager2d)& /*aPresentationManager*/,
|
void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager2d)& /*aPresentationManager*/,
|
||||||
const Handle(Graphic2d_GraphicObject)& /*aGRO*/,
|
const Handle(Graphic2d_GraphicObject)& /*aGRO*/,
|
||||||
const Standard_Integer /*aMode*/)
|
const Standard_Integer /*aMode*/)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,7 +323,7 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager2d)& /*aPresentat
|
|||||||
//purpose : Hidden Line Removal
|
//purpose : Hidden Line Removal
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
|
void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
|
||||||
const Handle(Prs3d_Presentation)& aPresentation)
|
const Handle(Prs3d_Presentation)& aPresentation)
|
||||||
{
|
{
|
||||||
Compute(aProjector,aPresentation,myshape);
|
Compute(aProjector,aPresentation,myshape);
|
||||||
}
|
}
|
||||||
@ -338,8 +334,8 @@ void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
|
void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
|
||||||
const Handle(Geom_Transformation)& TheTrsf,
|
const Handle(Geom_Transformation)& TheTrsf,
|
||||||
const Handle(Prs3d_Presentation)& aPresentation)
|
const Handle(Prs3d_Presentation)& aPresentation)
|
||||||
{
|
{
|
||||||
const TopLoc_Location& loc = myshape.Location();
|
const TopLoc_Location& loc = myshape.Location();
|
||||||
TopoDS_Shape shbis = myshape.Located(TopLoc_Location(TheTrsf->Trsf())*loc);
|
TopoDS_Shape shbis = myshape.Located(TopLoc_Location(TheTrsf->Trsf())*loc);
|
||||||
@ -352,8 +348,8 @@ void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
|
void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
|
||||||
const Handle(Prs3d_Presentation)& aPresentation,
|
const Handle(Prs3d_Presentation)& aPresentation,
|
||||||
const TopoDS_Shape& SH)
|
const TopoDS_Shape& SH)
|
||||||
{
|
{
|
||||||
if (SH.ShapeType() == TopAbs_COMPOUND) {
|
if (SH.ShapeType() == TopAbs_COMPOUND) {
|
||||||
#ifdef BUC60547
|
#ifdef BUC60547
|
||||||
@ -379,7 +375,7 @@ void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
|
|||||||
if (OwnHLRDeviationAngle(newangle,prevangle) || OwnHLRDeviationCoefficient(newcoeff, prevcoeff))
|
if (OwnHLRDeviationAngle(newangle,prevangle) || OwnHLRDeviationCoefficient(newcoeff, prevcoeff))
|
||||||
|
|
||||||
if (Abs (newangle - prevangle) > Precision::Angular() ||
|
if (Abs (newangle - prevangle) > Precision::Angular() ||
|
||||||
Abs (newcoeff - prevcoeff) > Precision::Confusion() ) {
|
Abs (newcoeff - prevcoeff) > Precision::Confusion() ) {
|
||||||
#ifdef DEB
|
#ifdef DEB
|
||||||
cout << "AIS_Shape : compute"<<endl;
|
cout << "AIS_Shape : compute"<<endl;
|
||||||
cout << "newangle : " << newangle << " # de " << "prevangl : " << prevangle << " OU "<<endl;
|
cout << "newangle : " << newangle << " # de " << "prevangl : " << prevangle << " OU "<<endl;
|
||||||
@ -471,7 +467,7 @@ Standard_Integer AIS_Shape::SelectionMode(const TopAbs_ShapeEnum aType)
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
|
void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
|
||||||
const Standard_Integer aMode)
|
const Standard_Integer aMode)
|
||||||
{
|
{
|
||||||
if(myshape.IsNull()) return;
|
if(myshape.IsNull()) return;
|
||||||
if (myshape.ShapeType() == TopAbs_COMPOUND) {
|
if (myshape.ShapeType() == TopAbs_COMPOUND) {
|
||||||
@ -496,20 +492,7 @@ void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
|
|||||||
|
|
||||||
// POP protection against crash in low layers
|
// POP protection against crash in low layers
|
||||||
|
|
||||||
Standard_Real aDeflection = myDrawer->MaximalChordialDeviation();
|
Standard_Real aDeflection = GetDeflection(shape, myDrawer);
|
||||||
if (myDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE)
|
|
||||||
{
|
|
||||||
// Vector is calculated depending on global min max of the part:
|
|
||||||
Bnd_Box aBndBox; //= BoundingBox(); ?
|
|
||||||
BRepBndLib::Add (shape, aBndBox);
|
|
||||||
if (!aBndBox.IsVoid())
|
|
||||||
{
|
|
||||||
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
|
||||||
aBndBox.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
|
||||||
aDeflection = Max (aXmax - aXmin, Max (aYmax - aYmin, aZmax - aZmin)) * myDrawer->DeviationCoefficient();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Boolean autoTriangulation = Standard_True;
|
Standard_Boolean autoTriangulation = Standard_True;
|
||||||
try {
|
try {
|
||||||
OCC_CATCH_SIGNALS
|
OCC_CATCH_SIGNALS
|
||||||
@ -518,7 +501,7 @@ void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
|
|||||||
shape,
|
shape,
|
||||||
TypOfSel,
|
TypOfSel,
|
||||||
aDeflection,
|
aDeflection,
|
||||||
myDrawer->DeviationAngle(),
|
myDrawer->HLRAngle(),
|
||||||
autoTriangulation);
|
autoTriangulation);
|
||||||
} catch ( Standard_Failure ) {
|
} catch ( Standard_Failure ) {
|
||||||
// cout << "a Shape should be incorrect : A Selection on the Bnd is activated "<<endl;
|
// cout << "a Shape should be incorrect : A Selection on the Bnd is activated "<<endl;
|
||||||
@ -571,7 +554,7 @@ void AIS_Shape::SetColor(const Quantity_Color &aCol)
|
|||||||
hasOwnColor = Standard_True;
|
hasOwnColor = Standard_True;
|
||||||
#ifdef GER61351
|
#ifdef GER61351
|
||||||
if( !HasColor() && !IsTransparent() && !HasMaterial() ) {
|
if( !HasColor() && !IsTransparent() && !HasMaterial() ) {
|
||||||
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
|
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
myOwnColor = aCol;
|
myOwnColor = aCol;
|
||||||
@ -786,7 +769,7 @@ void AIS_Shape::SetMaterial(const Graphic3d_NameOfMaterial aMat)
|
|||||||
{
|
{
|
||||||
#ifdef GER61351
|
#ifdef GER61351
|
||||||
if( !HasColor() && !IsTransparent() && !HasMaterial() ) {
|
if( !HasColor() && !IsTransparent() && !HasMaterial() ) {
|
||||||
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
|
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
|
||||||
}
|
}
|
||||||
myDrawer->ShadingAspect()->SetMaterial(aMat,myCurrentFacingModel);
|
myDrawer->ShadingAspect()->SetMaterial(aMat,myCurrentFacingModel);
|
||||||
hasOwnMaterial = Standard_True;
|
hasOwnMaterial = Standard_True;
|
||||||
@ -814,7 +797,7 @@ void AIS_Shape::SetMaterial(const Graphic3d_MaterialAspect& aMat)
|
|||||||
{
|
{
|
||||||
#ifdef GER61351
|
#ifdef GER61351
|
||||||
if( !HasColor() && !IsTransparent() && !HasMaterial() ) {
|
if( !HasColor() && !IsTransparent() && !HasMaterial() ) {
|
||||||
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
|
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
|
||||||
}
|
}
|
||||||
myDrawer->ShadingAspect()->SetMaterial(aMat,myCurrentFacingModel);
|
myDrawer->ShadingAspect()->SetMaterial(aMat,myCurrentFacingModel);
|
||||||
hasOwnMaterial = Standard_True;
|
hasOwnMaterial = Standard_True;
|
||||||
@ -846,11 +829,11 @@ void AIS_Shape::UnsetMaterial()
|
|||||||
if( HasColor() || IsTransparent()) {
|
if( HasColor() || IsTransparent()) {
|
||||||
Graphic3d_MaterialAspect mat = AIS_GraphicTool::GetMaterial(myDrawer->Link());
|
Graphic3d_MaterialAspect mat = AIS_GraphicTool::GetMaterial(myDrawer->Link());
|
||||||
if( HasColor() ) {
|
if( HasColor() ) {
|
||||||
Quantity_Color color = myDrawer->ShadingAspect()->Color(myCurrentFacingModel);
|
Quantity_Color color = myDrawer->ShadingAspect()->Color(myCurrentFacingModel);
|
||||||
mat.SetColor(color);
|
mat.SetColor(color);
|
||||||
}
|
}
|
||||||
if( IsTransparent() ) {
|
if( IsTransparent() ) {
|
||||||
Standard_Real trans = myDrawer->ShadingAspect()->Transparency(myCurrentFacingModel);
|
Standard_Real trans = myDrawer->ShadingAspect()->Transparency(myCurrentFacingModel);
|
||||||
mat.SetTransparency(trans);
|
mat.SetTransparency(trans);
|
||||||
}
|
}
|
||||||
myDrawer->ShadingAspect()->SetMaterial(mat,myCurrentFacingModel);
|
myDrawer->ShadingAspect()->SetMaterial(mat,myCurrentFacingModel);
|
||||||
@ -900,7 +883,7 @@ void AIS_Shape::SetTransparency(const Standard_Real AValue)
|
|||||||
|
|
||||||
Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
|
Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
|
||||||
P->SetPrimitivesAspect(a4bis);
|
P->SetPrimitivesAspect(a4bis);
|
||||||
#ifdef BUC60918 //force highest priority for transparent objects
|
#ifdef BUC60918 //force highest priority for transparent objects
|
||||||
P->SetDisplayPriority(10);
|
P->SetDisplayPriority(10);
|
||||||
#endif
|
#endif
|
||||||
G->SetGroupPrimitivesAspect(a4bis);
|
G->SetGroupPrimitivesAspect(a4bis);
|
||||||
@ -1133,7 +1116,7 @@ void AIS_Shape::SetOwnHLRDeviationAngle ( const Standard_Real anAngle )
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
Standard_Boolean AIS_Shape::OwnDeviationCoefficient ( Standard_Real & aCoefficient,
|
Standard_Boolean AIS_Shape::OwnDeviationCoefficient ( Standard_Real & aCoefficient,
|
||||||
Standard_Real & aPreviousCoefficient ) const
|
Standard_Real & aPreviousCoefficient ) const
|
||||||
{
|
{
|
||||||
aCoefficient = myDrawer->DeviationCoefficient();
|
aCoefficient = myDrawer->DeviationCoefficient();
|
||||||
aPreviousCoefficient = myDrawer->PreviousDeviationCoefficient ();
|
aPreviousCoefficient = myDrawer->PreviousDeviationCoefficient ();
|
||||||
@ -1146,7 +1129,7 @@ Standard_Boolean AIS_Shape::OwnDeviationCoefficient ( Standard_Real & aCoeffici
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
Standard_Boolean AIS_Shape::OwnHLRDeviationCoefficient ( Standard_Real & aCoefficient,
|
Standard_Boolean AIS_Shape::OwnHLRDeviationCoefficient ( Standard_Real & aCoefficient,
|
||||||
Standard_Real & aPreviousCoefficient ) const
|
Standard_Real & aPreviousCoefficient ) const
|
||||||
{
|
{
|
||||||
aCoefficient = myDrawer->HLRDeviationCoefficient();
|
aCoefficient = myDrawer->HLRDeviationCoefficient();
|
||||||
aPreviousCoefficient = myDrawer->PreviousHLRDeviationCoefficient ();
|
aPreviousCoefficient = myDrawer->PreviousHLRDeviationCoefficient ();
|
||||||
@ -1160,7 +1143,7 @@ Standard_Boolean AIS_Shape::OwnHLRDeviationCoefficient ( Standard_Real & aCoeffi
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
Standard_Boolean AIS_Shape::OwnDeviationAngle ( Standard_Real & anAngle,
|
Standard_Boolean AIS_Shape::OwnDeviationAngle ( Standard_Real & anAngle,
|
||||||
Standard_Real & aPreviousAngle ) const
|
Standard_Real & aPreviousAngle ) const
|
||||||
{
|
{
|
||||||
anAngle = myDrawer->DeviationAngle();
|
anAngle = myDrawer->DeviationAngle();
|
||||||
aPreviousAngle = myDrawer->PreviousDeviationAngle ();
|
aPreviousAngle = myDrawer->PreviousDeviationAngle ();
|
||||||
@ -1173,10 +1156,9 @@ Standard_Boolean AIS_Shape::OwnDeviationAngle ( Standard_Real & anAngle,
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
Standard_Boolean AIS_Shape::OwnHLRDeviationAngle ( Standard_Real & anAngle,
|
Standard_Boolean AIS_Shape::OwnHLRDeviationAngle ( Standard_Real & anAngle,
|
||||||
Standard_Real & aPreviousAngle ) const
|
Standard_Real & aPreviousAngle ) const
|
||||||
{
|
{
|
||||||
anAngle = myDrawer->HLRAngle();
|
anAngle = myDrawer->HLRAngle();
|
||||||
aPreviousAngle = myDrawer->PreviousHLRDeviationAngle ();
|
aPreviousAngle = myDrawer->PreviousHLRDeviationAngle ();
|
||||||
return myDrawer->IsOwnHLRDeviationAngle();
|
return myDrawer->IsOwnHLRDeviationAngle();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,9 @@ is
|
|||||||
-- Package methods for shapes
|
-- Package methods for shapes
|
||||||
--
|
--
|
||||||
|
|
||||||
Add(S : Shape from TopoDS; B : in out Box from Bnd);
|
Add(S : Shape from TopoDS;
|
||||||
|
B : in out Box from Bnd;
|
||||||
|
useTriangulation: Boolean from Standard = Standard_True);
|
||||||
---Purpose:Adds the shape S to the bounding box B.
|
---Purpose:Adds the shape S to the bounding box B.
|
||||||
-- More precisely are successively added to B:
|
-- More precisely are successively added to B:
|
||||||
-- - each face of S; the triangulation of the face is used if it exists,
|
-- - each face of S; the triangulation of the face is used if it exists,
|
||||||
|
@ -26,12 +26,11 @@
|
|||||||
//purpose : Add a shape bounding to a box
|
//purpose : Add a shape bounding to a box
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void BRepBndLib::Add(const TopoDS_Shape& S, Bnd_Box& B)
|
void BRepBndLib::Add(const TopoDS_Shape& S, Bnd_Box& B, Standard_Boolean useTriangulation)
|
||||||
{
|
{
|
||||||
TopExp_Explorer ex;
|
TopExp_Explorer ex;
|
||||||
|
|
||||||
// Add the faces
|
// Add the faces
|
||||||
|
|
||||||
BRepAdaptor_Surface BS;
|
BRepAdaptor_Surface BS;
|
||||||
Handle(Geom_Surface) GS;
|
Handle(Geom_Surface) GS;
|
||||||
Handle(Poly_Triangulation) T;
|
Handle(Poly_Triangulation) T;
|
||||||
@ -42,80 +41,86 @@ void BRepBndLib::Add(const TopoDS_Shape& S, Bnd_Box& B)
|
|||||||
for (ex.Init(S,TopAbs_FACE); ex.More(); ex.Next()) {
|
for (ex.Init(S,TopAbs_FACE); ex.More(); ex.Next()) {
|
||||||
const TopoDS_Face& F = TopoDS::Face(ex.Current());
|
const TopoDS_Face& F = TopoDS::Face(ex.Current());
|
||||||
T = BRep_Tool::Triangulation(F, l);
|
T = BRep_Tool::Triangulation(F, l);
|
||||||
if (!T.IsNull()) {
|
if (useTriangulation && !T.IsNull())
|
||||||
|
{
|
||||||
nbNodes = T->NbNodes();
|
nbNodes = T->NbNodes();
|
||||||
const TColgp_Array1OfPnt& Nodes = T->Nodes();
|
const TColgp_Array1OfPnt& Nodes = T->Nodes();
|
||||||
for (i = 1; i <= nbNodes; i++) {
|
for (i = 1; i <= nbNodes; i++) {
|
||||||
if (l.IsIdentity()) B.Add(Nodes(i));
|
if (l.IsIdentity()) B.Add(Nodes(i));
|
||||||
else B.Add(Nodes(i).Transformed(l));
|
else B.Add(Nodes(i).Transformed(l));
|
||||||
}
|
}
|
||||||
// B.Enlarge(T->Deflection());
|
// B.Enlarge(T->Deflection());
|
||||||
B.Enlarge(T->Deflection() + BRep_Tool::Tolerance(F));
|
B.Enlarge(T->Deflection() + BRep_Tool::Tolerance(F));
|
||||||
}
|
} else
|
||||||
else {
|
{
|
||||||
GS = BRep_Tool::Surface(F, l);
|
GS = BRep_Tool::Surface(F, l);
|
||||||
if (!GS.IsNull()) {
|
if (!GS.IsNull()) {
|
||||||
BS.Initialize(F, Standard_False);
|
BS.Initialize(F, Standard_False);
|
||||||
if (BS.GetType() != GeomAbs_Plane) {
|
if (BS.GetType() != GeomAbs_Plane) {
|
||||||
BS.Initialize(F);
|
BS.Initialize(F);
|
||||||
BndLib_AddSurface::Add(BS, BRep_Tool::Tolerance(F), B);
|
BndLib_AddSurface::Add(BS, BRep_Tool::Tolerance(F), B);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// on travaille directement sur les courbes 3d.
|
// on travaille directement sur les courbes 3d.
|
||||||
TopExp_Explorer ex2(F, TopAbs_EDGE);
|
TopExp_Explorer ex2(F, TopAbs_EDGE);
|
||||||
if (!ex2.More()) {
|
if (!ex2.More()) {
|
||||||
BS.Initialize(F);
|
BS.Initialize(F);
|
||||||
BndLib_AddSurface::Add(BS, BRep_Tool::Tolerance(F), B);
|
BndLib_AddSurface::Add(BS, BRep_Tool::Tolerance(F), B);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (;ex2.More();ex2.Next()) {
|
for (;ex2.More();ex2.Next()) {
|
||||||
BC.Initialize(TopoDS::Edge(ex2.Current()));
|
BC.Initialize(TopoDS::Edge(ex2.Current()));
|
||||||
BndLib_Add3dCurve::Add(BC, BRep_Tool::Tolerance(F), B);
|
BndLib_Add3dCurve::Add(BC, BRep_Tool::Tolerance(F), B);
|
||||||
}
|
}
|
||||||
B.Enlarge(BRep_Tool::Tolerance(F));
|
B.Enlarge(BRep_Tool::Tolerance(F));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the edges not in faces
|
// Add the edges not in faces
|
||||||
|
|
||||||
|
|
||||||
Handle(TColStd_HArray1OfInteger) HIndices;
|
Handle(TColStd_HArray1OfInteger) HIndices;
|
||||||
Handle(Poly_PolygonOnTriangulation) Poly;
|
Handle(Poly_PolygonOnTriangulation) Poly;
|
||||||
|
|
||||||
for (ex.Init(S,TopAbs_EDGE,TopAbs_FACE); ex.More(); ex.Next()) {
|
for (ex.Init(S,TopAbs_EDGE,TopAbs_FACE); ex.More(); ex.Next())
|
||||||
|
{
|
||||||
const TopoDS_Edge& E = TopoDS::Edge(ex.Current());
|
const TopoDS_Edge& E = TopoDS::Edge(ex.Current());
|
||||||
Handle(Poly_Polygon3D) P3d = BRep_Tool::Polygon3D(E, l);
|
Handle(Poly_Polygon3D) P3d = BRep_Tool::Polygon3D(E, l);
|
||||||
if (!P3d.IsNull()) {
|
if (!P3d.IsNull())
|
||||||
|
{
|
||||||
const TColgp_Array1OfPnt& Nodes = P3d->Nodes();
|
const TColgp_Array1OfPnt& Nodes = P3d->Nodes();
|
||||||
nbNodes = P3d->NbNodes();
|
nbNodes = P3d->NbNodes();
|
||||||
for (i = 1; i <= nbNodes; i++) {
|
for (i = 1; i <= nbNodes; i++)
|
||||||
if (l.IsIdentity()) B.Add(Nodes(i));
|
{
|
||||||
else B.Add(Nodes(i).Transformed(l));
|
if (l.IsIdentity()) B.Add(Nodes(i));
|
||||||
|
else B.Add(Nodes(i).Transformed(l));
|
||||||
}
|
}
|
||||||
// B.Enlarge(P3d->Deflection());
|
// B.Enlarge(P3d->Deflection());
|
||||||
B.Enlarge(P3d->Deflection() + BRep_Tool::Tolerance(E));
|
B.Enlarge(P3d->Deflection() + BRep_Tool::Tolerance(E));
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
BRep_Tool::PolygonOnTriangulation(E, Poly, T, l);
|
BRep_Tool::PolygonOnTriangulation(E, Poly, T, l);
|
||||||
if (!Poly.IsNull()) {
|
if (useTriangulation && !Poly.IsNull())
|
||||||
const TColStd_Array1OfInteger& Indices = Poly->Nodes();
|
{
|
||||||
const TColgp_Array1OfPnt& Nodes = T->Nodes();
|
const TColStd_Array1OfInteger& Indices = Poly->Nodes();
|
||||||
nbNodes = Indices.Length();
|
const TColgp_Array1OfPnt& Nodes = T->Nodes();
|
||||||
for (i = 1; i <= nbNodes; i++) {
|
nbNodes = Indices.Length();
|
||||||
if (l.IsIdentity()) B.Add(Nodes(Indices(i)));
|
for (i = 1; i <= nbNodes; i++)
|
||||||
else B.Add(Nodes(Indices(i)).Transformed(l));
|
{
|
||||||
}
|
if (l.IsIdentity()) B.Add(Nodes(Indices(i)));
|
||||||
// B.Enlarge(T->Deflection());
|
else B.Add(Nodes(Indices(i)).Transformed(l));
|
||||||
B.Enlarge(Poly->Deflection() + BRep_Tool::Tolerance(E));
|
}
|
||||||
|
// B.Enlarge(T->Deflection());
|
||||||
|
B.Enlarge(Poly->Deflection() + BRep_Tool::Tolerance(E));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (BRep_Tool::IsGeometric(E)) {
|
if (BRep_Tool::IsGeometric(E))
|
||||||
BC.Initialize(E);
|
{
|
||||||
BndLib_Add3dCurve::Add(BC, BRep_Tool::Tolerance(E), B);
|
BC.Initialize(E);
|
||||||
}
|
BndLib_Add3dCurve::Add(BC, BRep_Tool::Tolerance(E), B);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,245 +52,238 @@
|
|||||||
|
|
||||||
|
|
||||||
static Standard_Real GetDeflection(const anyShape& aShape,
|
static Standard_Real GetDeflection(const anyShape& aShape,
|
||||||
const Handle(Prs3d_Drawer)& aDrawer)
|
const Handle(Prs3d_Drawer)& aDrawer)
|
||||||
{
|
{
|
||||||
Standard_Real aDeflection;
|
Standard_Real aDeflection = aDrawer->MaximalChordialDeviation();
|
||||||
if (aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE) {
|
if (aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE) {
|
||||||
Bnd_Box B;
|
Bnd_Box B;
|
||||||
BRepBndLib::Add(aShape, B);
|
BRepBndLib::Add(aShape, B, Standard_False);
|
||||||
if ( ! B.IsVoid() )
|
if ( ! B.IsVoid() )
|
||||||
{
|
{
|
||||||
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
||||||
B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
||||||
aDeflection = MAX3( aXmax-aXmin , aYmax-aYmin , aZmax-aZmin)
|
aDeflection = MAX3( aXmax-aXmin , aYmax-aYmin , aZmax-aZmin)
|
||||||
* aDrawer->DeviationCoefficient()*4;
|
* aDrawer->DeviationCoefficient()*4;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
aDeflection = aDrawer->MaximalChordialDeviation();
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
aDeflection = aDrawer->MaximalChordialDeviation();
|
|
||||||
|
|
||||||
return aDeflection;
|
return aDeflection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Standard_Boolean ShadeFromShape(const anyShape& aShape,
|
static Standard_Boolean ShadeFromShape(const anyShape& aShape,
|
||||||
const Standard_Real /*defle*/,
|
const Standard_Real /*defle*/,
|
||||||
const Standard_Boolean /*share*/,
|
const Standard_Boolean /*share*/,
|
||||||
const Handle (Prs3d_Presentation)& aPresentation,
|
const Handle (Prs3d_Presentation)& aPresentation,
|
||||||
const Handle (Prs3d_Drawer)& aDrawer)
|
const Handle (Prs3d_Drawer)& aDrawer)
|
||||||
{
|
{
|
||||||
|
anyShadedShapeTool SST;
|
||||||
|
Handle(Poly_Triangulation) T;
|
||||||
|
TopLoc_Location loc;
|
||||||
|
gp_Pnt p;
|
||||||
|
Standard_Integer i,j,k,decal ;
|
||||||
|
Standard_Integer t[3], n[3];
|
||||||
|
Standard_Integer nbTriangles = 0, nbVertices = 0;
|
||||||
|
|
||||||
anyShadedShapeTool SST;
|
// precision for compare square distances
|
||||||
Handle(Poly_Triangulation) T;
|
double dPreci = Precision::Confusion()*Precision::Confusion();
|
||||||
TopLoc_Location loc;
|
|
||||||
gp_Pnt p;
|
|
||||||
Standard_Integer i,j,k,decal ;
|
|
||||||
Standard_Integer t[3], n[3];
|
|
||||||
Standard_Integer nbTriangles = 0, nbVertices = 0;
|
|
||||||
|
|
||||||
// precision for compare square distances
|
if ( !aDrawer->ShadingAspectGlobal() ) {
|
||||||
double dPreci = Precision::Confusion()*Precision::Confusion();
|
|
||||||
|
|
||||||
if ( !aDrawer->ShadingAspectGlobal() ) {
|
Handle(Graphic3d_AspectFillArea3d) Asp = aDrawer->ShadingAspect()->Aspect();
|
||||||
|
if(anyShadedShapeTool::IsClosed(aShape)) {
|
||||||
Handle(Graphic3d_AspectFillArea3d) Asp = aDrawer->ShadingAspect()->Aspect();
|
Asp->SuppressBackFace();
|
||||||
if(anyShadedShapeTool::IsClosed(aShape)) {
|
} else {
|
||||||
Asp->SuppressBackFace();
|
Asp->AllowBackFace();
|
||||||
} else {
|
|
||||||
Asp->AllowBackFace();
|
|
||||||
}
|
|
||||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(Asp);
|
|
||||||
}
|
}
|
||||||
|
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(Asp);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef G005
|
#ifdef G005
|
||||||
if( Graphic3d_ArrayOfPrimitives::IsEnable() ) {
|
if( Graphic3d_ArrayOfPrimitives::IsEnable() ) {
|
||||||
|
|
||||||
for (SST.Init(aShape); SST.MoreFace(); SST.NextFace()) {
|
|
||||||
const anyTopFace& F = SST.CurrentFace();
|
|
||||||
T = SST.Triangulation(F, loc);
|
|
||||||
if (!T.IsNull()) {
|
|
||||||
nbTriangles += T->NbTriangles();
|
|
||||||
nbVertices += T->NbNodes();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nbVertices > 2 && nbTriangles > 0) {
|
|
||||||
Handle(Graphic3d_ArrayOfTriangles) parray =
|
|
||||||
new Graphic3d_ArrayOfTriangles(nbVertices,3*nbTriangles,
|
|
||||||
Standard_True,Standard_False,Standard_False,Standard_True);
|
|
||||||
for (SST.Init(aShape); SST.MoreFace(); SST.NextFace()) {
|
|
||||||
const anyTopFace& F = SST.CurrentFace();
|
|
||||||
T = SST.Triangulation(F, loc);
|
|
||||||
if (!T.IsNull()) {
|
|
||||||
const gp_Trsf& trsf = loc.Transformation();
|
|
||||||
Poly_Connect pc(T);
|
|
||||||
// Extracts vertices & normals from nodes
|
|
||||||
const TColgp_Array1OfPnt& Nodes = T->Nodes();
|
|
||||||
TColgp_Array1OfDir NORMAL(Nodes.Lower(), Nodes.Upper());
|
|
||||||
SST.Normal(F, pc, NORMAL);
|
|
||||||
|
|
||||||
decal = parray->VertexNumber();
|
|
||||||
for (i= Nodes.Lower(); i<= Nodes.Upper(); i++) {
|
|
||||||
p = Nodes(i);
|
|
||||||
if( !loc.IsIdentity() ) {
|
|
||||||
p.Transform(trsf);
|
|
||||||
NORMAL(i).Transform(trsf);
|
|
||||||
}
|
|
||||||
parray->AddVertex(p,NORMAL(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fill parray with vertex and edge visibillity info
|
|
||||||
const Poly_Array1OfTriangle& triangles = T->Triangles();
|
|
||||||
for (i = 1; i <= T->NbTriangles(); i++) {
|
|
||||||
pc.Triangles(i,t[0],t[1],t[2]);
|
|
||||||
if (SST.Orientation(F) == TopAbs_REVERSED)
|
|
||||||
triangles(i).Get(n[0],n[2],n[1]);
|
|
||||||
else
|
|
||||||
triangles(i).Get(n[0],n[1],n[2]);
|
|
||||||
gp_Pnt P1 = Nodes(n[0]);
|
|
||||||
gp_Pnt P2 = Nodes(n[1]);
|
|
||||||
gp_Pnt P3 = Nodes(n[2]);
|
|
||||||
gp_Vec V1(P1,P2);
|
|
||||||
if ( V1.SquareMagnitude() > dPreci ) {
|
|
||||||
gp_Vec V2(P2,P3);
|
|
||||||
if ( V2.SquareMagnitude() > dPreci ) {
|
|
||||||
gp_Vec V3(P3,P1);
|
|
||||||
if ( V3.SquareMagnitude() > dPreci ) {
|
|
||||||
V1.Normalize();
|
|
||||||
V2.Normalize();
|
|
||||||
V1.Cross(V2);
|
|
||||||
if ( V1.SquareMagnitude() > dPreci ) {
|
|
||||||
parray->AddEdge(n[0]+decal,t[0] == 0);
|
|
||||||
parray->AddEdge(n[1]+decal,t[1] == 0);
|
|
||||||
parray->AddEdge(n[2]+decal,t[2] == 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Prs3d_Root::CurrentGroup(aPresentation)->BeginPrimitives();
|
|
||||||
Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(parray);
|
|
||||||
Prs3d_Root::CurrentGroup(aPresentation)->EndPrimitives();
|
|
||||||
}
|
|
||||||
return Standard_True;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// phase de comptage:
|
|
||||||
Standard_Integer nt, nnn, n1, n2, n3, nnv, EI;
|
|
||||||
static Standard_Integer plus1mod3[3] = {1, 2, 0};
|
|
||||||
for (SST.Init(aShape); SST.MoreFace(); SST.NextFace()) {
|
for (SST.Init(aShape); SST.MoreFace(); SST.NextFace()) {
|
||||||
const anyTopFace& F = SST.CurrentFace();
|
const anyTopFace& F = SST.CurrentFace();
|
||||||
T = SST.Triangulation(F, loc);
|
T = SST.Triangulation(F, loc);
|
||||||
if (!T.IsNull()) {
|
if (!T.IsNull()) {
|
||||||
|
nbTriangles += T->NbTriangles();
|
||||||
nnn = T->NbTriangles();
|
nbVertices += T->NbNodes();
|
||||||
const TColgp_Array1OfPnt& Nodes = T->Nodes();
|
|
||||||
const Poly_Array1OfTriangle& triangles = T->Triangles();
|
|
||||||
for (nt = 1; nt <= nnn; nt++) {
|
|
||||||
if (SST.Orientation(F) == TopAbs_REVERSED)
|
|
||||||
triangles(nt).Get(n1,n3,n2);
|
|
||||||
else
|
|
||||||
triangles(nt).Get(n1,n2,n3);
|
|
||||||
const gp_Pnt& P1 = Nodes(n1);
|
|
||||||
const gp_Pnt& P2 = Nodes(n2);
|
|
||||||
const gp_Pnt& P3 = Nodes(n3);
|
|
||||||
gp_Vec V1(P1,P2);
|
|
||||||
if ( V1.SquareMagnitude() > dPreci ) {
|
|
||||||
gp_Vec V2(P2,P3);
|
|
||||||
if (V2.SquareMagnitude() > dPreci ) {
|
|
||||||
gp_Vec V3(P3,P1);
|
|
||||||
if (V3.SquareMagnitude() > dPreci ) {
|
|
||||||
V1.Normalize();
|
|
||||||
V2.Normalize();
|
|
||||||
V1.Cross(V2);
|
|
||||||
if (V1.SquareMagnitude() > dPreci ) {
|
|
||||||
nbTriangles++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nbVertices += T->NbNodes();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nbVertices > 2 && nbTriangles > 0) {
|
if (nbVertices > 2 && nbTriangles > 0) {
|
||||||
Graphic3d_Array1OfVertexN AVN(1, nbVertices);
|
Handle(Graphic3d_ArrayOfTriangles) parray =
|
||||||
Aspect_Array1OfEdge AE(1, 3*nbTriangles);
|
new Graphic3d_ArrayOfTriangles(nbVertices,3*nbTriangles,
|
||||||
|
Standard_True,Standard_False,Standard_False,Standard_True);
|
||||||
EI = 1;
|
|
||||||
nnv = 1;
|
|
||||||
|
|
||||||
for (SST.Init(aShape); SST.MoreFace(); SST.NextFace()) {
|
for (SST.Init(aShape); SST.MoreFace(); SST.NextFace()) {
|
||||||
const anyTopFace& F = SST.CurrentFace();
|
const anyTopFace& F = SST.CurrentFace();
|
||||||
T = SST.Triangulation(F, loc);
|
T = SST.Triangulation(F, loc);
|
||||||
if (!T.IsNull()) {
|
if (!T.IsNull()) {
|
||||||
Poly_Connect pc(T);
|
const gp_Trsf& trsf = loc.Transformation();
|
||||||
// 1- les noeuds.
|
Poly_Connect pc(T);
|
||||||
const TColgp_Array1OfPnt& Nodes = T->Nodes();
|
// Extracts vertices & normals from nodes
|
||||||
TColgp_Array1OfDir NORMAL(Nodes.Lower(), Nodes.Upper());
|
const TColgp_Array1OfPnt& Nodes = T->Nodes();
|
||||||
SST.Normal(F, pc, NORMAL);
|
TColgp_Array1OfDir NORMAL(Nodes.Lower(), Nodes.Upper());
|
||||||
decal = nnv-1;
|
SST.Normal(F, pc, NORMAL);
|
||||||
|
|
||||||
for (j= Nodes.Lower(); j<= Nodes.Upper(); j++) {
|
decal = parray->VertexNumber();
|
||||||
p = Nodes(j).Transformed(loc.Transformation());
|
for (i= Nodes.Lower(); i<= Nodes.Upper(); i++) {
|
||||||
AVN(nnv).SetCoord(p.X(), p.Y(), p.Z());
|
p = Nodes(i);
|
||||||
AVN(nnv).SetNormal(NORMAL(j).X(), NORMAL(j).Y(), NORMAL(j).Z());
|
if( !loc.IsIdentity() ) {
|
||||||
nnv++;
|
p.Transform(trsf);
|
||||||
}
|
NORMAL(i).Transform(trsf);
|
||||||
// 2- les edges.
|
}
|
||||||
nbTriangles = T->NbTriangles();
|
parray->AddVertex(p,NORMAL(i));
|
||||||
const Poly_Array1OfTriangle& triangles = T->Triangles();
|
}
|
||||||
|
|
||||||
for (i = 1; i <= nbTriangles; i++) {
|
// Fill parray with vertex and edge visibillity info
|
||||||
pc.Triangles(i,t[0],t[1],t[2]);
|
const Poly_Array1OfTriangle& triangles = T->Triangles();
|
||||||
if (SST.Orientation(F) == TopAbs_REVERSED)
|
for (i = 1; i <= T->NbTriangles(); i++) {
|
||||||
triangles(i).Get(n[0],n[2],n[1]);
|
pc.Triangles(i,t[0],t[1],t[2]);
|
||||||
else
|
if (SST.Orientation(F) == TopAbs_REVERSED)
|
||||||
triangles(i).Get(n[0],n[1],n[2]);
|
triangles(i).Get(n[0],n[2],n[1]);
|
||||||
const gp_Pnt& P1 = Nodes(n[0]);
|
else
|
||||||
const gp_Pnt& P2 = Nodes(n[1]);
|
triangles(i).Get(n[0],n[1],n[2]);
|
||||||
const gp_Pnt& P3 = Nodes(n[2]);
|
gp_Pnt P1 = Nodes(n[0]);
|
||||||
gp_Vec V1(P1,P2);
|
gp_Pnt P2 = Nodes(n[1]);
|
||||||
if (V1.SquareMagnitude() > 1.e-10) {
|
gp_Pnt P3 = Nodes(n[2]);
|
||||||
gp_Vec V2(P2,P3);
|
gp_Vec V1(P1,P2);
|
||||||
if (V2.SquareMagnitude() > 1.e-10) {
|
if ( V1.SquareMagnitude() > dPreci ) {
|
||||||
gp_Vec V3(P3,P1);
|
gp_Vec V2(P2,P3);
|
||||||
if (V3.SquareMagnitude() > 1.e-10) {
|
if ( V2.SquareMagnitude() > dPreci ) {
|
||||||
V1.Normalize();
|
gp_Vec V3(P3,P1);
|
||||||
V2.Normalize();
|
if ( V3.SquareMagnitude() > dPreci ) {
|
||||||
V1.Cross(V2);
|
V1.Normalize();
|
||||||
if (V1.SquareMagnitude() > 1.e-10) {
|
V2.Normalize();
|
||||||
for (j = 0; j < 3; j++) {
|
V1.Cross(V2);
|
||||||
k = plus1mod3[j];
|
if ( V1.SquareMagnitude() > dPreci ) {
|
||||||
if (t[j] == 0)
|
parray->AddEdge(n[0]+decal,t[0] == 0);
|
||||||
AE(EI).SetValues(n[j]+decal, n[k]+decal, Aspect_TOE_VISIBLE);
|
parray->AddEdge(n[1]+decal,t[1] == 0);
|
||||||
else
|
parray->AddEdge(n[2]+decal,t[2] == 0);
|
||||||
AE(EI).SetValues(n[j]+decal, n[k]+decal, Aspect_TOE_INVISIBLE);
|
}
|
||||||
EI++;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Prs3d_Root::CurrentGroup(aPresentation)->TriangleSet(AVN, AE);
|
Prs3d_Root::CurrentGroup(aPresentation)->BeginPrimitives();
|
||||||
|
Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(parray);
|
||||||
|
Prs3d_Root::CurrentGroup(aPresentation)->EndPrimitives();
|
||||||
}
|
}
|
||||||
return Standard_True;
|
return Standard_True;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// phase de comptage:
|
||||||
|
Standard_Integer nt, nnn, n1, n2, n3, nnv, EI;
|
||||||
|
static Standard_Integer plus1mod3[3] = {1, 2, 0};
|
||||||
|
for (SST.Init(aShape); SST.MoreFace(); SST.NextFace()) {
|
||||||
|
const anyTopFace& F = SST.CurrentFace();
|
||||||
|
T = SST.Triangulation(F, loc);
|
||||||
|
if (!T.IsNull()) {
|
||||||
|
nnn = T->NbTriangles();
|
||||||
|
const TColgp_Array1OfPnt& Nodes = T->Nodes();
|
||||||
|
const Poly_Array1OfTriangle& triangles = T->Triangles();
|
||||||
|
for (nt = 1; nt <= nnn; nt++) {
|
||||||
|
if (SST.Orientation(F) == TopAbs_REVERSED)
|
||||||
|
triangles(nt).Get(n1,n3,n2);
|
||||||
|
else
|
||||||
|
triangles(nt).Get(n1,n2,n3);
|
||||||
|
const gp_Pnt& P1 = Nodes(n1);
|
||||||
|
const gp_Pnt& P2 = Nodes(n2);
|
||||||
|
const gp_Pnt& P3 = Nodes(n3);
|
||||||
|
gp_Vec V1(P1,P2);
|
||||||
|
if ( V1.SquareMagnitude() > dPreci ) {
|
||||||
|
gp_Vec V2(P2,P3);
|
||||||
|
if (V2.SquareMagnitude() > dPreci ) {
|
||||||
|
gp_Vec V3(P3,P1);
|
||||||
|
if (V3.SquareMagnitude() > dPreci ) {
|
||||||
|
V1.Normalize();
|
||||||
|
V2.Normalize();
|
||||||
|
V1.Cross(V2);
|
||||||
|
if (V1.SquareMagnitude() > dPreci ) {
|
||||||
|
nbTriangles++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nbVertices += T->NbNodes();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nbVertices > 2 && nbTriangles > 0) {
|
||||||
|
Graphic3d_Array1OfVertexN AVN(1, nbVertices);
|
||||||
|
Aspect_Array1OfEdge AE(1, 3*nbTriangles);
|
||||||
|
|
||||||
|
EI = 1;
|
||||||
|
nnv = 1;
|
||||||
|
|
||||||
|
for (SST.Init(aShape); SST.MoreFace(); SST.NextFace()) {
|
||||||
|
const anyTopFace& F = SST.CurrentFace();
|
||||||
|
T = SST.Triangulation(F, loc);
|
||||||
|
if (!T.IsNull()) {
|
||||||
|
Poly_Connect pc(T);
|
||||||
|
// 1- les noeuds.
|
||||||
|
const TColgp_Array1OfPnt& Nodes = T->Nodes();
|
||||||
|
TColgp_Array1OfDir NORMAL(Nodes.Lower(), Nodes.Upper());
|
||||||
|
SST.Normal(F, pc, NORMAL);
|
||||||
|
decal = nnv-1;
|
||||||
|
|
||||||
|
for (j= Nodes.Lower(); j<= Nodes.Upper(); j++) {
|
||||||
|
p = Nodes(j).Transformed(loc.Transformation());
|
||||||
|
AVN(nnv).SetCoord(p.X(), p.Y(), p.Z());
|
||||||
|
AVN(nnv).SetNormal(NORMAL(j).X(), NORMAL(j).Y(), NORMAL(j).Z());
|
||||||
|
nnv++;
|
||||||
|
}
|
||||||
|
// 2- les edges.
|
||||||
|
nbTriangles = T->NbTriangles();
|
||||||
|
const Poly_Array1OfTriangle& triangles = T->Triangles();
|
||||||
|
|
||||||
|
for (i = 1; i <= nbTriangles; i++) {
|
||||||
|
pc.Triangles(i,t[0],t[1],t[2]);
|
||||||
|
if (SST.Orientation(F) == TopAbs_REVERSED)
|
||||||
|
triangles(i).Get(n[0],n[2],n[1]);
|
||||||
|
else
|
||||||
|
triangles(i).Get(n[0],n[1],n[2]);
|
||||||
|
const gp_Pnt& P1 = Nodes(n[0]);
|
||||||
|
const gp_Pnt& P2 = Nodes(n[1]);
|
||||||
|
const gp_Pnt& P3 = Nodes(n[2]);
|
||||||
|
gp_Vec V1(P1,P2);
|
||||||
|
if (V1.SquareMagnitude() > 1.e-10) {
|
||||||
|
gp_Vec V2(P2,P3);
|
||||||
|
if (V2.SquareMagnitude() > 1.e-10) {
|
||||||
|
gp_Vec V3(P3,P1);
|
||||||
|
if (V3.SquareMagnitude() > 1.e-10) {
|
||||||
|
V1.Normalize();
|
||||||
|
V2.Normalize();
|
||||||
|
V1.Cross(V2);
|
||||||
|
if (V1.SquareMagnitude() > 1.e-10) {
|
||||||
|
for (j = 0; j < 3; j++) {
|
||||||
|
k = plus1mod3[j];
|
||||||
|
if (t[j] == 0)
|
||||||
|
AE(EI).SetValues(n[j]+decal, n[k]+decal, Aspect_TOE_VISIBLE);
|
||||||
|
else
|
||||||
|
AE(EI).SetValues(n[j]+decal, n[k]+decal, Aspect_TOE_INVISIBLE);
|
||||||
|
EI++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Prs3d_Root::CurrentGroup(aPresentation)->TriangleSet(AVN, AE);
|
||||||
|
}
|
||||||
|
return Standard_True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Prs3d_ShadedShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
|
void Prs3d_ShadedShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
|
||||||
const anyShape& aShape,
|
const anyShape& aShape,
|
||||||
const Handle (Prs3d_Drawer)& aDrawer)
|
const Handle (Prs3d_Drawer)& aDrawer)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (aShape.IsNull()) return;
|
if (aShape.IsNull()) return;
|
||||||
@ -308,13 +301,13 @@ void Prs3d_ShadedShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
|
|||||||
|
|
||||||
// il faut presenter les edges isoles.
|
// il faut presenter les edges isoles.
|
||||||
for (ex.Init(aShape, TopAbs_EDGE, TopAbs_FACE); ex.More(); ex.Next()) {
|
for (ex.Init(aShape, TopAbs_EDGE, TopAbs_FACE); ex.More(); ex.Next()) {
|
||||||
haselement = Standard_True;
|
haselement = Standard_True;
|
||||||
B.Add(CO, ex.Current());
|
B.Add(CO, ex.Current());
|
||||||
}
|
}
|
||||||
// il faut presenter les vertex isoles.
|
// il faut presenter les vertex isoles.
|
||||||
for (ex.Init(aShape, TopAbs_VERTEX, TopAbs_EDGE); ex.More(); ex.Next()) {
|
for (ex.Init(aShape, TopAbs_VERTEX, TopAbs_EDGE); ex.More(); ex.Next()) {
|
||||||
haselement = Standard_True;
|
haselement = Standard_True;
|
||||||
B.Add(CO, ex.Current());
|
B.Add(CO, ex.Current());
|
||||||
}
|
}
|
||||||
if (haselement) StdPrs_WFShape::Add(aPresentation, CO, aDrawer);
|
if (haselement) StdPrs_WFShape::Add(aPresentation, CO, aDrawer);
|
||||||
}
|
}
|
||||||
@ -324,14 +317,18 @@ void Prs3d_ShadedShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
|
|||||||
}
|
}
|
||||||
Standard_Real aDeflection = GetDeflection(aShape, aDrawer);
|
Standard_Real aDeflection = GetDeflection(aShape, aDrawer);
|
||||||
//using of plugin
|
//using of plugin
|
||||||
BRepMesh_PDiscretRoot pAlgo;
|
// Check if it is possible to avoid unnecessary recomputation
|
||||||
pAlgo=BRepMesh_DiscretFactory::Get().Discret(aShape,
|
// of shape triangulation
|
||||||
aDeflection,
|
if( !BRepTools::Triangulation(aShape, aDeflection) )
|
||||||
aDrawer->HLRAngle());
|
{
|
||||||
if (pAlgo)
|
BRepTools::Clean(aShape);
|
||||||
pAlgo->Perform();
|
|
||||||
|
|
||||||
|
BRepMesh_PDiscretRoot pAlgo;
|
||||||
|
pAlgo=BRepMesh_DiscretFactory::Get().Discret(aShape,
|
||||||
|
aDeflection,
|
||||||
|
aDrawer->HLRAngle());
|
||||||
|
if (pAlgo)
|
||||||
|
pAlgo->Perform();
|
||||||
|
}
|
||||||
ShadeFromShape(aShape, aDeflection, Standard_True, aPresentation, aDrawer);
|
ShadeFromShape(aShape, aDeflection, Standard_True, aPresentation, aDrawer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ Matches (const Standard_Real XMin,
|
|||||||
Bnd_Box2d BoundBox;
|
Bnd_Box2d BoundBox;
|
||||||
BoundBox.Update(XMin-aTol,YMin-aTol,XMax+aTol,YMax+aTol);
|
BoundBox.Update(XMin-aTol,YMin-aTol,XMax+aTol,YMax+aTol);
|
||||||
|
|
||||||
for(Standard_Integer j=0; j<mynbpoints-1; j++)
|
for(Standard_Integer j=0; j<mynbpoints; j++)
|
||||||
{
|
{
|
||||||
if(BoundBox.IsOut(((Select3D_Pnt2d*)mypolyg2d)[j])) return Standard_False;
|
if(BoundBox.IsOut(((Select3D_Pnt2d*)mypolyg2d)[j])) return Standard_False;
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,12 @@ void StdSelect_BRepSelectionTool
|
|||||||
const Standard_Real theMaxParam)
|
const Standard_Real theMaxParam)
|
||||||
{
|
{
|
||||||
Standard_Integer aPriority = (thePriority == -1) ? GetStandardPriority (theShape, theType) : thePriority;
|
Standard_Integer aPriority = (thePriority == -1) ? GetStandardPriority (theShape, theType) : thePriority;
|
||||||
|
|
||||||
|
if( isAutoTriangulation && !BRepTools::Triangulation (theShape, Precision::Infinite()) )
|
||||||
|
{
|
||||||
|
BRepMesh_IncrementalMesh(theShape, theDeflection, Standard_False, theDeviationAngle);
|
||||||
|
}
|
||||||
|
|
||||||
Handle(StdSelect_BRepOwner) aBrepOwner;
|
Handle(StdSelect_BRepOwner) aBrepOwner;
|
||||||
switch (theType)
|
switch (theType)
|
||||||
{
|
{
|
||||||
@ -586,13 +592,7 @@ Standard_Boolean StdSelect_BRepSelectionTool
|
|||||||
// check if there is triangulation of the face...
|
// check if there is triangulation of the face...
|
||||||
TopLoc_Location aLoc;
|
TopLoc_Location aLoc;
|
||||||
Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation (theFace, aLoc);
|
Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation (theFace, aLoc);
|
||||||
if (aTriangulation.IsNull() && theAutoTriangulation)
|
|
||||||
{
|
|
||||||
Standard_Real aDefaultDefl = 0.2;
|
|
||||||
Standard_Real aDefaultAng = 30 * PI / 180.0;
|
|
||||||
BRepMesh_IncrementalMesh (theFace, aDefaultDefl, Standard_True, aDefaultAng);
|
|
||||||
aTriangulation = BRep_Tool::Triangulation (theFace, aLoc);
|
|
||||||
}
|
|
||||||
if (!aTriangulation.IsNull())
|
if (!aTriangulation.IsNull())
|
||||||
{
|
{
|
||||||
Handle(Select3D_SensitiveTriangulation) STG = new Select3D_SensitiveTriangulation (theOwner, aTriangulation, aLoc, theInteriorFlag);
|
Handle(Select3D_SensitiveTriangulation) STG = new Select3D_SensitiveTriangulation (theOwner, aTriangulation, aLoc, theInteriorFlag);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user