MAGiC  V5.0
Mailleurs Automatiques de Géometries intégrés à la Cao
mg_primitive_ellipsoide_revolution.cpp
Aller à la documentation de ce fichier.
1 //####//------------------------------------------------------------
2 //####//------------------------------------------------------------
3 //####// MAGiC
4 //####// Jean Christophe Cuilliere et Vincent FRANCOIS
5 //####// Departement de Genie Mecanique - UQTR
6 //####//------------------------------------------------------------
7 //####// MAGIC est un projet de recherche de l equipe ERICCA
8 //####// du departement de genie mecanique de l Universite du Quebec a Trois Rivieres
9 //####// http://www.uqtr.ca/ericca
10 //####// http://www.uqtr.ca/
11 //####//------------------------------------------------------------
12 //####//------------------------------------------------------------
13 //####//
14 //####// mg_primitive_ellipsoide_revolution.cpp
15 //####//
16 //####//------------------------------------------------------------
17 //####//------------------------------------------------------------
18 //####// COPYRIGHT 2000-2024
19 //####// jeu 13 jun 2024 11:58:54 EDT
20 //####//------------------------------------------------------------
21 //####//------------------------------------------------------------
22 #ifdef CSG_OCC
23 
24 #include "gestionversion.h"
26 #include <TopoDS_Shape.hxx>
27 #include <TopoDS_Edge.hxx>
28 #include <TopoDS_Wire.hxx>
29 #include <TopoDS_TFace.hxx>
30 #include <gp_Elips.hxx>
31 #include <GC_MakeArcOfEllipse.hxx>
32 #include <Geom_TrimmedCurve.hxx>
33 #include <gp_Ax2.hxx>
34 #include <gp_Dir.hxx>
35 #include <gp_Pnt.hxx>
36 #include <BRepBuilderAPI_MakeEdge.hxx>
37 #include <BRepBuilderAPI_MakeWire.hxx>
38 #include <BRepBuilderAPI_MakeFace.hxx>
39 #include <BRepPrimAPI_MakeRevol.hxx>
40 
41 
42 
43 MG_PRIMITIVE_ELLIPSOIDE_REVOLUTION::MG_PRIMITIVE_ELLIPSOIDE_REVOLUTION(double centre_x,double centre_y, double centre_z,
44  double axe_x,double axe_y,double axe_z,
45  double rayon_majeur, double rayon_mineur)
46 {
47  m_centre[0]=centre_x;
48  m_centre[1]=centre_y;
49  m_centre[2]=centre_z;
50  m_axe[0]=axe_x;
51  m_axe[1]=axe_y;
52  m_axe[2]=axe_z;
53  m_dimensions[0]=rayon_majeur;
54  m_dimensions[1]=rayon_mineur;
55 }
56 
57 MG_PRIMITIVE_ELLIPSOIDE_REVOLUTION::MG_PRIMITIVE_ELLIPSOIDE_REVOLUTION(long unsigned int num,
58  double centre_x,double centre_y, double centre_z,
59  double axe_x,double axe_y,double axe_z,
60  double rayon_majeur, double rayon_mineur): MG_PRIMITIVE(num)
61 {
62  m_centre[0]=centre_x;
63  m_centre[1]=centre_y;
64  m_centre[2]=centre_z;
65  m_axe[0]=axe_x;
66  m_axe[1]=axe_y;
67  m_axe[2]=axe_z;
68  m_dimensions[0]=rayon_majeur;
69  m_dimensions[1]=rayon_mineur;
70 }
71 MG_PRIMITIVE_ELLIPSOIDE_REVOLUTION::MG_PRIMITIVE_ELLIPSOIDE_REVOLUTION(MG_PRIMITIVE_ELLIPSOIDE_REVOLUTION& mdd):MG_PRIMITIVE(mdd)
72 {
73 
74 }
75 
76 MG_PRIMITIVE_ELLIPSOIDE_REVOLUTION::~MG_PRIMITIVE_ELLIPSOIDE_REVOLUTION()
77 {
78 
79 }
80 
81 void MG_PRIMITIVE_ELLIPSOIDE_REVOLUTION::construit(void)
82 {
83  centre_ellipsoide = new gp_Pnt(m_centre[0],m_centre[1],m_centre[2]);
84  direction_ellipsoide = new gp_Dir(m_axe[0],m_axe[1],m_axe[2]);
85  axe_ellipsoide = new gp_Ax2;
86  axe_ellipsoide->SetLocation(*centre_ellipsoide);
87  axe_ellipsoide->SetDirection(*direction_ellipsoide);
88  axe_ellipsoide->Rotate(gp_Ax1(*centre_ellipsoide,axe_ellipsoide->YDirection()),M_PI/2.);
89  if(m_dimensions[0]>=m_dimensions[1])
90  {
91  ellipse = new gp_Elips(*axe_ellipsoide,m_dimensions[0],m_dimensions[1]);
92  }
93  else
94  {
95  ellipse = new gp_Elips(*axe_ellipsoide,m_dimensions[1],m_dimensions[0]);
96  }
97  edge = new TopoDS_Edge;
98  *edge = BRepBuilderAPI_MakeEdge(*ellipse,0.0,M_PI).Edge();
99  wire = new TopoDS_Wire;
100  *wire = BRepBuilderAPI_MakeWire(*edge).Wire();
101  face = new TopoDS_Face;
102  *face = BRepBuilderAPI_MakeFace(*wire,true);
103  direction_axe_revolution = new gp_Dir(m_axe[0],m_axe[1],m_axe[2]);
104  axe_revolution = new gp_Ax1;
105  axe_revolution->SetLocation(*centre_ellipsoide);
106  axe_revolution->SetDirection(*direction_axe_revolution);
107  forme = BRepPrimAPI_MakeRevol(*face,*axe_revolution,2.*M_PI).Shape();
108 }
109 
110 void MG_PRIMITIVE_ELLIPSOIDE_REVOLUTION::enregistrer(std::ostream& o, double version)
111 {
112  o << "%" << get_id() << "=ELLIPSOIDE_REVOLUTION("<< m_centre[0] << "," << m_centre[1] << "," << m_centre[2]
113  << "," << m_axe[0] << "," << m_axe[1] << "," << m_axe[2]
114  << "," << m_dimensions[0] << "," << m_dimensions[1]
115  << ");" << std::endl;
116 
117 }
118 
119 
120 
121 
122 
123 
124 #endif