Salome HOME
Updated copyright comment
[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-2024  CEA, EDF
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, or (at your option) any later version.
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 <GC_MakeCircle.hxx>
51 #include <Geom_Circle.hxx>
52 #include <gp_Circ.hxx>
53
54 #include <BRepBuilderAPI_MakeEdge.hxx>
55 #include <BRep_Tool.hxx>
56 ***************************************************/
57
58 BEGIN_NAMESPACE_HEXA
59
60 // ---------------------------------------------------------------------
61 bool requals (const double pnt1[], const double pnt2[]);
62 // ========================================================= cutAssociation
63 void Elements::cutAssociation (Edge* orig, Edges& tedges)
64 {
65    int   nbedges = tedges.size();
66    int   nbassos = orig->countAssociation();
67
68                             // ----------- Ordonnancement des shapes
69    PutData (nbassos);
70    double lgpara   = 0;
71    for (int ns = 0 ; ns<nbassos ; ns++)
72        {
73        AssoEdge* asso = orig->getAssociation (ns);
74        lgpara            += fabs (asso->getEnd () - asso->getStart ());
75        }
76
77    double     delta  = lgpara / nbedges;
78    int        nasso  = 0;
79    AssoEdge*  asso   = orig->getAssociation (nasso);
80    EdgeShape* shape  = asso->getEdgeShape ();
81    double     param1 = asso->getStart ();
82    double     parmax = asso->getEnd   ();
83
84    for (int ned = 0 ; ned<nbedges ; ned++)
85        {
86        Edge*   edge  = tedges [ned];
87        double param2 = param1 + delta;
88        if (ned>0)
89           {
90           Real3 point;
91           Vertex* node = edge->getVertex (V_AMONT);
92           shape->getPoint (param1, point);
93           node->setAssociation (point);
94           }
95        if (param2 <= parmax)
96           edge->addAssociation (shape, param1, param2);
97        else
98           {
99           edge->addAssociation (shape, param1, parmax);
100           nasso ++;
101           if (nasso >= nbassos)
102              return;
103           asso   = orig->getAssociation (nasso);
104           shape  = asso->getEdgeShape ();
105           param2 = param2 - 1;
106           parmax = asso->getEnd   ();
107           edge->addAssociation (shape, 0, param2);
108           }
109        param1 = param2;
110        }
111 }
112 // ====================================================== geom_dump_asso
113 void geom_dump_asso (Edge* edge)
114 {
115   std::cout << std::endl;
116   std::cout << " _______________________________________________________ "
117             << " dump_edge :" << std::endl;
118
119    if (edge==NULL || NOT edge->isHere ())
120       {
121       std::cout << "*** deleted ***" << std::endl;
122       return;
123       }
124
125    std::cout << std::endl;
126    std::cout << " ... Edge = " << edge->getName ()
127              << " = (" << edge->getVertex(V_AMONT)->getName()
128              <<   ", " << edge->getVertex(V_AVAL )->getName() << ")" << std::endl;
129
130    for (int nro=0 ; nro<V_TWO ; nro++)
131        {
132        Vertex* node  = edge->getVertex (nro);
133        std::cout << " ... " << node->getName()
134             <<  " = (" << node->getX()
135             <<    ", " << node->getY()
136             <<    ", " << node->getZ() << ")";
137
138        if (node->isAssociated())
139          std::cout << " --> (" << node->getAssoX()
140                    <<     ", " << node->getAssoY()
141                    <<     ", " << node->getAssoZ() << ")";
142        else
143          std::cout << " (not associated)";
144        std::cout << std::endl;
145        }
146
147    int nbr_associations = edge->countAssociation ();
148    PutData (nbr_associations);
149
150    for (int nro=0 ; nro<nbr_associations ; nro++)
151        {
152        AssoEdge* asso = edge->getAssociation (nro);
153        std::cout << " *** Association nro " << nro+1 << std::endl;
154        const double* shape_origin = asso->getOrigin();
155        const double* shape_extrem = asso->getExtrem();
156        PutData  (asso->getStart());
157        PutData  (asso->getEnd());
158        PutCoord (shape_origin);
159        PutCoord (shape_extrem);
160        }
161    std::cout << std::endl << std::endl;
162 }
163 END_NAMESPACE_HEXA