mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-28 03:00:33 +05:00
Improve GEOM_AISShape::computeMassCenter() for faces
which is used to show field values
This commit is contained in:
parent
0f61961349
commit
84e542cbbe
@ -186,18 +186,21 @@ GEOM_AISShape::~GEOM_AISShape()
|
||||
{
|
||||
}
|
||||
|
||||
void GEOM_AISShape::setIO(const Handle(SALOME_InteractiveObject)& io){
|
||||
void GEOM_AISShape::setIO(const Handle(SALOME_InteractiveObject)& io)
|
||||
{
|
||||
SetOwner( io );
|
||||
}
|
||||
|
||||
Handle(SALOME_InteractiveObject) GEOM_AISShape::getIO(){
|
||||
Handle(SALOME_InteractiveObject) GEOM_AISShape::getIO()
|
||||
{
|
||||
Handle(SALOME_InteractiveObject) IO;
|
||||
if ( !GetOwner().IsNull() )
|
||||
IO = Handle(SALOME_InteractiveObject)::DownCast( GetOwner() );
|
||||
return IO;
|
||||
}
|
||||
|
||||
Standard_Boolean GEOM_AISShape::hasIO(){
|
||||
Standard_Boolean GEOM_AISShape::hasIO()
|
||||
{
|
||||
return !getIO().IsNull();
|
||||
}
|
||||
|
||||
@ -210,7 +213,8 @@ void GEOM_AISShape::setName(const Standard_CString aName)
|
||||
IO->setName(aName);
|
||||
}
|
||||
|
||||
Standard_CString GEOM_AISShape::getName(){
|
||||
Standard_CString GEOM_AISShape::getName()
|
||||
{
|
||||
return myName.ToCString();
|
||||
}
|
||||
|
||||
@ -351,7 +355,8 @@ void GEOM_AISShape::SetEdgesInShadingColor(const Quantity_Color &aCol)
|
||||
myEdgesInShadingColor = aCol;
|
||||
}
|
||||
|
||||
void GEOM_AISShape::SetLabelColor(const Quantity_Color &aCol) {
|
||||
void GEOM_AISShape::SetLabelColor(const Quantity_Color &aCol)
|
||||
{
|
||||
myLabelColor = aCol;
|
||||
}
|
||||
|
||||
@ -440,11 +445,13 @@ void GEOM_AISShape::shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPre
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Boolean GEOM_AISShape::isTopLevel() {
|
||||
Standard_Boolean GEOM_AISShape::isTopLevel()
|
||||
{
|
||||
return myTopLevel;
|
||||
}
|
||||
|
||||
void GEOM_AISShape::setTopLevel(Standard_Boolean f) {
|
||||
void GEOM_AISShape::setTopLevel(Standard_Boolean f)
|
||||
{
|
||||
if(f) {
|
||||
if(f != myTopLevel)
|
||||
myPrevDisplayMode = DisplayMode();
|
||||
@ -463,30 +470,38 @@ void GEOM_AISShape::setTopLevel(Standard_Boolean f) {
|
||||
myTopLevel = f;
|
||||
}
|
||||
|
||||
void GEOM_AISShape::setPrevDisplayMode(const Standard_Integer mode) {
|
||||
void GEOM_AISShape::setPrevDisplayMode(const Standard_Integer mode)
|
||||
{
|
||||
myPrevDisplayMode = mode;
|
||||
}
|
||||
|
||||
Quantity_Color GEOM_AISShape::topLevelColor() {
|
||||
Quantity_Color GEOM_AISShape::topLevelColor()
|
||||
{
|
||||
return myTopLevelColor;
|
||||
}
|
||||
|
||||
void GEOM_AISShape::setTopLevelColor(const Quantity_Color c) {
|
||||
void GEOM_AISShape::setTopLevelColor(const Quantity_Color c)
|
||||
{
|
||||
myTopLevelColor = c;
|
||||
}
|
||||
|
||||
GEOM_AISShape::TopLevelDispMode GEOM_AISShape::topLevelDisplayMode() {
|
||||
GEOM_AISShape::TopLevelDispMode GEOM_AISShape::topLevelDisplayMode()
|
||||
{
|
||||
return myTopLevelDm;
|
||||
}
|
||||
void GEOM_AISShape::setTopLevelDisplayMode(const GEOM_AISShape::TopLevelDispMode dm) {
|
||||
|
||||
void GEOM_AISShape::setTopLevelDisplayMode(const GEOM_AISShape::TopLevelDispMode dm)
|
||||
{
|
||||
myTopLevelDm = dm;
|
||||
}
|
||||
|
||||
Standard_Boolean GEOM_AISShape::switchTopLevel() {
|
||||
Standard_Boolean GEOM_AISShape::switchTopLevel()
|
||||
{
|
||||
return myTopLevelDm != TopShowAdditionalWActor;
|
||||
}
|
||||
|
||||
Standard_Boolean GEOM_AISShape::toActivate() {
|
||||
Standard_Boolean GEOM_AISShape::toActivate()
|
||||
{
|
||||
return ( myTopLevel && myTopLevelDm == TopShowAdditionalWActor ) ? false : true;
|
||||
}
|
||||
|
||||
@ -669,9 +684,37 @@ Standard_Boolean GEOM_AISShape::computeMassCenter( const TopoDS_Shape& theShape,
|
||||
}
|
||||
else if ( theShape.ShapeType() == TopAbs_FACE )
|
||||
{
|
||||
BRepAdaptor_Surface surface( TopoDS::Face( theShape ));
|
||||
const TopoDS_Face& F = TopoDS::Face( theShape );
|
||||
BRepAdaptor_Surface surface( F );
|
||||
|
||||
TopLoc_Location L;
|
||||
Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation( F, L );
|
||||
if ( !triangulation.IsNull() && triangulation->HasUVNodes() )
|
||||
{
|
||||
gp_XY C( 0, 0 );
|
||||
double A = 0;
|
||||
const TColgp_Array1OfPnt2d& uvArray = triangulation->UVNodes();
|
||||
const Poly_Array1OfTriangle& trias = triangulation->Triangles();
|
||||
Standard_Integer n1,n2,n3;
|
||||
for ( int iT = trias.Lower(); iT <= trias.Upper(); ++iT )
|
||||
{
|
||||
trias( iT ).Get( n1,n2,n3 );
|
||||
const gp_Pnt2d& uv1 = uvArray( n1 );
|
||||
const gp_Pnt2d& uv2 = uvArray( n2 );
|
||||
const gp_Pnt2d& uv3 = uvArray( n3 );
|
||||
double a = 0.5 * sqrt(( uv1.X() - uv3.X() ) * ( uv2.Y() - uv1.Y() ) -
|
||||
( uv1.X() - uv2.X() ) * ( uv3.Y() - uv1.Y() ));
|
||||
C += ( uv1.XY() + uv2.XY() + uv3.XY() ) / 3. * a;
|
||||
A += a;
|
||||
}
|
||||
C /= A;
|
||||
theCenter = surface.Value( C.X(), C.Y() );
|
||||
}
|
||||
else
|
||||
{
|
||||
theCenter = surface.Value( 0.5 * ( surface.FirstUParameter() + surface.LastUParameter() ),
|
||||
0.5 * ( surface.FirstVParameter() + surface.LastVParameter() ));
|
||||
}
|
||||
aNbPoints = 1;
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,6 @@ namespace XAO
|
||||
const int& nbElements, const int& nbComponents, const std::string& name);
|
||||
|
||||
public:
|
||||
/**
|
||||
/**
|
||||
* Creates a Field of the given type.
|
||||
* @param type the type of the field to create.
|
||||
|
Loading…
Reference in New Issue
Block a user