Back to index

salome-geom  6.5.0
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
VolumeSection Class Reference

#include <Archimede_VolumeSection.hxx>

Collaboration diagram for VolumeSection:
Collaboration graph
[legend]

List of all members.

Public Member Functions

Standard_EXPORT VolumeSection (TopoDS_Shape, Standard_Real)
Standard_EXPORT void CenterOfGravity ()
Standard_EXPORT Standard_Real CalculateVolume (Standard_Real)
Standard_EXPORT Standard_Real Archimede (Standard_Real, Standard_Real)
Standard_EXPORT void SetPlane (Handle(Geom_Plane))
Standard_EXPORT TopoDS_Shape GetShape ()
Standard_EXPORT void MakeRotation (gp_Dir)
Standard_EXPORT Handle (Geom_RectangularTrimmedSurface) InvMakeRotation(gp_Dir
Standard_EXPORT Handle (Geom_RectangularTrimmedSurface))
Standard_EXPORT Handle (Geom_RectangularTrimmedSurface) TrimSurf()
Standard_EXPORT Handle (Geom_RectangularTrimmedSurface) AjustePlan(Handle(Geom_RectangularTrimmedSurface)
Standard_EXPORT void getZ (double &min, double &max)

Public Attributes

Standard_EXPORT Standard_Real
Standard_EXPORT gp_Pnt

Private Member Functions

 Handle (Geom_Plane) myPlane
Standard_Real ElementaryVolume (gp_Pnt, gp_Pnt, gp_Pnt)
gp_Pnt Intersection (gp_Pnt, gp_Pnt, Standard_Real)

Private Attributes

TopoDS_Shape myShape
Standard_Real Tolerance
gp_Pnt InitPoint
Standard_Real Zmin
Standard_Real Zmax
Standard_Real Ymin
Standard_Real Ymax
Standard_Real Xmin
Standard_Real Xmax

Detailed Description

Definition at line 39 of file Archimede_VolumeSection.hxx.


Constructor & Destructor Documentation

VolumeSection::VolumeSection ( TopoDS_Shape  S,
Standard_Real  Precision 
)

Definition at line 55 of file Archimede_VolumeSection.cxx.

                                                                    :myShape(S),Tolerance(Precision)
{
  // Maillage de la shape myShape
  BRepMesh_IncrementalMesh(myShape,Tolerance);
}

Member Function Documentation

Definition at line 224 of file Archimede_VolumeSection.cxx.

{
  // Resolution de l equation V(h) = Constante a l aide de l algorithme de dichotomie avec ponderation type
  // Lagrange
  
  Standard_Real c,Binf,Bsup;
  Standard_Real tempBsupVolume=0;
  Standard_Real tempBinfVolume=0;
  Standard_Real tempCVolume = 0;

  Binf = Zmin;
  Bsup = Zmax;
  if(Binf>Bsup)
    {
      MESSAGE("error, Bound + < Bound - in dichotomy")
      return -1;
    }
  tempBsupVolume = CalculateVolume(Bsup);
  tempBinfVolume = CalculateVolume(Binf);
  
  if (Constante>tempBsupVolume || Constante<tempBinfVolume)
    {
      MESSAGE("error, algorithm start Impossible. Wrong constant value" )
      return -1;
    }
  
  c = ((Binf*(tempBsupVolume-Constante))-(Bsup*(tempBinfVolume-Constante)))
    /((tempBsupVolume-Constante)-(tempBinfVolume-Constante));
  tempCVolume = CalculateVolume(c);
  
  
  if(Abs(tempCVolume-Constante)<=Epsilon)
    {
      goto endMethod;
    }
  else
    {
      while((Bsup-Binf)>Epsilon)
        { 
          if((tempBinfVolume-Constante)*(tempCVolume-Constante)>0 && Abs(tempCVolume-Constante)>Epsilon)
            {
              Binf = c;
              tempBinfVolume=tempCVolume;
              
              c = ((Binf*(tempBsupVolume-Constante))-(Bsup*(tempBinfVolume-Constante)))
                /((tempBsupVolume-Constante)-(tempBinfVolume-Constante));
 tempCVolume=CalculateVolume(c);
            }
          else if((tempBinfVolume-Constante)*(tempCVolume-Constante)<0 && Abs(tempCVolume-Constante)>Epsilon)
            {
              Bsup = c;
              tempBsupVolume =tempCVolume;

              c = ((Binf*(tempBsupVolume-Constante))-(Bsup*(tempBinfVolume-Constante)))
                /((tempBsupVolume-Constante)-(tempBinfVolume-Constante));
 tempCVolume=CalculateVolume(c);
            }
          else
            {
              goto endMethod;
            }
        }
      goto endMethod;
      
    }
 endMethod:
  MESSAGE("La ligne de flottaison correspondant a la constante :"<<Constante<<" est a la cote Z = "<<c)
  
  return c;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 125 of file Archimede_VolumeSection.cxx.

{
  Standard_Integer i,noeud[3],flag[3];
  Standard_Integer nbNodes;
  TopExp_Explorer ex;
  TopLoc_Location L;
  Standard_Real z[3];
  Standard_Real Volume=0;
  Standard_Real Determinant=0;
  gp_Pnt P[3];
  
  // Projection du point d'initialisation sur le plan de section
  
  InitPoint.SetZ(Elevation);

  for (ex.Init(myShape, TopAbs_FACE); ex.More(); ex.Next()) 
    {
      TopoDS_Face F = TopoDS::Face(ex.Current());
      Handle(Poly_Triangulation) Tr = BRep_Tool::Triangulation(F, L);
      if(Tr.IsNull())
        MESSAGE("Error, null layer" )
      const Poly_Array1OfTriangle& triangles = Tr->Triangles();
      Standard_Integer nbTriangles = Tr->NbTriangles();
      nbNodes = Tr->NbNodes();
      const TColgp_Array1OfPnt& Nodes = Tr->Nodes();
      
      // Calcul des volumes de chaque triangle, de chaque face 
      //en tenant compte des triangles coup‰s par le plan de section
      
      for (i=1;i<=nbTriangles;i++) 
        {
          Determinant=0;
          //Gardons la meme orientation des noeuds
          if (F.Orientation()  == TopAbs_REVERSED)
            triangles(i).Get(noeud[0], noeud[2], noeud[1]);
          else 
            triangles(i).Get(noeud[0], noeud[1], noeud[2]);
          
          P[0] = Nodes(noeud[0]).Transformed(L.Transformation());
          z[0] = P[0].Z();
          P[1] = Nodes(noeud[1]).Transformed(L.Transformation());
          z[1] = P[1].Z();
          P[2] = Nodes(noeud[2]).Transformed(L.Transformation());
          z[2] = P[2].Z();

          // Determination des cas aux limites pour les triangles
          Standard_Integer i,compteur=0;

          for (i=0;i<=2;i++)
            {
              flag[i]=Standard_False;
              if(z[i]>=Elevation)
                {
                  flag[i]=Standard_True;
                  compteur++;
                }
            }
          
          switch(compteur)
            {
            case 0:
              Determinant = ElementaryVolume(P[0],P[1],P[2]);
              break;
              
            case 1:
              for (i=0;i<=2;i++)
                {
                  if (flag[i]==Standard_True)
                    {
                      gp_Pnt Result1 = Intersection(P[i],P[(i+1)%3],Elevation);
                      gp_Pnt Result2 = Intersection(P[i],P[(i+2)%3],Elevation);
                      Determinant = ElementaryVolume(Result1,P[(i+1)%3],P[(i+2)%3])
                        + ElementaryVolume(Result1,P[(i+2)%3],Result2);
                    }
                }
              break;
              
            case 2:
              for (i=0;i<=2;i++)
                {
                  if (flag[i]==Standard_False)
                    {
                      gp_Pnt Result1 = Intersection(P[i],P[(i+1)%3],Elevation);
                      gp_Pnt Result2 = Intersection(P[i],P[(i+2)%3],Elevation);
                      Determinant = ElementaryVolume(P[i],Result1,Result2);
                    }
                }
              break;
              
            case 3:
              break;
            }
          Volume += Determinant;
        }
    }
  
  return Volume;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 71 of file Archimede_VolumeSection.cxx.

{
  Standard_Integer i;
  Standard_Integer nbNodes;
  TopExp_Explorer ex;
  TopLoc_Location L;
  
  // Boucle sur les faces de la shape
  
  Xmin = 1000000000;
  Ymin = 1000000000;
  Zmin = 1000000000;
  Xmax = -1000000000;
  Ymax = -1000000000;
  Zmax = -1000000000;
  
  for (ex.Init(myShape, TopAbs_FACE); ex.More(); ex.Next()) 
    {
      TopoDS_Face F = TopoDS::Face(ex.Current());
      Handle(Poly_Triangulation) Tr = BRep_Tool::Triangulation(F, L);
      if(Tr.IsNull())
        MESSAGE("Error, null layer" )
      nbNodes = Tr->NbNodes();
      const TColgp_Array1OfPnt& Nodes = Tr->Nodes();
      
      // Calcul des dimensions de la boite englobante du solide
      
      for(i=1;i<=nbNodes;i++)
        {
          InitPoint = Nodes(i).Transformed(L.Transformation());
          if(InitPoint.X() < Xmin)
            Xmin = InitPoint.X();
          if(InitPoint.X() > Xmax)
            Xmax = InitPoint.X();
          if(InitPoint.Y() < Ymin)
            Ymin = InitPoint.Y();
          if(InitPoint.Y() > Ymax)
            Ymax = InitPoint.Y();
          if(InitPoint.Z() < Zmin)
            Zmin = InitPoint.Z();
          if(InitPoint.Z() > Zmax)
            Zmax = InitPoint.Z();
          
        }
    }
  
  // Creation du point d'initialisation, c'est € dire le centre de gravit‰ 
  //g‰om‰trique de la boite englobante
  
  InitPoint.SetX(0.5 * (Xmin + Xmax));
  InitPoint.SetY(0.5 * (Ymin + Ymax));
  InitPoint.SetZ(0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 377 of file Archimede_VolumeSection.cxx.

{
  Standard_Real Determinant;
  
  math_Matrix M(1,3,1,3);
  
  M(1,1)=P1.X()-InitPoint.X();
  M(1,2)=P2.X()-InitPoint.X();
  M(1,3)=P3.X()-InitPoint.X();
  M(2,1)=P1.Y()-InitPoint.Y();
  M(2,2)=P2.Y()-InitPoint.Y();
  M(2,3)=P3.Y()-InitPoint.Y();
  M(3,1)=P1.Z()-InitPoint.Z();
  M(3,2)=P2.Z()-InitPoint.Z();
  M(3,3)=P3.Z()-InitPoint.Z();
  
  Determinant = (1.0/6) * M.Determinant();

  return Determinant;
}

Here is the caller graph for this function:

TopoDS_Shape VolumeSection::GetShape ( )

Definition at line 61 of file Archimede_VolumeSection.cxx.

{
  return myShape;
}
void VolumeSection::getZ ( double &  min,
double &  max 
)

Definition at line 398 of file Archimede_VolumeSection.cxx.

{
  min = Zmin;
  max = Zmax;
}

Here is the caller graph for this function:

Standard_EXPORT VolumeSection::Handle ( Geom_RectangularTrimmedSurface  )
Standard_EXPORT VolumeSection::Handle ( Geom_RectangularTrimmedSurface  )

Here is the caller graph for this function:

Standard_EXPORT VolumeSection::Handle ( Geom_RectangularTrimmedSurface  )
Standard_EXPORT VolumeSection::Handle ( Geom_RectangularTrimmedSurface  )
VolumeSection::Handle ( Geom_Plane  ) [private]
gp_Pnt VolumeSection::Intersection ( gp_Pnt  P1,
gp_Pnt  P2,
Standard_Real  Hauteur 
) [private]

Definition at line 363 of file Archimede_VolumeSection.cxx.

{
  Standard_Real constante;
  gp_Pnt Point;

  constante = (Hauteur-P1.Z())/(P2.Z()-P1.Z());
  Point.SetX(P1.X()*(1-constante) + constante*P2.X());
  Point.SetY(P1.Y()*(1-constante) + constante*P2.Y());
  Point.SetZ(Hauteur);
  
  return Point;
}

Here is the caller graph for this function:

void VolumeSection::MakeRotation ( gp_Dir  PlaneDirection)

Definition at line 295 of file Archimede_VolumeSection.cxx.

{
  gp_Dir Zdirection(0.0,0.0,1.0);
  Standard_Real VariationAngle = 0;
  gp_Pnt RotationAxeLocation(0.0,0.0,0.0);
  gp_Dir RotationAxeDirection(1.0,1.0,1.0);
  gp_Ax1 RotationAxe(RotationAxeLocation,RotationAxeDirection);
  gp_Trsf Transformation;
  
  VariationAngle = Zdirection.Angle(PlaneDirection);
  RotationAxe.SetDirection(PlaneDirection.Crossed(Zdirection));
  Transformation.SetRotation(RotationAxe,VariationAngle);
  TopLoc_Location L(Transformation);
  myShape.Move(L);
  myPlane->Transform(Transformation);
}

Here is the caller graph for this function:

void VolumeSection::SetPlane ( Handle(Geom_Plane)  P)

Definition at line 66 of file Archimede_VolumeSection.cxx.

{
  myPlane = P;
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 70 of file Archimede_VolumeSection.hxx.

Definition at line 78 of file Archimede_VolumeSection.hxx.

TopoDS_Shape VolumeSection::myShape [private]

Definition at line 76 of file Archimede_VolumeSection.hxx.

Definition at line 70 of file Archimede_VolumeSection.hxx.

Definition at line 77 of file Archimede_VolumeSection.hxx.

Definition at line 79 of file Archimede_VolumeSection.hxx.

Definition at line 79 of file Archimede_VolumeSection.hxx.

Definition at line 79 of file Archimede_VolumeSection.hxx.

Definition at line 79 of file Archimede_VolumeSection.hxx.

Definition at line 79 of file Archimede_VolumeSection.hxx.

Definition at line 79 of file Archimede_VolumeSection.hxx.


The documentation for this class was generated from the following files: