mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-02-05 19:34:18 +05:00
modification in API
This commit is contained in:
parent
07312a1c50
commit
1a0e41bedd
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "BooleanField.hxx"
|
#include "BooleanField.hxx"
|
||||||
#include "BooleanStep.hxx"
|
#include "BooleanStep.hxx"
|
||||||
|
#include "XaoUtils.hxx"
|
||||||
|
|
||||||
#include <Utils_SALOME_Exception.hxx>
|
#include <Utils_SALOME_Exception.hxx>
|
||||||
|
|
||||||
@ -43,6 +44,9 @@ BooleanStep* BooleanField::addStep(const int& step)
|
|||||||
|
|
||||||
BooleanStep* BooleanField::addStep(const int& step, const int& stamp)
|
BooleanStep* BooleanField::addStep(const int& step, const int& stamp)
|
||||||
{
|
{
|
||||||
|
if (hasStep(step))
|
||||||
|
throw SALOME_Exception(MsgBuilder() << "Step with number " << step << "already exists.");
|
||||||
|
|
||||||
BooleanStep* bstep = new BooleanStep(step, stamp, m_nbElements, m_nbComponents);
|
BooleanStep* bstep = new BooleanStep(step, stamp, m_nbElements, m_nbComponents);
|
||||||
m_steps.push_back(bstep);
|
m_steps.push_back(bstep);
|
||||||
return bstep;
|
return bstep;
|
||||||
|
@ -20,20 +20,24 @@
|
|||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
#include <Standard_TypeMismatch.hxx>
|
||||||
|
|
||||||
|
#include <BRepTools.hxx>
|
||||||
|
#include <BRep_Builder.hxx>
|
||||||
|
#include <TopAbs.hxx>
|
||||||
#include <TopTools_MapOfShape.hxx>
|
#include <TopTools_MapOfShape.hxx>
|
||||||
#include <TopTools_ListOfShape.hxx>
|
#include <TopTools_ListOfShape.hxx>
|
||||||
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||||
#include <TopTools_IndexedMapOfShape.hxx>
|
#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
#include <TopExp.hxx>
|
#include <TopExp.hxx>
|
||||||
#include <TopExp_Explorer.hxx>
|
#include <TopExp_Explorer.hxx>
|
||||||
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
//#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||||
#include <TColStd_HArray1OfInteger.hxx>
|
//#include <TColStd_HArray1OfInteger.hxx>
|
||||||
#include <TColStd_HSequenceOfInteger.hxx>
|
//#include <TColStd_HSequenceOfInteger.hxx>
|
||||||
#include <GProp_GProps.hxx>
|
#include <GProp_GProps.hxx>
|
||||||
#include <BRepGProp.hxx>
|
#include <BRepGProp.hxx>
|
||||||
#include <TopoDS.hxx>
|
#include <TopoDS.hxx>
|
||||||
#include <TopoDS_Vertex.hxx>
|
#include <TopoDS_Vertex.hxx>
|
||||||
#include <BRep_Tool.hxx>
|
|
||||||
|
|
||||||
#include <Utils_SALOME_Exception.hxx>
|
#include <Utils_SALOME_Exception.hxx>
|
||||||
|
|
||||||
@ -50,7 +54,46 @@ BrepGeometry::BrepGeometry(const std::string& name) : Geometry(name)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
TopoDS_Shape BrepGeometry::getGeometricalElement(TopAbs_ShapeEnum shapeType, const int& shapeIndex)
|
const std::string BrepGeometry::getShape()
|
||||||
|
{
|
||||||
|
std::ostringstream streamShape;
|
||||||
|
BRepTools::Write(m_shape, streamShape);
|
||||||
|
std::string data = streamShape.str();
|
||||||
|
char* res = new char[data.size()];
|
||||||
|
strcpy(res, data.c_str());
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrepGeometry::setShape(const std::string& shape)
|
||||||
|
{
|
||||||
|
std::istringstream streamBrep(shape.c_str());
|
||||||
|
BRep_Builder builder;
|
||||||
|
BRepTools::Read(m_shape, streamBrep, builder);
|
||||||
|
|
||||||
|
initIds();
|
||||||
|
}
|
||||||
|
|
||||||
|
TopoDS_Shape BrepGeometry::getTopoDS_Shape()
|
||||||
|
{
|
||||||
|
return m_shape;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrepGeometry::setTopoDS_Shape(const TopoDS_Shape& shape)
|
||||||
|
{
|
||||||
|
m_shape = shape;
|
||||||
|
initIds();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrepGeometry::initIds()
|
||||||
|
{
|
||||||
|
// intialization of Ids
|
||||||
|
initListIds(TopAbs_VERTEX, m_vertices);
|
||||||
|
initListIds(TopAbs_EDGE, m_edges);
|
||||||
|
initListIds(TopAbs_FACE, m_faces);
|
||||||
|
initListIds(TopAbs_SOLID, m_solids);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrepGeometry::initListIds(const TopAbs_ShapeEnum& shapeType, GeometricElementList& eltList)
|
||||||
{
|
{
|
||||||
TopTools_MapOfShape mapShape;
|
TopTools_MapOfShape mapShape;
|
||||||
TopTools_ListOfShape listShape;
|
TopTools_ListOfShape listShape;
|
||||||
@ -62,24 +105,61 @@ TopoDS_Shape BrepGeometry::getGeometricalElement(TopAbs_ShapeEnum shapeType, con
|
|||||||
listShape.Append(exp.Current());
|
listShape.Append(exp.Current());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!listShape.IsEmpty())
|
if (listShape.IsEmpty())
|
||||||
{
|
return;
|
||||||
|
|
||||||
TopTools_IndexedMapOfShape indices;
|
TopTools_IndexedMapOfShape indices;
|
||||||
TopExp::MapShapes(m_shape, indices);
|
TopExp::MapShapes(m_shape, indices);
|
||||||
|
|
||||||
|
std::list<int> indexList;
|
||||||
TopTools_ListIteratorOfListOfShape itSub(listShape);
|
TopTools_ListIteratorOfListOfShape itSub(listShape);
|
||||||
for (int index = 1; itSub.More(); itSub.Next(), ++index)
|
for (int index = 1; itSub.More(); itSub.Next(), ++index)
|
||||||
{
|
{
|
||||||
TopoDS_Shape value = itSub.Value();
|
TopoDS_Shape value = itSub.Value();
|
||||||
if (shapeIndex == (int)indices.FindIndex(value))
|
indexList.push_back(indices.FindIndex(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::list<int>::iterator it = indexList.begin();
|
||||||
|
|
||||||
|
eltList.setSize(indexList.size());
|
||||||
|
for (int i = 0; it != indexList.end(); it++, i++)
|
||||||
|
eltList.setReference(i, XaoUtils::intToString((*it)));
|
||||||
|
}
|
||||||
|
|
||||||
|
TopoDS_Shape BrepGeometry::getSubShape(const TopoDS_Shape& mainShape, const TopAbs_ShapeEnum& shapeType, const int& shapeIndex)
|
||||||
|
{
|
||||||
|
TopTools_MapOfShape mapShape;
|
||||||
|
TopTools_ListOfShape listShape;
|
||||||
|
|
||||||
|
TopExp_Explorer exp(mainShape, shapeType);
|
||||||
|
for (; exp.More(); exp.Next())
|
||||||
|
{
|
||||||
|
if (mapShape.Add(exp.Current()))
|
||||||
|
listShape.Append(exp.Current());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!listShape.IsEmpty())
|
||||||
|
{
|
||||||
|
// use main shape indices
|
||||||
|
TopTools_IndexedMapOfShape indices;
|
||||||
|
TopExp::MapShapes(mainShape, indices);
|
||||||
|
|
||||||
|
TopTools_ListIteratorOfListOfShape itSub(listShape);
|
||||||
|
for (int index = 1; itSub.More(); itSub.Next(), ++index)
|
||||||
|
{
|
||||||
|
if (shapeIndex + 1 == index)
|
||||||
|
{
|
||||||
|
TopoDS_Shape value = itSub.Value();
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
throw SALOME_Exception(MsgBuilder() << "Shape not found: " << shapeIndex);
|
throw SALOME_Exception(MsgBuilder() << "Shape with reference [" << shapeIndex << "] not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
const int BrepGeometry::countGeometricalElements(TopoDS_Shape shape, TopAbs_ShapeEnum shapeType)
|
// -----------------------------
|
||||||
|
const int BrepGeometry::countGeometricalElements(const TopoDS_Shape& shape, const TopAbs_ShapeEnum& shapeType)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
TopTools_MapOfShape mapShape;
|
TopTools_MapOfShape mapShape;
|
||||||
@ -93,7 +173,7 @@ const int BrepGeometry::countGeometricalElements(TopoDS_Shape shape, TopAbs_Shap
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> BrepGeometry::getGeometricalElements(TopoDS_Shape shape, TopAbs_ShapeEnum shapeType)
|
std::vector<int> BrepGeometry::getGeometricalElements(const TopoDS_Shape& shape, const TopAbs_ShapeEnum& shapeType, const XAO::Dimension& dim)
|
||||||
{
|
{
|
||||||
std::vector<int> indexList;
|
std::vector<int> indexList;
|
||||||
|
|
||||||
@ -109,65 +189,71 @@ std::vector<int> BrepGeometry::getGeometricalElements(TopoDS_Shape shape, TopAbs
|
|||||||
|
|
||||||
if (!listShape.IsEmpty())
|
if (!listShape.IsEmpty())
|
||||||
{
|
{
|
||||||
|
// use the shape of the geometry for the indices
|
||||||
TopTools_IndexedMapOfShape indices;
|
TopTools_IndexedMapOfShape indices;
|
||||||
TopExp::MapShapes(shape, indices);
|
TopExp::MapShapes(m_shape, indices);
|
||||||
|
|
||||||
TopTools_ListIteratorOfListOfShape itSub(listShape);
|
TopTools_ListIteratorOfListOfShape itSub(listShape);
|
||||||
for (int index = 1; itSub.More(); itSub.Next(), ++index)
|
for (int index = 1; itSub.More(); itSub.Next(), ++index)
|
||||||
{
|
{
|
||||||
TopoDS_Shape value = itSub.Value();
|
TopoDS_Shape value = itSub.Value();
|
||||||
indexList.push_back(indices.FindIndex(value));
|
int id = indices.FindIndex(value);
|
||||||
|
indexList.push_back(findElement(dim, id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return indexList;
|
return indexList;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrepGeometry::getEdgeVertices(const int& edge, int& vertexA, int& vertexB)
|
void BrepGeometry::getEdgeVertices(const int& edgeIndex, int& vertexA, int& vertexB)
|
||||||
{
|
{
|
||||||
TopoDS_Shape shape = getGeometricalElement(TopAbs_EDGE, edge);
|
TopoDS_Shape edge = getSubShape(m_shape, TopAbs_EDGE, edgeIndex);
|
||||||
std::vector<int> vertices = getGeometricalElements(shape, TopAbs_VERTEX);
|
std::vector<int> vertices = getGeometricalElements(edge, TopAbs_VERTEX, XAO::VERTEX);
|
||||||
assert(vertices.size() == 2);
|
assert(vertices.size() == 2);
|
||||||
|
|
||||||
vertexA = vertices[0];
|
vertexA = vertices[0];
|
||||||
vertexB = vertices[1];
|
vertexB = vertices[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
const int BrepGeometry::countFaceWires(const int& face)
|
const int BrepGeometry::countFaceWires(const int& faceIndex)
|
||||||
{
|
{
|
||||||
TopoDS_Shape shape = getGeometricalElement(TopAbs_FACE, face);
|
TopoDS_Shape face = getSubShape(m_shape, TopAbs_FACE, faceIndex);
|
||||||
return countGeometricalElements(shape, TopAbs_WIRE);
|
return countGeometricalElements(face, TopAbs_WIRE);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> BrepGeometry::getFaceWires(const int& face)
|
std::vector<int> BrepGeometry::getFaceEdges(const int& faceIndex, const int& wireIndex)
|
||||||
{
|
{
|
||||||
TopoDS_Shape shape = getGeometricalElement(TopAbs_FACE, face);
|
// get the face
|
||||||
return getGeometricalElements(shape, TopAbs_WIRE);
|
TopoDS_Shape face = getSubShape(m_shape, TopAbs_FACE, faceIndex);
|
||||||
|
// get the wire
|
||||||
|
TopoDS_Shape wire = getSubShape(face, TopAbs_WIRE, wireIndex);
|
||||||
|
return getGeometricalElements(wire, TopAbs_EDGE, XAO::EDGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
const int BrepGeometry::countSolidShells(const int& solid)
|
const int BrepGeometry::countSolidShells(const int& solidIndex)
|
||||||
{
|
{
|
||||||
TopoDS_Shape shape = getGeometricalElement(TopAbs_SOLID, solid);
|
TopoDS_Shape solid = getSubShape(m_shape, TopAbs_SOLID, solidIndex);
|
||||||
return countGeometricalElements(shape, TopAbs_SHELL);
|
return countGeometricalElements(solid, TopAbs_SHELL);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> BrepGeometry::getSolidShells(const int& solid)
|
std::vector<int> BrepGeometry::getSolidFaces(const int& solidIndex, const int& shellIndex)
|
||||||
{
|
{
|
||||||
TopoDS_Shape shape = getGeometricalElement(TopAbs_SOLID, solid);
|
TopoDS_Shape solid = getSubShape(m_shape, TopAbs_SOLID, solidIndex);
|
||||||
return getGeometricalElements(shape, TopAbs_SHELL);
|
TopoDS_Shape shell = getSubShape(solid, TopAbs_SHELL, shellIndex);
|
||||||
|
return getGeometricalElements(shell, TopAbs_FACE, XAO::FACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrepGeometry::getVertexXYZ(const int& vertex, double& xCoord, double& yCoord, double& zCoord)
|
void BrepGeometry::getVertexXYZ(const int& vertexIndex, double& xCoord, double& yCoord, double& zCoord)
|
||||||
{
|
{
|
||||||
xCoord = 0.;
|
xCoord = 0.;
|
||||||
yCoord = 0.;
|
yCoord = 0.;
|
||||||
zCoord = 0.;
|
zCoord = 0.;
|
||||||
|
|
||||||
TopoDS_Shape shape = getGeometricalElement(TopAbs_VERTEX, vertex);
|
TopoDS_Shape vertex = getSubShape(m_shape, TopAbs_VERTEX, vertexIndex);
|
||||||
if (shape.ShapeType() != TopAbs_VERTEX)
|
if (vertex.ShapeType() != TopAbs_VERTEX)
|
||||||
throw SALOME_Exception(MsgBuilder() << "Shape " << vertex << " is not a point.");
|
throw SALOME_Exception(MsgBuilder() << "Shape " << vertexIndex<< " is not a point.");
|
||||||
|
|
||||||
TopoDS_Vertex point = TopoDS::Vertex(shape);
|
TopoDS_Vertex point = TopoDS::Vertex(vertex);
|
||||||
if (!point.IsNull())
|
if (!point.IsNull())
|
||||||
{
|
{
|
||||||
gp_Pnt aPnt = BRep_Tool::Pnt(point);
|
gp_Pnt aPnt = BRep_Tool::Pnt(point);
|
||||||
@ -177,68 +263,85 @@ void BrepGeometry::getVertexXYZ(const int& vertex, double& xCoord, double& yCoor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const double BrepGeometry::getEdgeLength(const int& edge)
|
// -----------------------------
|
||||||
|
const double BrepGeometry::getEdgeLength(const int& edgeIndex)
|
||||||
{
|
{
|
||||||
TopoDS_Shape shape = getGeometricalElement(TopAbs_EDGE, edge);
|
TopoDS_Shape edge = getSubShape(m_shape, TopAbs_EDGE, edgeIndex);
|
||||||
GProp_GProps system;
|
GProp_GProps system;
|
||||||
BRepGProp::LinearProperties(shape, system);
|
BRepGProp::LinearProperties(edge, system);
|
||||||
return system.Mass();
|
return system.Mass();
|
||||||
}
|
}
|
||||||
|
|
||||||
const double BrepGeometry::getFaceArea(const int& face)
|
const double BrepGeometry::getFaceArea(const int& faceIndex)
|
||||||
{
|
{
|
||||||
TopoDS_Shape shape = getGeometricalElement(TopAbs_FACE, face);
|
TopoDS_Shape face = getSubShape(m_shape, TopAbs_FACE, faceIndex);
|
||||||
GProp_GProps system;
|
GProp_GProps system;
|
||||||
BRepGProp::SurfaceProperties(shape, system);
|
BRepGProp::SurfaceProperties(face, system);
|
||||||
return system.Mass();
|
return system.Mass();
|
||||||
}
|
}
|
||||||
|
|
||||||
const double BrepGeometry::getSolidVolume(const int& solid)
|
const double BrepGeometry::getSolidVolume(const int& solidIndex)
|
||||||
{
|
{
|
||||||
TopoDS_Shape shape = getGeometricalElement(TopAbs_SOLID, solid);
|
TopoDS_Shape solid = getSubShape(m_shape, TopAbs_SOLID, solidIndex);
|
||||||
GProp_GProps system;
|
GProp_GProps system;
|
||||||
BRepGProp::VolumeProperties(shape, system);
|
BRepGProp::VolumeProperties(solid, system);
|
||||||
return system.Mass();
|
return system.Mass();
|
||||||
}
|
}
|
||||||
|
|
||||||
const int BrepGeometry::getVertexID(const int& vertex)
|
// -----------------------------
|
||||||
|
const int BrepGeometry::getVertexID(const int& index)
|
||||||
{
|
{
|
||||||
return XaoUtils::stringToInt(getVertexReference(vertex));
|
return XaoUtils::stringToInt(getVertexReference(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
const int BrepGeometry::getEdgeID(const int& edge)
|
const int BrepGeometry::getEdgeID(const int& index)
|
||||||
{
|
{
|
||||||
return XaoUtils::stringToInt(getEdgeReference(edge));
|
return XaoUtils::stringToInt(getEdgeReference(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
const int BrepGeometry::getFaceID(const int& face)
|
const int BrepGeometry::getFaceID(const int& index)
|
||||||
{
|
{
|
||||||
return XaoUtils::stringToInt(getFaceReference(face));
|
return XaoUtils::stringToInt(getFaceReference(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
const int BrepGeometry::getSolidID(const int& solid)
|
const int BrepGeometry::getSolidID(const int& index)
|
||||||
{
|
{
|
||||||
return XaoUtils::stringToInt(getSolidReference(solid));
|
return XaoUtils::stringToInt(getSolidReference(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrepGeometry::setVertexID(const int& vertex, const int& id)
|
// -----------------------------
|
||||||
|
void BrepGeometry::setVertexID(const int& index, const int& id)
|
||||||
{
|
{
|
||||||
setVertexReference(vertex, XaoUtils::intToString(id));
|
setVertexReference(index, XaoUtils::intToString(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrepGeometry::setEdgeID(const int& edge, const int& id)
|
void BrepGeometry::setEdgeID(const int& index, const int& id)
|
||||||
{
|
{
|
||||||
setEdgeReference(edge, XaoUtils::intToString(id));
|
setEdgeReference(index, XaoUtils::intToString(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrepGeometry::setFaceID(const int& face, const int& id)
|
void BrepGeometry::setFaceID(const int& index, const int& id)
|
||||||
{
|
{
|
||||||
setEdgeReference(face, XaoUtils::intToString(id));
|
setEdgeReference(index, XaoUtils::intToString(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrepGeometry::setSolidID(const int& solid, const int& id)
|
void BrepGeometry::setSolidID(const int& index, const int& id)
|
||||||
{
|
{
|
||||||
setEdgeReference(solid, XaoUtils::intToString(id));
|
setEdgeReference(index, XaoUtils::intToString(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------
|
||||||
|
const int BrepGeometry::findElement(const XAO::Dimension& dim, const int& id)
|
||||||
|
{
|
||||||
|
if (dim == XAO::VERTEX)
|
||||||
|
return findVertex(id);
|
||||||
|
if (dim == XAO::EDGE)
|
||||||
|
return findEdge(id);
|
||||||
|
if (dim == XAO::FACE)
|
||||||
|
return findFace(id);
|
||||||
|
if (dim == XAO::SOLID)
|
||||||
|
return findSolid(id);
|
||||||
|
throw SALOME_Exception(MsgBuilder() << "Unknown Dimension: " << dim);
|
||||||
}
|
}
|
||||||
|
|
||||||
const int BrepGeometry::findVertex(const int& id)
|
const int BrepGeometry::findVertex(const int& id)
|
||||||
@ -261,6 +364,7 @@ const int BrepGeometry::findSolid(const int& id)
|
|||||||
return getSolidIndexByReference(XaoUtils::intToString(id));
|
return getSolidIndexByReference(XaoUtils::intToString(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------
|
||||||
const std::string BrepGeometry::findVertexName(const int& id)
|
const std::string BrepGeometry::findVertexName(const int& id)
|
||||||
{
|
{
|
||||||
return getVertexName(findVertex(id));
|
return getVertexName(findVertex(id));
|
||||||
@ -281,6 +385,7 @@ const std::string BrepGeometry::findSolidName(const int& id)
|
|||||||
return getSolidName(findSolid(id));
|
return getSolidName(findSolid(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------
|
||||||
void BrepGeometry::changeVertexName(const int& id, const std::string& name)
|
void BrepGeometry::changeVertexName(const int& id, const std::string& name)
|
||||||
{
|
{
|
||||||
setVertexName(findVertex(id), name);
|
setVertexName(findVertex(id), name);
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <SALOMEconfig.h>
|
|
||||||
#include <TopoDS_Shape.hxx>
|
#include <TopoDS_Shape.hxx>
|
||||||
|
|
||||||
#include "Xao.hxx"
|
#include "Xao.hxx"
|
||||||
@ -40,92 +39,100 @@ namespace XAO
|
|||||||
|
|
||||||
virtual const XAO::Format getFormat() { return XAO::BREP; }
|
virtual const XAO::Format getFormat() { return XAO::BREP; }
|
||||||
|
|
||||||
|
virtual const std::string getShape();
|
||||||
|
virtual void setShape(const std::string& shape);
|
||||||
|
|
||||||
|
TopoDS_Shape getTopoDS_Shape();
|
||||||
|
void setTopoDS_Shape(const TopoDS_Shape& shape);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gives the two extrimities of an edge.
|
* Gives the two extrimities of an edge.
|
||||||
* @param edge
|
* @param edgeIndex the index of the edge.
|
||||||
* @param vertexA
|
* @param vertexA
|
||||||
* @param vertexB
|
* @param vertexB
|
||||||
*/
|
*/
|
||||||
void getEdgeVertices(const int& edge, int& vertexA, int& vertexB);
|
void getEdgeVertices(const int& edgeIndex, int& vertexA, int& vertexB);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of wires of a face (including holes).
|
* Gets the number of wires of a face (including holes).
|
||||||
* @param face the index of the face.
|
* @param faceIndex the index of the face.
|
||||||
* @return the number of wires.
|
* @return the number of wires.
|
||||||
*/
|
*/
|
||||||
const int countFaceWires(const int& face);
|
const int countFaceWires(const int& faceIndex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the indices of the wires of the face.
|
* Gets the indices of the wires of the face.
|
||||||
* @param face the index of the face.
|
* @param faceIndex the index of the face.
|
||||||
|
* @param wireIndex the index of the wire.
|
||||||
* @return the list of wires for the given face.
|
* @return the list of wires for the given face.
|
||||||
*/
|
*/
|
||||||
std::vector<int> getFaceWires(const int& face);
|
std::vector<int> getFaceEdges(const int& faceIndex, const int& wireIndex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of shells of a solid (including cavities).
|
* Gets the number of shells of a solid (including cavities).
|
||||||
* @param solid the index of the solid.
|
* @param solidIndex the index of the solid.
|
||||||
* @return the number of shells.
|
* @return the number of shells.
|
||||||
*/
|
*/
|
||||||
const int countSolidShells(const int& solid);
|
const int countSolidShells(const int& solidIndex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the indices of the shells of the solids.
|
* Gets the indices of the shells of the solids.
|
||||||
* @param solid the index of the solid.
|
* @param solidIndex the index of the solid.
|
||||||
|
* @param shellIndex the index of the shell (for the given solid).
|
||||||
* @return the list of shells for the given solid.
|
* @return the list of shells for the given solid.
|
||||||
*/
|
*/
|
||||||
std::vector<int> getSolidShells(const int& solid);
|
std::vector<int> getSolidFaces(const int& solidIndex, const int& shellIndex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the coordinates of a vertex.
|
* Gets the coordinates of a vertex.
|
||||||
* @param vertex the index of the vertex.
|
* @param vertexIndex the index of the vertex.
|
||||||
* @param xCoord the X coordinate.
|
* @param xCoord the X coordinate.
|
||||||
* @param yCoord the Y coordinate.
|
* @param yCoord the Y coordinate.
|
||||||
* @param zCoord the Z coordinate.
|
* @param zCoord the Z coordinate.
|
||||||
*/
|
*/
|
||||||
void getVertexXYZ(const int& vertex, double& xCoord, double& yCoord, double& zCoord);
|
void getVertexXYZ(const int& vertexIndex, double& xCoord, double& yCoord, double& zCoord);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the length of an edge.
|
* Gets the length of an edge.
|
||||||
* @param edge the index of the edge.
|
* @param edge the index of the edge.
|
||||||
* @return the length of the edge.
|
* @return the length of the edge.
|
||||||
*/
|
*/
|
||||||
const double getEdgeLength(const int& edge);
|
const double getEdgeLength(const int& index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the are of a face.
|
* Gets the are of a face.
|
||||||
* @param face the index of a face.
|
* @param face the index of a face.
|
||||||
* @return the area of the face.
|
* @return the area of the face.
|
||||||
*/
|
*/
|
||||||
const double getFaceArea(const int& face);
|
const double getFaceArea(const int& index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the volume of a solid.
|
* Gets the volume of a solid.
|
||||||
* @param solid the index of the solid.
|
* @param solid the index of the solid.
|
||||||
* @return the volume of the solid.
|
* @return the volume of the solid.
|
||||||
*/
|
*/
|
||||||
const double getSolidVolume(const int& solid);
|
const double getSolidVolume(const int& index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ID of a vertex.
|
* Gets the ID of a vertex.
|
||||||
* @param vertex the index of the vertex.
|
* @param vertex the index of the vertex.
|
||||||
* @return the ID of the vertex.
|
* @return the ID of the vertex.
|
||||||
*/
|
*/
|
||||||
const int getVertexID(const int& vertex);
|
const int getVertexID(const int& index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ID of an edge.
|
* Gets the ID of an edge.
|
||||||
* @param edge the index of the edge.
|
* @param edge the index of the edge.
|
||||||
* @return the ID of the edge.
|
* @return the ID of the edge.
|
||||||
*/
|
*/
|
||||||
const int getEdgeID(const int& edge);
|
const int getEdgeID(const int& index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ID of a face.
|
* Gets the ID of a face.
|
||||||
* @param face the index of the face.
|
* @param face the index of the face.
|
||||||
* @return the ID of the face.
|
* @return the ID of the face.
|
||||||
*/
|
*/
|
||||||
const int getFaceID(const int& face);
|
const int getFaceID(const int& index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ID of a solid.
|
* Gets the ID of a solid.
|
||||||
@ -134,10 +141,12 @@ namespace XAO
|
|||||||
*/
|
*/
|
||||||
const int getSolidID(const int& solid);
|
const int getSolidID(const int& solid);
|
||||||
|
|
||||||
void setVertexID(const int& vertex, const int& id);
|
void setVertexID(const int& index, const int& id);
|
||||||
void setEdgeID(const int& edge, const int& id);
|
void setEdgeID(const int& index, const int& id);
|
||||||
void setFaceID(const int& face, const int& id);
|
void setFaceID(const int& index, const int& id);
|
||||||
void setSolidID(const int& solid, const int& id);
|
void setSolidID(const int& index, const int& id);
|
||||||
|
|
||||||
|
const int findElement(const XAO::Dimension& dim, const int& id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds a vertex with its ID.
|
* Finds a vertex with its ID.
|
||||||
@ -224,10 +233,14 @@ namespace XAO
|
|||||||
void changeSolidName(const int& id, const std::string& name);
|
void changeSolidName(const int& id, const std::string& name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TopoDS_Shape getGeometricalElement(TopAbs_ShapeEnum shapeType, const int& shapeIndex);
|
void initIds();
|
||||||
const int countGeometricalElements(TopoDS_Shape shape, TopAbs_ShapeEnum shapeType);
|
void initListIds(const TopAbs_ShapeEnum& shapeType, GeometricElementList& eltList);
|
||||||
std::vector<int> getGeometricalElements(TopoDS_Shape shape, TopAbs_ShapeEnum shapeType);
|
TopoDS_Shape getSubShape(const TopoDS_Shape& mainShape, const TopAbs_ShapeEnum& shapeType, const int& shapeIndex);
|
||||||
|
const int countGeometricalElements(const TopoDS_Shape& shape, const TopAbs_ShapeEnum& shapeType);
|
||||||
|
std::vector<int> getGeometricalElements(const TopoDS_Shape& shape, const TopAbs_ShapeEnum& shapeType, const XAO::Dimension& dim);
|
||||||
|
|
||||||
|
private:
|
||||||
|
TopoDS_Shape m_shape;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "DoubleField.hxx"
|
#include "DoubleField.hxx"
|
||||||
#include "DoubleStep.hxx"
|
#include "DoubleStep.hxx"
|
||||||
|
#include "XaoUtils.hxx"
|
||||||
|
|
||||||
#include <Utils_SALOME_Exception.hxx>
|
#include <Utils_SALOME_Exception.hxx>
|
||||||
|
|
||||||
@ -42,6 +43,9 @@ DoubleStep* DoubleField::addStep(const int& step)
|
|||||||
|
|
||||||
DoubleStep* DoubleField::addStep(const int& step, const int& stamp)
|
DoubleStep* DoubleField::addStep(const int& step, const int& stamp)
|
||||||
{
|
{
|
||||||
|
if (hasStep(step))
|
||||||
|
throw SALOME_Exception(MsgBuilder() << "Step with number " << step << "already exists.");
|
||||||
|
|
||||||
DoubleStep* bstep = new DoubleStep(step, stamp, m_nbElements, m_nbComponents);
|
DoubleStep* bstep = new DoubleStep(step, stamp, m_nbElements, m_nbComponents);
|
||||||
m_steps.push_back(bstep);
|
m_steps.push_back(bstep);
|
||||||
return bstep;
|
return bstep;
|
||||||
|
@ -98,6 +98,19 @@ bool Field::removeStep(Step* step)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Field::hasStep(const int& step)
|
||||||
|
{
|
||||||
|
std::vector<Step*>::iterator it = m_steps.begin();
|
||||||
|
for (; it != m_steps.end(); ++it)
|
||||||
|
{
|
||||||
|
Step* current = *it;
|
||||||
|
if (current->getStep() == step)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void Field::checkComponent(const int& component)
|
void Field::checkComponent(const int& component)
|
||||||
{
|
{
|
||||||
if (component < m_nbComponents && component >= 0)
|
if (component < m_nbComponents && component >= 0)
|
||||||
|
@ -162,18 +162,25 @@ namespace XAO
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new step of the same type than the field.
|
* Adds a new step of the same type than the field.
|
||||||
* @param step the index of the step.
|
* @param number the numer of the step.
|
||||||
* @return the new create step.
|
* @return the new create step.
|
||||||
*/
|
*/
|
||||||
virtual Step* addNewStep(const int& step) = 0;
|
virtual Step* addNewStep(const int& number) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a step.
|
* Remove a step.
|
||||||
* @param step the step to remove.
|
* @param step the step to remove.
|
||||||
* @return true if the step has been removed.
|
* @return true if the step has been removed, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool removeStep(Step* step);
|
bool removeStep(Step* step);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies if the field has a step with the given step number.
|
||||||
|
* @param step the step number.
|
||||||
|
* @return true if the field has a step for the given number.
|
||||||
|
*/
|
||||||
|
bool hasStep(const int& step);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the first step.
|
* Returns the first step.
|
||||||
* @return an iterator on the first step.
|
* @return an iterator on the first step.
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <Utils_SALOME_Exception.hxx>
|
#include <Utils_SALOME_Exception.hxx>
|
||||||
|
|
||||||
#include "GeometricElement.hxx"
|
#include "GeometricElement.hxx"
|
||||||
|
#include "XaoUtils.hxx"
|
||||||
|
|
||||||
using namespace XAO;
|
using namespace XAO;
|
||||||
|
|
||||||
@ -86,9 +87,7 @@ const std::string GeometricElementList::getName(const int& index)
|
|||||||
void GeometricElementList::setName(const int& index, const std::string& name)
|
void GeometricElementList::setName(const int& index, const std::string& name)
|
||||||
{
|
{
|
||||||
if (m_count == 0 || index > m_count)
|
if (m_count == 0 || index > m_count)
|
||||||
{
|
|
||||||
throw SALOME_Exception("Problem with number of elements");
|
throw SALOME_Exception("Problem with number of elements");
|
||||||
}
|
|
||||||
|
|
||||||
m_elements[index].setName(name);
|
m_elements[index].setName(name);
|
||||||
}
|
}
|
||||||
@ -96,9 +95,7 @@ void GeometricElementList::setName(const int& index, const std::string& name)
|
|||||||
const bool GeometricElementList::hasName(const int& index)
|
const bool GeometricElementList::hasName(const int& index)
|
||||||
{
|
{
|
||||||
if (m_count == 0 || index > m_count)
|
if (m_count == 0 || index > m_count)
|
||||||
{
|
|
||||||
throw SALOME_Exception("Problem with number of elements");
|
throw SALOME_Exception("Problem with number of elements");
|
||||||
}
|
|
||||||
|
|
||||||
return m_elements[index].hasName();
|
return m_elements[index].hasName();
|
||||||
}
|
}
|
||||||
@ -124,9 +121,8 @@ const int GeometricElementList::getIndexByReference(const std::string& ref)
|
|||||||
for (int index = 0; index < m_count; ++index)
|
for (int index = 0; index < m_count; ++index)
|
||||||
{
|
{
|
||||||
if (ref == m_elements[index].getReference())
|
if (ref == m_elements[index].getReference())
|
||||||
{
|
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return -1;
|
throw SALOME_Exception(MsgBuilder() << "Reference not found: " << ref);
|
||||||
}
|
}
|
||||||
|
@ -18,29 +18,6 @@
|
|||||||
//
|
//
|
||||||
// Author : Nathalie Gore (OpenCascade)
|
// Author : Nathalie Gore (OpenCascade)
|
||||||
|
|
||||||
#include <Standard_TypeMismatch.hxx>
|
|
||||||
|
|
||||||
#include <BRepTools.hxx>
|
|
||||||
#include <BRep_Builder.hxx>
|
|
||||||
#include <TopAbs.hxx>
|
|
||||||
|
|
||||||
//#include <string>
|
|
||||||
#include <fstream>
|
|
||||||
#include <sstream>
|
|
||||||
#include <iostream>
|
|
||||||
#include <iosfwd>
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
#include <TopTools_MapOfShape.hxx>
|
|
||||||
#include <TopTools_ListOfShape.hxx>
|
|
||||||
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
|
||||||
#include <TopTools_IndexedMapOfShape.hxx>
|
|
||||||
#include <TopExp.hxx>
|
|
||||||
#include <TopExp_Explorer.hxx>
|
|
||||||
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
|
||||||
#include <TColStd_HArray1OfInteger.hxx>
|
|
||||||
#include <TColStd_HSequenceOfInteger.hxx>
|
|
||||||
|
|
||||||
#include <Utils_SALOME_Exception.hxx>
|
#include <Utils_SALOME_Exception.hxx>
|
||||||
|
|
||||||
#include "XaoUtils.hxx"
|
#include "XaoUtils.hxx"
|
||||||
@ -71,100 +48,6 @@ Geometry::~Geometry()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Geometry::setShape(const TopoDS_Shape& shape)
|
|
||||||
{
|
|
||||||
m_shape = shape;
|
|
||||||
|
|
||||||
// intialization of Ids
|
|
||||||
initListIds(TopAbs_VERTEX);
|
|
||||||
initListIds(TopAbs_EDGE);
|
|
||||||
initListIds(TopAbs_FACE);
|
|
||||||
initListIds(TopAbs_SOLID);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Geometry::setBREP(const char* brep)
|
|
||||||
{
|
|
||||||
std::istringstream streamBrep(brep);
|
|
||||||
BRep_Builder builder;
|
|
||||||
BRepTools::Read(m_shape, streamBrep, builder);
|
|
||||||
|
|
||||||
// intialization of Ids
|
|
||||||
initListIds(TopAbs_VERTEX);
|
|
||||||
initListIds(TopAbs_EDGE);
|
|
||||||
initListIds(TopAbs_FACE);
|
|
||||||
initListIds(TopAbs_SOLID);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* Geometry::getBREP()
|
|
||||||
{
|
|
||||||
std::ostringstream streamShape;
|
|
||||||
BRepTools::Write(m_shape, streamShape);
|
|
||||||
std::string data = streamShape.str();
|
|
||||||
char* res = new char[data.size()];
|
|
||||||
strcpy(res, data.c_str());
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Geometry::initListIds(const Standard_Integer shapeType)
|
|
||||||
{
|
|
||||||
TopTools_MapOfShape mapShape;
|
|
||||||
TopTools_ListOfShape listShape;
|
|
||||||
|
|
||||||
TopExp_Explorer exp(m_shape, TopAbs_ShapeEnum(shapeType));
|
|
||||||
for (; exp.More(); exp.Next())
|
|
||||||
{
|
|
||||||
if (mapShape.Add(exp.Current()))
|
|
||||||
listShape.Append(exp.Current());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (listShape.IsEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
TopTools_IndexedMapOfShape indices;
|
|
||||||
TopExp::MapShapes(m_shape, indices);
|
|
||||||
|
|
||||||
std::list<int> indexList;
|
|
||||||
TopTools_ListIteratorOfListOfShape itSub(listShape);
|
|
||||||
for (int index = 1; itSub.More(); itSub.Next(), ++index)
|
|
||||||
{
|
|
||||||
TopoDS_Shape value = itSub.Value();
|
|
||||||
indexList.push_back(indices.FindIndex(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::list<int>::iterator it = indexList.begin();
|
|
||||||
switch (shapeType)
|
|
||||||
{
|
|
||||||
case TopAbs_VERTEX:
|
|
||||||
{
|
|
||||||
m_vertices.setSize(indexList.size());
|
|
||||||
for (int i = 0; it != indexList.end(); it++, i++)
|
|
||||||
m_vertices.setReference(i, XaoUtils::intToString((*it)));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TopAbs_EDGE:
|
|
||||||
{
|
|
||||||
m_edges.setSize(indexList.size());
|
|
||||||
for (int i = 0; it != indexList.end(); it++, i++)
|
|
||||||
m_edges.setReference(i, XaoUtils::intToString((*it)));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TopAbs_FACE:
|
|
||||||
{
|
|
||||||
m_faces.setSize(indexList.size());
|
|
||||||
for (int i = 0; it != indexList.end(); it++, i++)
|
|
||||||
m_faces.setReference(i, XaoUtils::intToString((*it)));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TopAbs_SOLID:
|
|
||||||
{
|
|
||||||
m_solids.setSize(indexList.size());
|
|
||||||
for (int i = 0; it != indexList.end(); it++, i++)
|
|
||||||
m_solids.setReference(i, XaoUtils::intToString((*it)));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const int Geometry::countElements(const XAO::Dimension& dim)
|
const int Geometry::countElements(const XAO::Dimension& dim)
|
||||||
{
|
{
|
||||||
if (dim == XAO::VERTEX)
|
if (dim == XAO::VERTEX)
|
||||||
|
@ -23,9 +23,6 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <SALOMEconfig.h>
|
|
||||||
#include <TopoDS_Shape.hxx>
|
|
||||||
|
|
||||||
#include "Xao.hxx"
|
#include "Xao.hxx"
|
||||||
#include "GeometricElement.hxx"
|
#include "GeometricElement.hxx"
|
||||||
|
|
||||||
@ -78,22 +75,8 @@ namespace XAO
|
|||||||
*/
|
*/
|
||||||
virtual const XAO::Format getFormat() = 0;
|
virtual const XAO::Format getFormat() = 0;
|
||||||
|
|
||||||
/**
|
virtual const std::string getShape() = 0;
|
||||||
* Gets the shape of the geometry.
|
virtual void setShape(const std::string& shape) = 0;
|
||||||
* @return the shape of the geometry.
|
|
||||||
*/
|
|
||||||
TopoDS_Shape getShape()
|
|
||||||
{
|
|
||||||
return m_shape;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Sets the shape of the geometry.
|
|
||||||
* @param shape the shape to set.
|
|
||||||
*/
|
|
||||||
void setShape(const TopoDS_Shape& shape);
|
|
||||||
|
|
||||||
const char* getBREP();
|
|
||||||
void setBREP(const char* brep);
|
|
||||||
|
|
||||||
const int countElements(const XAO::Dimension& dim);
|
const int countElements(const XAO::Dimension& dim);
|
||||||
const int countVertices() { return m_vertices.getSize(); }
|
const int countVertices() { return m_vertices.getSize(); }
|
||||||
@ -146,13 +129,8 @@ namespace XAO
|
|||||||
GeometricElementList::iterator begin(const XAO::Dimension& dim);
|
GeometricElementList::iterator begin(const XAO::Dimension& dim);
|
||||||
GeometricElementList::iterator end(const XAO::Dimension& dim);
|
GeometricElementList::iterator end(const XAO::Dimension& dim);
|
||||||
|
|
||||||
private:
|
|
||||||
void initListIds(const Standard_Integer shapeType);
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
TopoDS_Shape m_shape;
|
|
||||||
GeometricElementList m_vertices;
|
GeometricElementList m_vertices;
|
||||||
GeometricElementList m_edges;
|
GeometricElementList m_edges;
|
||||||
GeometricElementList m_faces;
|
GeometricElementList m_faces;
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "IntegerField.hxx"
|
#include "IntegerField.hxx"
|
||||||
#include "IntegerStep.hxx"
|
#include "IntegerStep.hxx"
|
||||||
|
#include "XaoUtils.hxx"
|
||||||
|
|
||||||
#include <Utils_SALOME_Exception.hxx>
|
#include <Utils_SALOME_Exception.hxx>
|
||||||
|
|
||||||
@ -42,6 +43,9 @@ IntegerStep* IntegerField::addStep(const int& step)
|
|||||||
|
|
||||||
IntegerStep* IntegerField::addStep(const int& step, const int& stamp)
|
IntegerStep* IntegerField::addStep(const int& step, const int& stamp)
|
||||||
{
|
{
|
||||||
|
if (hasStep(step))
|
||||||
|
throw SALOME_Exception(MsgBuilder() << "Step with number " << step << "already exists.");
|
||||||
|
|
||||||
IntegerStep* bstep = new IntegerStep(step, stamp, m_nbElements, m_nbComponents);
|
IntegerStep* bstep = new IntegerStep(step, stamp, m_nbElements, m_nbComponents);
|
||||||
m_steps.push_back(bstep);
|
m_steps.push_back(bstep);
|
||||||
return bstep;
|
return bstep;
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "StringField.hxx"
|
#include "StringField.hxx"
|
||||||
#include "StringStep.hxx"
|
#include "StringStep.hxx"
|
||||||
|
#include "XaoUtils.hxx"
|
||||||
|
|
||||||
#include <Utils_SALOME_Exception.hxx>
|
#include <Utils_SALOME_Exception.hxx>
|
||||||
|
|
||||||
@ -42,6 +43,9 @@ StringStep* StringField::addStep(const int& step)
|
|||||||
|
|
||||||
StringStep* StringField::addStep(const int& step, const int& stamp)
|
StringStep* StringField::addStep(const int& step, const int& stamp)
|
||||||
{
|
{
|
||||||
|
if (hasStep(step))
|
||||||
|
throw SALOME_Exception(MsgBuilder() << "Step with number " << step << "already exists.");
|
||||||
|
|
||||||
StringStep* bstep = new StringStep(step, stamp, m_nbElements, m_nbComponents);
|
StringStep* bstep = new StringStep(step, stamp, m_nbElements, m_nbComponents);
|
||||||
m_steps.push_back(bstep);
|
m_steps.push_back(bstep);
|
||||||
return bstep;
|
return bstep;
|
||||||
|
@ -163,7 +163,7 @@ void XaoExporter::exportGeometricElements(Geometry* xaoGeometry,
|
|||||||
xmlNodePtr topology, XAO::Dimension dim, const xmlChar* colTag, const xmlChar* eltTag)
|
xmlNodePtr topology, XAO::Dimension dim, const xmlChar* colTag, const xmlChar* eltTag)
|
||||||
{
|
{
|
||||||
xmlNodePtr vertices = xmlNewChild(topology, 0, colTag, 0);
|
xmlNodePtr vertices = xmlNewChild(topology, 0, colTag, 0);
|
||||||
xmlNewProp(vertices, C_ATTR_COUNT, BAD_CAST XaoUtils::intToString(xaoGeometry->countVertices()).c_str());
|
xmlNewProp(vertices, C_ATTR_COUNT, BAD_CAST XaoUtils::intToString(xaoGeometry->countElements(dim)).c_str());
|
||||||
GeometricElementList::iterator it = xaoGeometry->begin(dim);
|
GeometricElementList::iterator it = xaoGeometry->begin(dim);
|
||||||
for (; it != xaoGeometry->end(dim); it++)
|
for (; it != xaoGeometry->end(dim); it++)
|
||||||
{
|
{
|
||||||
@ -184,8 +184,8 @@ void XaoExporter::exportGeometry(Geometry* xaoGeometry, xmlDocPtr doc, xmlNodePt
|
|||||||
|
|
||||||
xmlNodePtr shape = xmlNewChild(geometry, 0, C_TAG_SHAPE, 0);
|
xmlNodePtr shape = xmlNewChild(geometry, 0, C_TAG_SHAPE, 0);
|
||||||
xmlNewProp(shape, C_ATTR_SHAPE_FORMAT, BAD_CAST XaoUtils::shapeFormatToString(xaoGeometry->getFormat()).c_str());
|
xmlNewProp(shape, C_ATTR_SHAPE_FORMAT, BAD_CAST XaoUtils::shapeFormatToString(xaoGeometry->getFormat()).c_str());
|
||||||
const char* brep = xaoGeometry->getBREP();
|
std::string txtShape = xaoGeometry->getShape();
|
||||||
xmlNodePtr cdata = xmlNewCDataBlock(doc, BAD_CAST brep, strlen(brep));
|
xmlNodePtr cdata = xmlNewCDataBlock(doc, BAD_CAST txtShape.c_str(), txtShape.size());
|
||||||
xmlAddChild(shape, cdata);
|
xmlAddChild(shape, cdata);
|
||||||
|
|
||||||
xmlNodePtr topology = xmlNewChild(geometry, 0, C_TAG_TOPOLOGY, 0);
|
xmlNodePtr topology = xmlNewChild(geometry, 0, C_TAG_TOPOLOGY, 0);
|
||||||
@ -368,7 +368,7 @@ void XaoExporter::parseShapeNode(xmlDocPtr doc, xmlNodePtr shapeNode, Geometry*
|
|||||||
xmlChar* data = xmlNodeGetContent(shapeNode->children);
|
xmlChar* data = xmlNodeGetContent(shapeNode->children);
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
throw SALOME_Exception("Missing BREP");
|
throw SALOME_Exception("Missing BREP");
|
||||||
geometry->setBREP((char*)data);
|
geometry->setShape((char*)data);
|
||||||
xmlFree(data);
|
xmlFree(data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -23,7 +23,7 @@ void BrepGeometryTest::cleanUp()
|
|||||||
void readBrep(Geometry* geom, const std::string& fileName)
|
void readBrep(Geometry* geom, const std::string& fileName)
|
||||||
{
|
{
|
||||||
char* txt = TestUtils::readTextFile(TestUtils::getTestFilePath(fileName));
|
char* txt = TestUtils::readTextFile(TestUtils::getTestFilePath(fileName));
|
||||||
geom->setBREP(txt);
|
geom->setShape(txt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrepGeometryTest::testGetIDs()
|
void BrepGeometryTest::testGetIDs()
|
||||||
@ -97,43 +97,67 @@ void BrepGeometryTest::testGetEdgeVertices()
|
|||||||
BrepGeometry* geom = new BrepGeometry("box");
|
BrepGeometry* geom = new BrepGeometry("box");
|
||||||
readBrep(geom, "Box_2.brep");
|
readBrep(geom, "Box_2.brep");
|
||||||
|
|
||||||
|
// edge of index 23, id = #63
|
||||||
|
// vertex are 47 (#12), 59 (#15)
|
||||||
int v1, v2;
|
int v1, v2;
|
||||||
geom->getEdgeVertices(63, v1, v2);
|
geom->getEdgeVertices(23, v1, v2);
|
||||||
std::cout << "# " << v1 << ", " << v2 << std::endl;
|
CPPUNIT_ASSERT_EQUAL(12, v1);
|
||||||
CPPUNIT_ASSERT_EQUAL(47, v1);
|
CPPUNIT_ASSERT_EQUAL(15, v2);
|
||||||
CPPUNIT_ASSERT_EQUAL(59, v2);
|
|
||||||
|
|
||||||
delete geom;
|
delete geom;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrepGeometryTest::testGetFaceWires()
|
void printVector(std::vector<int>& v)
|
||||||
|
{
|
||||||
|
std::cout << "# ";
|
||||||
|
for (int i = 0; i < v.size(); i++)
|
||||||
|
std::cout << v[i] << ", ";
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrepGeometryTest::testGetFaceEdges()
|
||||||
{
|
{
|
||||||
BrepGeometry* geom = new BrepGeometry("box");
|
BrepGeometry* geom = new BrepGeometry("box");
|
||||||
readBrep(geom, "Box_2.brep");
|
readBrep(geom, "Box_2.brep");
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(2, geom->countFaceWires(13));
|
CPPUNIT_ASSERT_EQUAL(2, geom->countFaceWires(1)); // face 13
|
||||||
CPPUNIT_ASSERT_EQUAL(1, geom->countFaceWires(29));
|
CPPUNIT_ASSERT_EQUAL(1, geom->countFaceWires(2)); // face 29
|
||||||
|
|
||||||
std::vector<int> wires = geom->getFaceWires(13);
|
// wire 0 of face 1 (#13) => edge 4 (#15), 5 (#17), 0 (#5), 6 (#19)
|
||||||
CPPUNIT_ASSERT_EQUAL(2, (int)wires.size());
|
std::vector<int> edges = geom->getFaceEdges(1, 0);
|
||||||
CPPUNIT_ASSERT_EQUAL(2, wires[0]);
|
CPPUNIT_ASSERT_EQUAL(4, (int)edges.size());
|
||||||
CPPUNIT_ASSERT_EQUAL(11, wires[1]);
|
int ids1[4] = { 4,5,0,6 };
|
||||||
|
for (int i = 0; i < 4; ++i)
|
||||||
|
CPPUNIT_ASSERT_EQUAL(ids1[i], edges[i]);
|
||||||
|
|
||||||
|
// wire 1 of face 13 => edge 7 (#21) ,8 (#24), 9 (#26), 10 (#28)
|
||||||
|
edges = geom->getFaceEdges(1, 1);
|
||||||
|
CPPUNIT_ASSERT_EQUAL(4, (int)edges.size());
|
||||||
|
int ids2[4] = { 7,8,9,10 };
|
||||||
|
for (int i = 0; i < 4; ++i)
|
||||||
|
CPPUNIT_ASSERT_EQUAL(ids2[i], edges[i]);
|
||||||
|
|
||||||
delete geom;
|
delete geom;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrepGeometryTest::testSolidShells()
|
void BrepGeometryTest::testSolidFaces()
|
||||||
{
|
{
|
||||||
BrepGeometry* geom = new BrepGeometry("box");
|
BrepGeometry* geom = new BrepGeometry("box");
|
||||||
readBrep(geom, "Cut_2.brep");
|
readBrep(geom, "Cut_2.brep");
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(5, geom->countSolidShells(1));
|
CPPUNIT_ASSERT_EQUAL(5, geom->countSolidShells(0));
|
||||||
|
|
||||||
std::vector<int> shells = geom->getSolidShells(1);
|
std::vector<int> faces = geom->getSolidFaces(0, 0);
|
||||||
CPPUNIT_ASSERT_EQUAL(5, (int)shells.size());
|
CPPUNIT_ASSERT_EQUAL(6, (int)faces.size());
|
||||||
int ids[5] = { 2, 35, 68, 76, 84 };
|
int ids[6] = { 0, 1, 2, 3, 4, 5 };
|
||||||
for (int i = 0; i < 5; ++i)
|
for (int i = 0; i < 6; ++i)
|
||||||
CPPUNIT_ASSERT_EQUAL(ids[i], shells[i]);
|
CPPUNIT_ASSERT_EQUAL(ids[i], faces[i]);
|
||||||
|
|
||||||
|
faces = geom->getSolidFaces(0, 1);
|
||||||
|
CPPUNIT_ASSERT_EQUAL(6, (int)faces.size());
|
||||||
|
int ids2[6] = { 6, 7, 8, 9, 10, 11 };
|
||||||
|
for (int i = 0; i < 6; ++i)
|
||||||
|
CPPUNIT_ASSERT_EQUAL(ids2[i], faces[i]);
|
||||||
|
|
||||||
delete geom;
|
delete geom;
|
||||||
}
|
}
|
||||||
@ -144,7 +168,7 @@ void BrepGeometryTest::testGetVertex()
|
|||||||
readBrep(geom, "Box_2.brep");
|
readBrep(geom, "Box_2.brep");
|
||||||
|
|
||||||
double x, y, z;
|
double x, y, z;
|
||||||
geom->getVertexXYZ(59, x, y, z);
|
geom->getVertexXYZ(15, x, y, z);
|
||||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(60., x, 1e-6);
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(60., x, 1e-6);
|
||||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(80., y, 1e-6);
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(80., y, 1e-6);
|
||||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(60., z, 1e-6);
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(60., z, 1e-6);
|
||||||
@ -157,8 +181,9 @@ void BrepGeometryTest::testGetEdgeLength()
|
|||||||
BrepGeometry* geom = new BrepGeometry("box");
|
BrepGeometry* geom = new BrepGeometry("box");
|
||||||
readBrep(geom, "Box_2.brep");
|
readBrep(geom, "Box_2.brep");
|
||||||
|
|
||||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(200., geom->getEdgeLength(5), 0);
|
// edges 0 (#5), 7 (#21)
|
||||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(80., geom->getEdgeLength(21), 0);
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(200., geom->getEdgeLength(0), 0);
|
||||||
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(80., geom->getEdgeLength(7), 0);
|
||||||
|
|
||||||
delete geom;
|
delete geom;
|
||||||
}
|
}
|
||||||
@ -168,8 +193,9 @@ void BrepGeometryTest::testGetFaceArea()
|
|||||||
BrepGeometry* geom = new BrepGeometry("box");
|
BrepGeometry* geom = new BrepGeometry("box");
|
||||||
readBrep(geom, "Box_2.brep");
|
readBrep(geom, "Box_2.brep");
|
||||||
|
|
||||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(40000., geom->getFaceArea(3), 1e-9);
|
// faces 0 (#3), 1 (#13)
|
||||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(33600., geom->getFaceArea(13), 1e-9);
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(40000., geom->getFaceArea(0), 1e-9);
|
||||||
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(33600., geom->getFaceArea(1), 1e-9);
|
||||||
|
|
||||||
delete geom;
|
delete geom;
|
||||||
}
|
}
|
||||||
@ -179,7 +205,7 @@ void BrepGeometryTest::testGetSolidVolume()
|
|||||||
BrepGeometry* geom = new BrepGeometry("box");
|
BrepGeometry* geom = new BrepGeometry("box");
|
||||||
readBrep(geom, "Box_2.brep");
|
readBrep(geom, "Box_2.brep");
|
||||||
|
|
||||||
CPPUNIT_ASSERT_DOUBLES_EQUAL(7488000., geom->getSolidVolume(1), 1e-9);
|
CPPUNIT_ASSERT_DOUBLES_EQUAL(7488000., geom->getSolidVolume(0), 1e-9);
|
||||||
|
|
||||||
delete geom;
|
delete geom;
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,8 @@ namespace XAO
|
|||||||
CPPUNIT_TEST(testGetIDs);
|
CPPUNIT_TEST(testGetIDs);
|
||||||
CPPUNIT_TEST(testGetReferences);
|
CPPUNIT_TEST(testGetReferences);
|
||||||
CPPUNIT_TEST(testGetEdgeVertices);
|
CPPUNIT_TEST(testGetEdgeVertices);
|
||||||
CPPUNIT_TEST(testGetFaceWires);
|
CPPUNIT_TEST(testGetFaceEdges);
|
||||||
CPPUNIT_TEST(testSolidShells);
|
CPPUNIT_TEST(testSolidFaces);
|
||||||
CPPUNIT_TEST(testGetVertex);
|
CPPUNIT_TEST(testGetVertex);
|
||||||
CPPUNIT_TEST(testGetEdgeLength);
|
CPPUNIT_TEST(testGetEdgeLength);
|
||||||
CPPUNIT_TEST(testGetFaceArea);
|
CPPUNIT_TEST(testGetFaceArea);
|
||||||
@ -29,8 +29,8 @@ namespace XAO
|
|||||||
void testGetIDs();
|
void testGetIDs();
|
||||||
void testGetReferences();
|
void testGetReferences();
|
||||||
void testGetEdgeVertices();
|
void testGetEdgeVertices();
|
||||||
void testGetFaceWires();
|
void testGetFaceEdges();
|
||||||
void testSolidShells();
|
void testSolidFaces();
|
||||||
|
|
||||||
void testGetVertex();
|
void testGetVertex();
|
||||||
void testGetEdgeLength();
|
void testGetEdgeLength();
|
||||||
|
@ -57,6 +57,7 @@ Field* FieldTest::testField(XAO::Type type)
|
|||||||
step = f->addNewStep(1);
|
step = f->addNewStep(1);
|
||||||
step = f->addNewStep(2);
|
step = f->addNewStep(2);
|
||||||
CPPUNIT_ASSERT_EQUAL(3, f->countSteps());
|
CPPUNIT_ASSERT_EQUAL(3, f->countSteps());
|
||||||
|
CPPUNIT_ASSERT_THROW(f->addNewStep(2), SALOME_Exception); // step already exists
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(true, f->removeStep(step));
|
CPPUNIT_ASSERT_EQUAL(true, f->removeStep(step));
|
||||||
CPPUNIT_ASSERT_EQUAL(2, f->countSteps());
|
CPPUNIT_ASSERT_EQUAL(2, f->countSteps());
|
||||||
@ -78,7 +79,9 @@ void FieldTest::testBooleanField()
|
|||||||
step = f->addStep(10);
|
step = f->addStep(10);
|
||||||
CPPUNIT_ASSERT_EQUAL(XAO::BOOLEAN, step->getType());
|
CPPUNIT_ASSERT_EQUAL(XAO::BOOLEAN, step->getType());
|
||||||
CPPUNIT_ASSERT_EQUAL(3, f->countSteps());
|
CPPUNIT_ASSERT_EQUAL(3, f->countSteps());
|
||||||
|
CPPUNIT_ASSERT_THROW(f->addStep(10), SALOME_Exception); // step already exists
|
||||||
}
|
}
|
||||||
|
|
||||||
void FieldTest::testIntegerField()
|
void FieldTest::testIntegerField()
|
||||||
{
|
{
|
||||||
IntegerField* f = (IntegerField*)testField(XAO::INTEGER);
|
IntegerField* f = (IntegerField*)testField(XAO::INTEGER);
|
||||||
@ -91,6 +94,7 @@ void FieldTest::testIntegerField()
|
|||||||
step = f->addStep(10);
|
step = f->addStep(10);
|
||||||
CPPUNIT_ASSERT_EQUAL(XAO::INTEGER, step->getType());
|
CPPUNIT_ASSERT_EQUAL(XAO::INTEGER, step->getType());
|
||||||
CPPUNIT_ASSERT_EQUAL(3, f->countSteps());
|
CPPUNIT_ASSERT_EQUAL(3, f->countSteps());
|
||||||
|
CPPUNIT_ASSERT_THROW(f->addStep(10), SALOME_Exception); // step already exists
|
||||||
}
|
}
|
||||||
void FieldTest::testDoubleField()
|
void FieldTest::testDoubleField()
|
||||||
{
|
{
|
||||||
@ -104,6 +108,7 @@ void FieldTest::testDoubleField()
|
|||||||
step = f->addStep(10);
|
step = f->addStep(10);
|
||||||
CPPUNIT_ASSERT_EQUAL(XAO::DOUBLE, step->getType());
|
CPPUNIT_ASSERT_EQUAL(XAO::DOUBLE, step->getType());
|
||||||
CPPUNIT_ASSERT_EQUAL(3, f->countSteps());
|
CPPUNIT_ASSERT_EQUAL(3, f->countSteps());
|
||||||
|
CPPUNIT_ASSERT_THROW(f->addStep(10), SALOME_Exception); // step already exists
|
||||||
}
|
}
|
||||||
void FieldTest::testStringField()
|
void FieldTest::testStringField()
|
||||||
{
|
{
|
||||||
@ -117,6 +122,7 @@ void FieldTest::testStringField()
|
|||||||
step = f->addStep(10);
|
step = f->addStep(10);
|
||||||
CPPUNIT_ASSERT_EQUAL(XAO::STRING, step->getType());
|
CPPUNIT_ASSERT_EQUAL(XAO::STRING, step->getType());
|
||||||
CPPUNIT_ASSERT_EQUAL(3, f->countSteps());
|
CPPUNIT_ASSERT_EQUAL(3, f->countSteps());
|
||||||
|
CPPUNIT_ASSERT_THROW(f->addStep(10), SALOME_Exception); // step already exists
|
||||||
}
|
}
|
||||||
|
|
||||||
void FieldTest::testStep(XAO::Type type)
|
void FieldTest::testStep(XAO::Type type)
|
||||||
|
Loading…
Reference in New Issue
Block a user