Salome HOME
4b943ce23930af5434aefad043c04c02eee4b100
[modules/hexablock.git] / src / HEXABLOCK / HexElements_asso.cxx
1 //
2 // CC++ : Ancienne interface Cascade de la classe Elements ** A SUPPRIMER **
3 //
4 // Copyright (C) 2009-2013  CEA/DEN, EDF R&D
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "HexElements.hxx"
24 #include "HexEdge.hxx"
25 #include "HexDocument.hxx"
26 #include "HexEdgeShape.hxx"
27 #include "HexAssoEdge.hxx"
28 #include "HexVertex.hxx"
29
30 /*****************************************
31 #include <BRepTools.hxx>
32 #include <BRep_Builder.hxx>
33 #include <BRepAdaptor_Curve.hxx>
34 #include <BRepBuilderAPI_Transform.hxx>
35 #include <BRepBuilderAPI_MakeVertex.hxx>
36
37 #include <GCPnts_AbscissaPoint.hxx>
38
39 #include <TopoDS.hxx>
40 #include <TopoDS_Shape.hxx>
41 #include <TopoDS_Edge.hxx>
42 #include <TopoDS_Compound.hxx>
43 #include <TopoDS_Vertex.hxx>
44
45 #include <gp_Pln.hxx>
46 #include <gp_Pnt.hxx>
47 #include <gp_Dir.hxx>
48 #include <gp_Lin.hxx>
49                                     // Cercles
50 #include <GEOMImpl_CircleDriver.hxx>
51 #include <GEOMImpl_ICircle.hxx>
52 #include <GC_MakeCircle.hxx>
53 #include <Geom_Circle.hxx>
54 #include <gp_Circ.hxx>
55
56 #include <BRepBuilderAPI_MakeEdge.hxx>
57 #include <BRep_Tool.hxx>
58 ***************************************************/
59
60 BEGIN_NAMESPACE_HEXA
61
62 // ---------------------------------------------------------------------
63 bool requals (const double pnt1[], const double pnt2[]);
64 // ========================================================= cutAssociation
65 void Elements::cutAssociation (Edge* orig, Edges& tedges)
66 {
67    int   nbedges = tedges.size();
68    int   nbassos = orig->countAssociation();
69
70                             // ----------- Ordonnancement des shapes
71    PutData (nbassos);
72    double lgpara   = 0;
73    for (int ns = 0 ; ns<nbassos ; ns++)
74        {
75        AssoEdge* asso = orig->getAssociation (ns);
76        lgpara            += fabs (asso->getEnd () - asso->getStart ());
77        }
78
79    double     delta  = lgpara / nbedges;
80    int        nasso  = 0;
81    AssoEdge*  asso   = orig->getAssociation (nasso);
82    EdgeShape* shape  = asso->getEdgeShape ();
83    double     param1 = asso->getStart ();
84    double     parmax = asso->getEnd   ();
85
86    for (int ned = 0 ; ned<nbedges ; ned++)
87        {
88        Edge*   edge  = tedges [ned];
89        double param2 = param1 + delta;
90        if (ned>0)
91           {
92           Real3 point;
93           Vertex* node = edge->getVertex (V_AMONT);
94           shape->getPoint (param1, point);
95           node->setAssociation (point);
96           }
97        if (param2 <= parmax)
98           edge->addAssociation (shape, param1, param2);
99        else
100           {
101           edge->addAssociation (shape, param1, parmax);
102           nasso ++;
103           if (nasso >= nbassos)
104              return;
105           asso   = orig->getAssociation (nasso);
106           shape  = asso->getEdgeShape ();
107           param2 = param2 - 1;
108           parmax = asso->getEnd   ();
109           edge->addAssociation (shape, 0, param2);
110           }
111        param1 = param2;
112        }
113 }
114 // ====================================================== geom_dump_asso
115 void geom_dump_asso (Edge* edge)
116 {
117    cout << endl;
118    cout << " _______________________________________________________ "
119          << " dump_edge :" << endl;
120
121    if (edge==NULL || NOT edge->isHere ())
122       {
123       cout << "*** deleted ***" << endl;
124       return;
125       }
126
127    cout << endl;
128    cout << " ... Edge = " << edge->getName ()
129         << " = (" << edge->getVertex(V_AMONT)->getName()
130         <<   ", " << edge->getVertex(V_AVAL )->getName() << ")" << endl;
131
132    for (int nro=0 ; nro<V_TWO ; nro++)
133        {
134        Vertex* node  = edge->getVertex (nro);
135        cout << " ... " << node->getName()
136             <<  " = (" << node->getX()
137             <<    ", " << node->getY()
138             <<    ", " << node->getZ() << ")";
139
140        if (node->isAssociated())
141            cout << " --> (" << node->getAssoX()
142                 <<     ", " << node->getAssoY()
143                 <<     ", " << node->getAssoZ() << ")";
144        else
145            cout << " (not associated)";
146        cout << endl;
147        }
148
149    int nbr_associations = edge->countAssociation ();
150    PutData (nbr_associations);
151
152    for (int nro=0 ; nro<nbr_associations ; nro++)
153        {
154        AssoEdge* asso = edge->getAssociation (nro);
155        cout << " *** Association nro " << nro+1 << endl;
156        const double* shape_origin = asso->getOrigin();
157        const double* shape_extrem = asso->getExtrem();
158        PutData  (asso->getStart());
159        PutData  (asso->getEnd());
160        PutCoord (shape_origin);
161        PutCoord (shape_extrem);
162        }
163    cout << endl << endl;
164 }
165 END_NAMESPACE_HEXA