// C++ : Gestion des Shapes (Hexa v5)
-// Copyright (C) 2009-2013 CEA/DEN, EDF R&D
+// Copyright (C) 2009-2016 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include "HexQuad.hxx"
#include "HexEdge.hxx"
+#include "HexMatrix.hxx"
#include "HexKas_functions.hxx"
#include "HexXmlWriter.hxx"
#include "HexXmlTree.hxx"
-#ifndef NO_CASCADE
#include <TopoDS.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Edge.hxx>
#include <BRep_Builder.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepPrimAPI_MakeSphere.hxx>
+#include <BRepBuilderAPI_Transform.hxx>
#include <BRep_Tool.hxx>
#include <gp_Lin.hxx>
#include <gp_Circ.hxx>
-
BEGIN_NAMESPACE_HEXA
static bool db = on_debug (); // == getenv ("HEXA_DB") > 0
-static bool db0 = true;
+static bool db0 = db;
// ====================================================== Constructeur
NewShape::NewShape (Document* dad, EnumShape type)
curr_subid += 7;
return subid;
}
+// ====================================================== transfoShape
+int NewShape::transfoShape (Matrix& matrice, SubShape* shape)
+{
+ gp_Trsf transfo;
+ double a11,a12,a13,a14, a21,a22,a23,a24, a31,a32,a33,a34;
+ matrice.getCoeff (a11,a12,a13,a14, a21,a22,a23,a24, a31,a32,a33,a34);
+ transfo.SetValues (a11,a12,a13,a14, a21,a22,a23,a24, a31,a32,a33,a34);
+
+ TopoDS_Shape shape_orig = shape->getShape ();
+ BRepBuilderAPI_Transform builder (shape_orig, transfo, Standard_True);
+ TopoDS_Shape result = builder.Shape();
+
+ geo_builder.Add (geo_compound, result);
+
+ int subid = curr_subid;
+ curr_subid += 2; // PROVISOIRE
+ return subid;
+}
+// ====================================================== translateShape
+int NewShape::translateShape (double dir[], SubShape* shape)
+{
+ gp_Trsf transfo;
+ gp_Vec vecteur (dir [dir_x], dir [dir_y], dir [dir_z]);
+ transfo.SetTranslation (vecteur);
+
+ TopoDS_Shape shape_orig = shape->getShape ();
+ BRepBuilderAPI_Transform builder (shape_orig, transfo, Standard_True);
+ TopoDS_Shape result = builder.Shape();
+
+ geo_builder.Add (geo_compound, result);
+
+ int subid = curr_subid;
+ curr_subid += 2; // PROVISOIRE
+ return subid;
+}
// ====================================================== addAssociation
void NewShape::addAssociation (Vertex* vertex, int subid, double param)
{
if (edge==NULL)
return;
+ if (db0)
+ {
+ cout << edge->getName()
+ << " = (" << edge->getVertex(0)->getName()
+ << ", " << edge->getVertex(1)->getName()
+ << ") --> subid= " << subid << " [ "
+ << pmin << ", " << pmax << "]" << endl;
+ }
+
asso_edge.push_back (edge);
asso_pmin.push_back (pmin);
asso_pmax.push_back (pmax);
}
return NULL;
}
+// ====================================================== findVertex
+VertexShape* NewShape::findVertex (double point[])
+{
+ int nbre = tab_vertex.size ();
+ for (int nro=0 ; nro < nbre ; nro++)
+ {
+ VertexShape* shape = tab_vertex [nro];
+ if (shape->definedBy (point))
+ return shape;
+ }
+ return NULL;
+}
// ====================================================== findEdge
EdgeShape* NewShape::findEdge (int shid)
{
}
return NULL;
}
+// ====================================================== findEdge
+EdgeShape* NewShape::findEdge (double p1[], double p2[])
+{
+ int nbre = tab_edge.size ();
+ for (int nro=0 ; nro < nbre ; nro++)
+ {
+ EdgeShape* shape = tab_edge [nro];
+ if (shape->definedBy (p1, p2))
+ return shape;
+ }
+ return NULL;
+}
// ====================================================== findFace
FaceShape* NewShape::findFace (int shid)
{
// ====================================================== getVertex
int NewShape::getVertex (int nro)
{
- if (nro <0 || nro >= tab_vertex.size())
+ if (nro <0 || nro >= (int) tab_vertex.size())
return 0;
SubShape* shape = tab_vertex [nro];
// ====================================================== getEdge
int NewShape::getEdge (int nro)
{
- if (nro <0 || nro >= tab_edge.size())
+ if (nro <0 || nro >= (int) tab_edge.size())
return 0;
SubShape* shape = tab_edge [nro];
// ====================================================== getFace
int NewShape::getFace (int nro)
{
- if (nro <0 || nro >= tab_face.size())
+ if (nro <0 || nro >= (int) tab_face.size())
return 0;
SubShape* shape = tab_face [nro];
// ====================================================== getNameVertex
cpchar NewShape::getNameVertex (int nro)
{
- if (nro <0 || nro >= tab_vertex.size())
+ if (nro <0 || nro >= (int) tab_vertex.size())
return "?";
SubShape* shape = tab_vertex [nro];
// ====================================================== getNameEdge
cpchar NewShape::getNameEdge (int nro)
{
- if (nro <0 || nro >= tab_edge.size())
+ if (nro <0 || nro >= (int) tab_edge.size())
return "?";
SubShape* shape = tab_edge [nro];
// ====================================================== getNameFace
cpchar NewShape::getNameFace (int nro)
{
- if (nro <0 || nro >= tab_face.size())
+ if (nro <0 || nro >= (int) tab_face.size())
return "?";
SubShape* shape = tab_face [nro];
// ====================================================== getFaceShape
FaceShape* NewShape::getFaceShape (int nro)
{
- if (nro <0 || nro >= tab_face.size())
+ if (nro <0 || nro >= (int) tab_face.size())
return 0;
FaceShape* shape = tab_face [nro];
// ====================================================== getEdgeShape
EdgeShape* NewShape::getEdgeShape (int nro)
{
- if (nro <0 || nro >= tab_edge.size())
+ if (nro <0 || nro >= (int) tab_edge.size())
return 0;
EdgeShape* shape = tab_edge [nro];
// ====================================================== getVertexShape
VertexShape* NewShape::getVertexShape (int nro)
{
- if (nro <0 || nro >= tab_vertex.size())
+ if (nro <0 || nro >= (int) tab_vertex.size())
return 0;
VertexShape* shape = tab_vertex [nro];
int NewShape::addPoint (double* point)
{
char suffix [32];
- int subid = tab_vertex.size() + 1;
+ int subid = tab_vertex.size() + 2;
- sprintf (suffix, ":vertex%02d", subid);
+ sprintf (suffix, ":vertex_%02d", subid);
string name = el_name + suffix;
VertexShape* sub_shape = new VertexShape (this, subid, point);
if (ier != HOK)
return ier;
- pfile fic = fopen (filename.c_str(), "w");
- if (fic==NULL)
- return HERR;
+ pfile fic = fopen (filename.c_str(), "w");
+ if (fic==NULL)
+ return HERR;
- fprintf (fic, "%s\n", geo_brep.c_str());
- fclose (fic);
+ fprintf (fic, "%s\n", geo_brep.c_str());
+ fclose (fic);
+ return HOK;
+}
+// ===================================================== getBrep
+cpchar NewShape::getBrep ()
+{
+ int ier = updateBrep ();
+ if (ier != HOK)
+ return NULL;
+ return geo_brep.c_str();
}
// ====================================================== saveXml
void NewShape::saveXml (XmlWriter* xml)
return HOK;
}
END_NAMESPACE_HEXA
-
-#else
-
-// ====================================================== ===================
-BEGIN_NAMESPACE_HEXA
-NewShape::NewShape (Document* dad) : EltBase (dad, EL_SHAPE) {}
-void NewShape::setShape (const TopoDS_Shape& shape) {}
-void NewShape::saveXml (XmlWriter* xml) {}
-SubShape* NewShape::findSubShape (int shid) { return NULL; }
-SubShape* NewShape::findVertex (int shid) { return NULL; }
-SubShape* NewShape::findEdge (int shid) { return NULL; }
-SubShape* NewShape::findFace (int shid) { return NULL; }
-
-int NewShape::getVertex (int nro) { return 0 ; }
-int NewShape::getEdge (int nro) { return 0 ; }
-int NewShape::getFace (int nro) { return 0 ; }
-
-cpchar NewShape::getNameVertex (int nro) { return "Nothing" ; }
-cpchar NewShape::getNameEdge (int nro) { return "Nothing" ; }
-cpchar NewShape::getNameFace (int nro) { return "Nothing" ; }
-
-END_NAMESPACE_HEXA
-#endif