PR: debug in progress, still about 30 bugs

This commit is contained in:
prascle 2010-11-15 15:09:53 +00:00
parent 7eead70477
commit cde2f08074
36 changed files with 341 additions and 331 deletions

View File

@ -239,7 +239,7 @@ CLASS_DIAGRAMS = YES
HIDE_UNDOC_RELATIONS = NO
HAVE_DOT = YES
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
COLLABORATION_GRAPH = NO
GROUP_GRAPHS = YES
UML_LOOK = NO
TEMPLATE_RELATIONS = YES

View File

@ -36,22 +36,9 @@ using namespace std;
//purpose :
//=======================================================================
SMDS_EdgePosition::SMDS_EdgePosition(const int aEdgeId,
const double aUParam):SMDS_Position(aEdgeId), myUParameter(aUParam)
SMDS_EdgePosition::SMDS_EdgePosition(const double aUParam): myUParameter(aUParam)
{
//MESSAGE("********************************* SMDS_EdgePosition "<< aEdgeId << " " << myUParameter);
}
//=======================================================================
//function : Coords
//purpose :
//=======================================================================
const double *SMDS_EdgePosition::Coords() const
{
static double origin[]={0,0,0};
MESSAGE("SMDS_EdgePosition::Coords not implemented");
return origin;
//MESSAGE("********************************* SMDS_EdgePosition " << myUParameter);
}
/**

View File

@ -35,8 +35,7 @@ class SMDS_EXPORT SMDS_EdgePosition:public SMDS_Position
{
public:
SMDS_EdgePosition(const int aEdgeId=0, const double aUParam=0);
const virtual double * Coords() const;
SMDS_EdgePosition(const double aUParam=0);
SMDS_TypeOfPosition GetTypeOfPosition() const;
void SetUParameter(double aUparam);
double GetUParameter() const;

View File

@ -36,26 +36,13 @@ using namespace std;
//purpose :
//=======================================================================
SMDS_FacePosition::SMDS_FacePosition(const int aEdgeId,
const double aUParam,
SMDS_FacePosition::SMDS_FacePosition(const double aUParam,
const double aVParam)
:SMDS_Position(aEdgeId),
myUParameter(aUParam),myVParameter(aVParam)
: myUParameter(aUParam),myVParameter(aVParam)
{
//MESSAGE("******************************************************** SMDS_FacePosition");
}
//=======================================================================
//function : Coords
//purpose :
//=======================================================================
const double *SMDS_FacePosition::Coords() const
{
static double origin[]={0,0,0};
MESSAGE("SMDS_EdgePosition::Coords not implemented");
return origin;
}
/**
*/
SMDS_TypeOfPosition SMDS_FacePosition::GetTypeOfPosition() const

View File

@ -35,9 +35,7 @@ class SMDS_EXPORT SMDS_FacePosition:public SMDS_Position
{
public:
SMDS_FacePosition(int aFaceId=0, double aUParam=0,
double aVParam=0);
const virtual double * Coords() const;
SMDS_FacePosition(double aUParam=0, double aVParam=0);
SMDS_TypeOfPosition GetTypeOfPosition() const;
void SetUParameter(double aUparam);
void SetVParameter(double aVparam);

View File

@ -125,7 +125,9 @@ SMDS_Mesh::SMDS_Mesh()
myHasConstructionEdges(false), myHasConstructionFaces(false),
myHasInverseElements(true),
myNodeMin(0), myNodeMax(0),
myNodePool(0), myEdgePool(0), myFacePool(0), myVolumePool(0)
myNodePool(0), myEdgePool(0), myFacePool(0), myVolumePool(0),
myModified(false), myRemovedNodes(false), myChangedNodes(false),
xmin(0), xmax(0), ymin(0), ymax(0), zmin(0), zmax(0)
{
myMeshId = _meshList.size(); // --- index of the mesh to push back in the vector
MESSAGE("myMeshId=" << myMeshId);
@ -215,7 +217,7 @@ SMDS_MeshNode * SMDS_Mesh::AddNodeWithID(double x, double y, double z, int ID)
}
myNodeIDFactory->adjustMaxId(ID);
SMDS_MeshNode * node = myNodePool->getNew();
node->init(ID, myMeshId, -1, x, y, z);
node->init(ID, myMeshId, 0, x, y, z);
if (ID >= myNodes.size())
{
myNodes.resize(ID+SMDS_Mesh::chunkSize, 0);
@ -224,6 +226,8 @@ SMDS_MeshNode * SMDS_Mesh::AddNodeWithID(double x, double y, double z, int ID)
myNodes[ID] = node;
myNodeIDFactory->BindID(ID,node);
myInfo.myNbNodes++;
myModified = true;
this->adjustBoundingBox(x, y, z);
return node;
}else
return NULL;
@ -2426,6 +2430,13 @@ void SMDS_Mesh::Clear()
while(itc!=myChildren.end())
(*itc)->Clear();
myModified = false;
myRemovedNodes = false;
myChangedNodes = false;
xmin = 0; xmax = 0;
ymin = 0; ymax = 0;
zmin = 0; zmax = 0;
myInfo.Clear();
myGrid->Initialize();
@ -4061,3 +4072,36 @@ int SMDS_Mesh::fromSmdsToVtk(int smdsid)
return myCellIdSmdsToVtk[smdsid];
throw SALOME_Exception(LOCALIZED ("smds id out of bounds"));
}
void SMDS_Mesh::updateBoundingBox()
{
xmin = 0; xmax = 0;
ymin = 0; ymax = 0;
zmin = 0; zmax = 0;
vtkPoints *points = myGrid->GetPoints();
int myNodesSize = this->myNodes.size();
for (int i = 0; i < myNodesSize; i++)
{
if (SMDS_MeshNode *n = myNodes[i])
{
double coords[3];
points->GetPoint(n->myVtkID, coords);
if (coords[0] < xmin) xmin = coords[0];
else if (coords[0] > xmax) xmax = coords[0];
if (coords[1] < ymin) ymin = coords[1];
else if (coords[1] > ymax) ymax = coords[1];
if (coords[2] < zmin) zmin = coords[2];
else if (coords[2] > zmax) zmax = coords[2];
}
}
}
double SMDS_Mesh::getMaxDim()
{
double dmax = 1.e-3;
if ((xmax - xmin) > dmax) dmax = xmax -xmin;
if ((ymax - ymin) > dmax) dmax = ymax -ymin;
if ((zmax - zmin) > dmax) dmax = zmax -zmin;
MESSAGE("getMaxDim " << dmax);
return dmax;
}

View File

@ -57,8 +57,11 @@
class SMDS_EXPORT SMDS_Mesh:public SMDS_MeshObject{
public:
friend class SMDS_MeshIDFactory;
friend class SMDS_MeshNodeIDFactory;
friend class SMDS_MeshElementIDFactory;
friend class SMDS_MeshVolumeVtkNodes;
friend class SMDS_MeshNode;
SMDS_Mesh();
@ -568,6 +571,8 @@ public:
typedef std::vector<SMDS_MeshCell *> SetOfCells;
void updateNodeMinMax();
void updateBoundingBox();
double getMaxDim();
int fromVtkToSmds(int vtkid);
int fromSmdsToVtk(int smdsid);
@ -614,6 +619,16 @@ protected:
myCells.resize(ID+SMDS_Mesh::chunkSize,0);
};
inline void adjustBoundingBox(double x, double y, double z)
{
if (x > xmax) xmax = x;
else if (x < xmin) xmin = x;
if (y > ymax) ymax = y;
else if (y < ymin) ymin = y;
if (z > zmax) zmax = z;
else if (z < zmin) zmin = z;
};
// Fields PRIVATE
//! index of this SMDS_mesh in the static vector<SMDS_Mesh*> _meshList
@ -654,6 +669,16 @@ protected:
bool myHasConstructionEdges;
bool myHasConstructionFaces;
bool myHasInverseElements;
bool myModified; // any add remove or change of node or cell
bool myRemovedNodes;
bool myChangedNodes;
double xmin;
double xmax;
double ymin;
double ymax;
double zmin;
double zmax;
};

View File

@ -35,7 +35,7 @@
using namespace std;
SMDS_MeshElement::SMDS_MeshElement(int ID):myID(ID), myMeshId(-1), myShapeId(-1), myIdInShape(-1)
SMDS_MeshElement::SMDS_MeshElement(int ID):myID(ID), myMeshId(-1), myShapeId(0), myIdInShape(-1)
{
}

View File

@ -92,6 +92,8 @@ public:
friend SMDS_EXPORT bool SMDS_MeshElementIDFactory::BindID(int ID,SMDS_MeshElement* elem);
friend class SMDS_Mesh;
friend class SMESHDS_Mesh;
friend class SMESHDS_SubMesh;
friend class SMDS_MeshElementIDFactory;
// ===========================
// Access to nodes by index
@ -137,41 +139,28 @@ public:
*/
int GetNodeIndex( const SMDS_MeshNode* node ) const;
//inline int getId() const {return myID; };
inline ShortType getMeshId() const {return myMeshId; };
inline ShortType getshapeId() const {return myShapeId; };
inline void setShapeId(ShortType shapeId) {myShapeId = shapeId; };
inline int getIdInShape() const { return myIdInShape; };
inline void setIdInShape(int id) { myIdInShape = id; };
inline void setVtkId(int vtkId)
{
myVtkID = vtkId;
}
inline int getVtkId() const
{
return myVtkID;
}
inline int getVtkId() const { return myVtkID; };
protected:
inline void setId(int id) {myID = id; };
inline void setShapeId(ShortType shapeId) {myShapeId = shapeId; };
inline void setIdInShape(int id) { myIdInShape = id; };
inline void setVtkId(int vtkId) { myVtkID = vtkId; };
SMDS_MeshElement(int ID=-1);
SMDS_MeshElement(int id, ShortType meshId, ShortType shapeId=-1);
SMDS_MeshElement(int id, ShortType meshId, ShortType shapeId = 0);
virtual void Print(std::ostream & OS) const;
//! Element index in vector SMDS_Mesh::myNodes or SMDS_Mesh::myCells
int myID;
// index in vtkUnstructuredGrid
//! index in vtkUnstructuredGrid
int myVtkID;
//! SMDS_Mesh identification in SMESH
ShortType myMeshId;
//! SubShape and SubMesh identification in SMESHDS (not in use?)
//! SubShape and SubMesh identification in SMESHDS
ShortType myShapeId;
//! Element index in SMESHDS_SubMesh vector
int myIdInShape;
};

View File

@ -87,6 +87,7 @@ void SMDS_MeshIDFactory::ReleaseID(const int ID)
}
}
}
myMesh->myModified = true;
}
void SMDS_MeshIDFactory::Clear()

View File

@ -49,7 +49,7 @@ int SMDS_MeshNode::nbNodes =0;
//purpose :
//=======================================================================
SMDS_MeshNode::SMDS_MeshNode() :
SMDS_MeshElement(-1, -1, -1),
SMDS_MeshElement(-1, -1, 0),
myPosition(SMDS_SpacePosition::originSpacePosition())
{
nbNodes++;
@ -265,7 +265,6 @@ int SMDS_MeshNode::NbNodes() const
return 1;
}
double* SMDS_MeshNode::getCoord() const
{
return SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetPoint(myVtkID);
@ -292,8 +291,12 @@ double SMDS_MeshNode::Z() const
//* resize the vtkPoints structure every SMDS_Mesh::chunkSize points
void SMDS_MeshNode::setXYZ(double x, double y, double z)
{
vtkPoints *points = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetPoints();
SMDS_Mesh *mesh = SMDS_Mesh::_meshList[myMeshId];
vtkPoints *points = mesh->getGrid()->GetPoints();
points->InsertPoint(myVtkID, x, y, z);
mesh->adjustBoundingBox(x, y, z);
mesh->myChangedNodes = true;
mesh->myModified = true;
}
SMDSAbs_ElementType SMDS_MeshNode::GetType() const

View File

@ -41,7 +41,6 @@ public:
friend class SMDS_Mesh;
friend class ObjectPool<SMDS_MeshNode>;
double* getCoord() const;
void Print(std::ostream & OS) const;
double X() const;
double Y() const;
@ -63,12 +62,6 @@ public:
bool emptyInverseElements();
void setXYZ(double x, double y, double z);
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*/
//virtual const SMDS_MeshNode* GetNode(const int) const { return this; }
static int nbNodes;
protected:
@ -77,6 +70,7 @@ protected:
virtual ~SMDS_MeshNode();
void init(int id, int meshId, int shapeId = -1, double x=0, double y=0, double z=0);
inline void setVtkId(int vtkId) { myVtkID = vtkId; };
double* getCoord() const;
SMDS_ElemIteratorPtr
elementsIterator(SMDSAbs_ElementType type) const;

View File

@ -75,6 +75,7 @@ SMDS_MeshElement* SMDS_MeshNodeIDFactory::MeshElement(int ID)
void SMDS_MeshNodeIDFactory::ReleaseID(const int ID)
{
SMDS_MeshIDFactory::ReleaseID(ID);
myMesh->myRemovedNodes = true;
if (ID == myMax)
myMax = 0; // --- force updateMinMax
if (ID == myMin)

View File

@ -33,31 +33,9 @@
//purpose :
//=======================================================================
SMDS_Position::SMDS_Position(int aShapeId) :myShapeId(aShapeId)
SMDS_Position::SMDS_Position()
{
//MESSAGE("########################## SMDS_Position " << myShapeId);
}
//=======================================================================
//function : SetShapeId
//purpose :
//=======================================================================
void SMDS_Position::SetShapeId(int aShapeId)
{
//MESSAGE("############################## SetShapeId "<< aShapeId);
myShapeId = aShapeId;
}
//=======================================================================
//function : GetShapeId
//purpose :
//=======================================================================
int SMDS_Position::GetShapeId() const
{
//MESSAGE("################################# GetShapeId " << myShapeId);
return myShapeId;
//MESSAGE("########################## SMDS_Position ");
}
//=======================================================================

View File

@ -40,18 +40,12 @@ class SMDS_EXPORT SMDS_Position
{
public:
const virtual double * Coords() const = 0;
virtual SMDS_TypeOfPosition GetTypeOfPosition() const = 0;
virtual int GetDim() const;
void SetShapeId(int aShapeId);
int GetShapeId() const;
virtual ~SMDS_Position() {}
protected:
SMDS_Position(int aShapeId);
private:
int myShapeId;
SMDS_Position();
};

View File

@ -30,17 +30,10 @@
SMDS_SpacePosition* SMDS_SpacePosition::_originPosition = new SMDS_SpacePosition();
SMDS_SpacePosition::SMDS_SpacePosition(double x, double y, double z):
SMDS_Position(0)
SMDS_SpacePosition::SMDS_SpacePosition(double x, double y, double z)
{
}
const double* SMDS_SpacePosition::Coords() const
{
static double origin[]={0,0,0};
return origin;
}
SMDS_TypeOfPosition SMDS_SpacePosition::GetTypeOfPosition() const
{
return SMDS_TOP_3DSPACE;

View File

@ -36,7 +36,6 @@ class SMDS_EXPORT SMDS_SpacePosition:public SMDS_Position
public:
SMDS_SpacePosition(double x=0, double y=0, double z=0);
const virtual double * Coords() const;
virtual inline SMDS_TypeOfPosition GetTypeOfPosition() const;
static SMDS_PositionPtr originSpacePosition();
private:

View File

@ -36,25 +36,11 @@ using namespace std;
//purpose :
//=======================================================================
SMDS_VertexPosition:: SMDS_VertexPosition(const int aVertexId)
:SMDS_Position(aVertexId)
SMDS_VertexPosition:: SMDS_VertexPosition()
{
//MESSAGE("*********************************************** SMDS_VertexPosition " << aVertexId);
}
//=======================================================================
//function : Coords
//purpose :
//=======================================================================
const double *SMDS_VertexPosition::Coords() const
{
const static double origin[]={0,0,0};
//MESSAGE("######################### SMDS_VertexPosition::Coords not implemented");
return origin;
}
SMDS_TypeOfPosition SMDS_VertexPosition::GetTypeOfPosition() const
{
//MESSAGE("################################################# GetTypeOfPosition");

View File

@ -36,8 +36,7 @@ class SMDS_EXPORT SMDS_VertexPosition:public SMDS_Position
public:
SMDS_TypeOfPosition GetTypeOfPosition() const;
SMDS_VertexPosition(int aVertexId=0);
const double *Coords() const;
SMDS_VertexPosition();
};
#endif

View File

@ -65,6 +65,7 @@ bool SMDS_VtkEdge::IsMediumNode(const SMDS_MeshNode* node) const
vtkIdType npts = 0;
vtkIdType* pts = 0;
grid->GetCellPoints(myVtkID, npts, pts);
//MESSAGE("IsMediumNode " << npts << " " << (node->getVtkId() == pts[npts-1]));
return ((npts == 3) && (node->getVtkId() == pts[2]));
}

View File

@ -165,6 +165,7 @@ bool SMDS_VtkFace::IsMediumNode(const SMDS_MeshNode* node) const
rankFirstMedium = 4; // medium nodes are of rank 4,5,6,7
break;
default:
//MESSAGE("wrong element type " << aVtkType);
return false;
}
vtkIdType npts = 0;
@ -175,6 +176,7 @@ bool SMDS_VtkFace::IsMediumNode(const SMDS_MeshNode* node) const
{
if (pts[rank] == nodeId)
{
//MESSAGE("rank " << rank << " is medium node " << (rank < rankFirstMedium));
if (rank < rankFirstMedium)
return false;
else

View File

@ -75,13 +75,14 @@ void SMDS_VtkVolume::initPoly(std::vector<vtkIdType> nodeIds, std::vector<int> n
{
int nf = nbNodesPerFace[i];
ptIds.push_back(nf);
double a[3];
double b[3];
double c[3];
grid->GetPoints()->GetPoint(nodeIds[k], a);
grid->GetPoints()->GetPoint(nodeIds[k + 1], b);
grid->GetPoints()->GetPoint(nodeIds[k + 2], c);
bool isFaceForward = this->isForward(a, b, c, center);
// double a[3];
// double b[3];
// double c[3];
// grid->GetPoints()->GetPoint(nodeIds[k], a);
// grid->GetPoints()->GetPoint(nodeIds[k + 1], b);
// grid->GetPoints()->GetPoint(nodeIds[k + 2], c);
// bool isFaceForward = this->isForward(a, b, c, center);
bool isFaceForward = true;
//MESSAGE("isFaceForward " << i << " " << isFaceForward);
vtkIdType *facePts = &nodeIds[k];
if (isFaceForward)

View File

@ -258,7 +258,7 @@ bool SMESH_Algo::IsReversedSubMesh (const TopoDS_Face& theFace,
fPos = dynamic_cast< const SMDS_FacePosition* >( pos );
}
else if ( pos->GetTypeOfPosition() == SMDS_TOP_VERTEX ) {
vID = pos->GetShapeId();
vID = node->getshapeId();
}
}
if ( fPos || ( !normalOK && vID )) {

View File

@ -278,7 +278,7 @@ bool SMESH_MeshEditor::Remove (const list< int >& theIDs,
if ( isNodes ) {
const SMDS_MeshNode* node = cast2Node( elem );
if ( node->GetPosition()->GetTypeOfPosition() == SMDS_TOP_VERTEX )
if ( int aShapeID = node->GetPosition()->GetShapeId() )
if ( int aShapeID = node->getshapeId() )
if ( SMESH_subMesh * sm = GetMesh()->GetSubMeshContaining( aShapeID ) )
smmap.insert( sm );
}
@ -331,22 +331,21 @@ int SMESH_MeshEditor::FindShape (const SMDS_MeshElement * theElem)
if ( aMesh->ShapeToMesh().IsNull() )
return 0;
if ( theElem->GetType() == SMDSAbs_Node ) {
const SMDS_PositionPtr& aPosition =
static_cast<const SMDS_MeshNode*>( theElem )->GetPosition();
if ( aPosition )
return aPosition->GetShapeId();
else
return 0;
}
if ( theElem->GetType() == SMDSAbs_Node )
{
int aShapeID = theElem->getshapeId();
if (aShapeID <= 0)
return 0;
else
return aShapeID;
}
TopoDS_Shape aShape; // the shape a node is on
SMDS_ElemIteratorPtr nodeIt = theElem->nodesIterator();
while ( nodeIt->more() ) {
const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
const SMDS_PositionPtr& aPosition = node->GetPosition();
if ( aPosition ) {
int aShapeID = aPosition->GetShapeId();
int aShapeID = node->getshapeId();
if (aShapeID > 0) {
SMESHDS_SubMesh * sm = aMesh->MeshElements( aShapeID );
if ( sm ) {
if ( sm->Contains( theElem ))
@ -2920,7 +2919,7 @@ void SMESH_MeshEditor::Smooth (TIDSortedElemSet & theElems,
break;
}
case SMDS_TOP_EDGE: {
TopoDS_Shape S = aMesh->IndexToShape( pos->GetShapeId() );
TopoDS_Shape S = aMesh->IndexToShape( node->getshapeId() );
Handle(Geom2d_Curve) pcurve;
if ( !S.IsNull() && S.ShapeType() == TopAbs_EDGE )
pcurve = BRep_Tool::CurveOnSurface( TopoDS::Edge( S ), face, f,l );
@ -2931,7 +2930,7 @@ void SMESH_MeshEditor::Smooth (TIDSortedElemSet & theElems,
break;
}
case SMDS_TOP_VERTEX: {
TopoDS_Shape S = aMesh->IndexToShape( pos->GetShapeId() );
TopoDS_Shape S = aMesh->IndexToShape( node->getshapeId() );
if ( !S.IsNull() && S.ShapeType() == TopAbs_VERTEX )
uv = BRep_Tool::Parameters( TopoDS::Vertex( S ), face ).XY();
break;
@ -3194,7 +3193,7 @@ void SMESH_MeshEditor::Smooth (TIDSortedElemSet & theElems,
if ( node_uv != uvMap.end() ) {
gp_XY* uv = node_uv->second;
node->SetPosition
( SMDS_PositionPtr( new SMDS_FacePosition( *fId, uv->X(), uv->Y() )));
( SMDS_PositionPtr( new SMDS_FacePosition( uv->X(), uv->Y() )));
}
}
@ -3291,6 +3290,7 @@ void SMESH_MeshEditor::sweepElement(const SMDS_MeshElement* elem,
const int nbSteps,
SMESH_SequenceOfElemPtr& srcElements)
{
MESSAGE("sweepElement " << nbSteps);
SMESHDS_Mesh* aMesh = GetMeshDS();
// Loop on elem nodes:
@ -4287,6 +4287,7 @@ SMESH_MeshEditor::ExtrusionSweep (TIDSortedElemSet & theElems,
const int theFlags,
const double theTolerance)
{
MESSAGE("ExtrusionSweep " << theMakeGroups << " " << theFlags << " " << theTolerance);
myLastCreatedElems.Clear();
myLastCreatedNodes.Clear();
@ -9230,9 +9231,9 @@ int SMESH_MeshEditor::removeQuadElem(SMESHDS_SubMesh * theSm,
for ( ; nIt != mediumNodes.end(); ++nIt ) {
const SMDS_MeshNode* n = *nIt;
if ( n->NbInverseElements() == 0 ) {
if ( n->GetPosition()->GetShapeId() != theShapeID )
if ( n->getshapeId() != theShapeID )
meshDS->RemoveFreeNode( n, meshDS->MeshElements
( n->GetPosition()->GetShapeId() ));
( n->getshapeId() ));
else
meshDS->RemoveFreeNode( n, theSm );
}

View File

@ -286,7 +286,7 @@ bool SMESH_MesherHelper::IsMedium(const SMDS_MeshNode* node,
TopoDS_Shape SMESH_MesherHelper::GetSubShapeByNode(const SMDS_MeshNode* node,
SMESHDS_Mesh* meshDS)
{
int shapeID = node->GetPosition()->GetShapeId();
int shapeID = node->getshapeId();
if ( 0 < shapeID && shapeID <= meshDS->MaxShapeIndex() )
return meshDS->IndexToShape( shapeID );
else
@ -365,7 +365,7 @@ gp_XY SMESH_MesherHelper::GetNodeUV(const TopoDS_Face& F,
// edge and retrieve value from this pcurve
const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(n->GetPosition());
int edgeID = Pos->GetShapeId();
int edgeID = n->getshapeId();
TopoDS_Edge E = TopoDS::Edge(GetMeshDS()->IndexToShape(edgeID));
double f, l, u = epos->GetUParameter();
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
@ -400,7 +400,7 @@ gp_XY SMESH_MesherHelper::GetNodeUV(const TopoDS_Face& F,
}
else if(Pos->GetTypeOfPosition()==SMDS_TOP_VERTEX)
{
if ( int vertexID = n->GetPosition()->GetShapeId() ) {
if ( int vertexID = n->getshapeId() ) {
const TopoDS_Vertex& V = TopoDS::Vertex(GetMeshDS()->IndexToShape(vertexID));
try {
uv = BRep_Tool::Parameters( V, F );
@ -470,8 +470,11 @@ bool SMESH_MesherHelper::CheckNodeUV(const TopoDS_Face& F,
const double tol,
const bool force) const
{
if ( force || !myOkNodePosShapes.count( n->GetPosition()->GetShapeId() ))
if ( force || !myOkNodePosShapes.count( n->getshapeId() ))
{
double toldis = tol;
double tolmin = 1.e-7*myMesh->GetMeshDS()->getMaxDim(); // nodes coordinates are stored in float format
if (toldis < tolmin) toldis = tolmin;
// check that uv is correct
TopLoc_Location loc;
Handle(Geom_Surface) surface = BRep_Tool::Surface( F,loc );
@ -479,7 +482,7 @@ bool SMESH_MesherHelper::CheckNodeUV(const TopoDS_Face& F,
if ( !loc.IsIdentity() ) nodePnt.Transform( loc.Transformation().Inverted() );
if ( Precision::IsInfinite( uv.X() ) ||
Precision::IsInfinite( uv.Y() ) ||
nodePnt.Distance( surface->Value( uv.X(), uv.Y() )) > tol )
nodePnt.Distance( surface->Value( uv.X(), uv.Y() )) > toldis )
{
// uv incorrect, project the node to surface
GeomAPI_ProjectPointOnSurf& projector = GetProjector( F, loc, tol );
@ -491,7 +494,7 @@ bool SMESH_MesherHelper::CheckNodeUV(const TopoDS_Face& F,
}
Quantity_Parameter U,V;
projector.LowerDistanceParameters(U,V);
if ( nodePnt.Distance( surface->Value( U, V )) > tol )
if ( nodePnt.Distance( surface->Value( U, V )) > toldis )
{
MESSAGE( "SMESH_MesherHelper::CheckNodeUV(), invalid projection" );
return false;
@ -500,7 +503,7 @@ bool SMESH_MesherHelper::CheckNodeUV(const TopoDS_Face& F,
}
else if ( uv.Modulus() > numeric_limits<double>::min() )
{
((SMESH_MesherHelper*) this)->myOkNodePosShapes.insert( n->GetPosition()->GetShapeId() );
((SMESH_MesherHelper*) this)->myOkNodePosShapes.insert( n->getshapeId() );
}
}
return true;
@ -619,7 +622,7 @@ double SMESH_MesherHelper::GetNodeU(const TopoDS_Edge& E,
else
{
SMESHDS_Mesh * meshDS = GetMeshDS();
int vertexID = pos->GetShapeId();
int vertexID = n->getshapeId();
const TopoDS_Vertex& V = TopoDS::Vertex(meshDS->IndexToShape(vertexID));
param = BRep_Tool::Parameter( V, E );
}
@ -630,7 +633,7 @@ double SMESH_MesherHelper::GetNodeU(const TopoDS_Edge& E,
double f,l; BRep_Tool::Range( E, f,l );
bool force = ( param < f-tol || param > l+tol );
if ( !force && pos->GetTypeOfPosition()==SMDS_TOP_EDGE )
force = ( GetMeshDS()->ShapeToIndex( E ) != pos->GetShapeId() );
force = ( GetMeshDS()->ShapeToIndex( E ) != n->getshapeId() );
*check = CheckNodeU( E, n, param, tol, force );
}
@ -649,10 +652,11 @@ bool SMESH_MesherHelper::CheckNodeU(const TopoDS_Edge& E,
const double tol,
const bool force) const
{
if ( force || !myOkNodePosShapes.count( n->GetPosition()->GetShapeId() ))
if ( force || !myOkNodePosShapes.count( n->getshapeId() ))
{
double toldis = tol;
// TODO if (toldis < 5.e-5) toldis = 5.e-5; // nodes coordinates are stored in float format
double tolmin = 1.e-7*myMesh->GetMeshDS()->getMaxDim(); // nodes coordinates are stored in float format
if (toldis < tolmin) toldis = tolmin;
// check that u is correct
TopLoc_Location loc; double f,l;
Handle(Geom_Curve) curve = BRep_Tool::Curve( E,loc,f,l );
@ -688,7 +692,7 @@ bool SMESH_MesherHelper::CheckNodeU(const TopoDS_Edge& E,
}
else if ( fabs( u ) > numeric_limits<double>::min() )
{
((SMESH_MesherHelper*) this)->myOkNodePosShapes.insert( n->GetPosition()->GetShapeId() );
((SMESH_MesherHelper*) this)->myOkNodePosShapes.insert( n->getshapeId() );
}
if (( u < f-tol || u > l+tol ) && force )
{
@ -739,17 +743,17 @@ const SMDS_MeshNode* SMESH_MesherHelper::GetMediumNode(const SMDS_MeshNode* n1,
if( myShape.IsNull() )
{
if( Pos1->GetTypeOfPosition()==SMDS_TOP_FACE ) {
faceID = Pos1->GetShapeId();
faceID = n1->getshapeId();
}
else if( Pos2->GetTypeOfPosition()==SMDS_TOP_FACE ) {
faceID = Pos2->GetShapeId();
faceID = n2->getshapeId();
}
if( Pos1->GetTypeOfPosition()==SMDS_TOP_EDGE ) {
edgeID = Pos1->GetShapeId();
edgeID = n1->getshapeId();
}
if( Pos2->GetTypeOfPosition()==SMDS_TOP_EDGE ) {
edgeID = Pos2->GetShapeId();
edgeID = n2->getshapeId();
}
}
// get positions of the given nodes on shapes
@ -787,10 +791,10 @@ const SMDS_MeshNode* SMESH_MesherHelper::GetMediumNode(const SMDS_MeshNode* n1,
{
if ( uvOK[0] && uvOK[1] )
{
if ( IsDegenShape( Pos1->GetShapeId() ))
if ( IsDegenShape( n1->getshapeId() ))
if ( myParIndex & U_periodic ) uv[0].SetCoord( 1, uv[1].Coord( 1 ));
else uv[0].SetCoord( 2, uv[1].Coord( 2 ));
else if ( IsDegenShape( Pos2->GetShapeId() ))
else if ( IsDegenShape( n2->getshapeId() ))
if ( myParIndex & U_periodic ) uv[1].SetCoord( 1, uv[0].Coord( 1 ));
else uv[1].SetCoord( 2, uv[0].Coord( 2 ));

View File

@ -463,8 +463,7 @@ template <class TFaceIterator> bool areNodesBound( TFaceIterator & faceItr )
while ( nIt->more() )
{
const SMDS_MeshNode* node = smdsNode( nIt->next() );
SMDS_PositionPtr pos = node->GetPosition();
if ( !pos || !pos->GetShapeId() ) {
if (node->getshapeId() <0) {
return false;
}
}
@ -877,7 +876,7 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh,
const SMDS_MeshNode* node = smdsNode( nIt->next() );
iPoint = nodePointIDMap[ node ]; // point index of interest
// for a node on a seam edge there are two points
if ( helper.IsRealSeam( node->GetPosition()->GetShapeId() ) &&
if ( helper.IsRealSeam( node->getshapeId() ) &&
( n_id = closeNodePointIDMap.find( node )) != not_found )
{
TPoint & p1 = myPoints[ iPoint ];
@ -888,7 +887,7 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh,
// find node not on a seam edge
while ( nIt2->more() && !notSeamNode ) {
const SMDS_MeshNode* n = smdsNode( nIt2->next() );
if ( !helper.IsSeamShape( n->GetPosition()->GetShapeId() ))
if ( !helper.IsSeamShape( n->getshapeId() ))
notSeamNode = n;
}
gp_Pnt2d uv = helper.GetNodeUV( theFace, node, notSeamNode );
@ -4114,7 +4113,7 @@ void SMESH_Pattern::createElements(SMESH_Mesh* theMes
SMDS_ElemIteratorPtr noIt = elem->nodesIterator();
while ( noIt->more() ) {
SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>(smdsNode( noIt->next() ));
if (!node->GetPosition()->GetShapeId() &&
if (!node->getshapeId() &&
shellNodes.find( node ) == shellNodes.end() ) {
if ( S.ShapeType() == TopAbs_FACE )
aMeshDS->SetNodeOnFace( node, shapeID );

View File

@ -87,7 +87,7 @@ void SMESHDS_Mesh::ShapeToMesh(const TopoDS_Shape & S)
if ( !i_sub->second->IsComplexSubmesh() ) {
SMDS_NodeIteratorPtr nIt = i_sub->second->GetNodes();
while ( nIt->more() )
nIt->next()->GetPosition()->SetShapeId( 0 );
i_sub->second->RemoveNode(nIt->next(), false);
}
}
// - sub-meshes
@ -729,7 +729,7 @@ void SMESHDS_Mesh::RemoveNode(const SMDS_MeshNode * n)
{
SMESHDS_SubMesh* subMesh=0;
map<int,SMESHDS_SubMesh*>::iterator SubIt =
myShapeIndexToSubMesh.find( n->GetPosition()->GetShapeId() );
myShapeIndexToSubMesh.find( n->getshapeId() );
if ( SubIt != myShapeIndexToSubMesh.end() )
subMesh = SubIt->second;
else
@ -919,7 +919,7 @@ SMESHDS_SubMesh* SMESHDS_Mesh::getSubmesh( const int Index )
if ( Index != myCurSubID ) {
map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
if ( it == myShapeIndexToSubMesh.end() )
it = myShapeIndexToSubMesh.insert( make_pair(Index, new SMESHDS_SubMesh() )).first;
it = myShapeIndexToSubMesh.insert( make_pair(Index, new SMESHDS_SubMesh(this, Index) )).first;
myCurSubMesh = it->second;
myCurSubID = Index;
myCurSubShape.Nullify(); // myCurSubShape no more corresponds to submesh
@ -947,22 +947,6 @@ bool SMESHDS_Mesh::add(const SMDS_MeshElement* elem, SMESHDS_SubMesh* subMesh )
return false;
}
namespace {
//================================================================================
/*!
* \brief Creates a node position in volume
*/
//================================================================================
inline SMDS_PositionPtr volumePosition(int volId)
{
SMDS_SpacePosition* pos = new SMDS_SpacePosition();
pos->SetShapeId( volId );
return SMDS_PositionPtr(pos);
}
}
//=======================================================================
//function : SetNodeOnVolume
//purpose :
@ -971,8 +955,9 @@ void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
const TopoDS_Shell & S)
{
if ( add( aNode, getSubmesh(S) ))
aNode->SetPosition ( volumePosition( myCurSubID ));
aNode->SetPosition ( SMDS_SpacePosition::originSpacePosition() );
}
//=======================================================================
//function : SetNodeOnVolume
//purpose :
@ -981,7 +966,7 @@ void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode,
const TopoDS_Solid & S)
{
if ( add( aNode, getSubmesh(S) ))
aNode->SetPosition ( volumePosition( myCurSubID ));
aNode->SetPosition ( SMDS_SpacePosition::originSpacePosition() );
}
//=======================================================================
@ -994,7 +979,7 @@ void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode * aNode,
double v)
{
if ( add( aNode, getSubmesh(S) ))
aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(myCurSubID, u, v)));
aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition( u, v)));
}
//=======================================================================
@ -1006,7 +991,7 @@ void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode * aNode,
double u)
{
if ( add( aNode, getSubmesh(S) ))
aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(myCurSubID, u)));
aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(u)));
}
//=======================================================================
@ -1017,7 +1002,7 @@ void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode * aNode,
const TopoDS_Vertex & S)
{
if ( add( aNode, getSubmesh(S) ))
aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(myCurSubID)));
aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition()));
}
//=======================================================================
@ -1026,12 +1011,13 @@ void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode * aNode,
//=======================================================================
void SMESHDS_Mesh::UnSetNodeOnShape(const SMDS_MeshNode* aNode)
{
if ( aNode && aNode->GetPosition() ) {
map<int,SMESHDS_SubMesh*>::iterator it =
myShapeIndexToSubMesh.find( aNode->GetPosition()->GetShapeId() );
if ( it != myShapeIndexToSubMesh.end() )
it->second->RemoveNode( aNode, /*deleted=*/false );
}
int shapeId = aNode->getshapeId();
if (shapeId >= 0)
{
map<int, SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find(shapeId);
if (it != myShapeIndexToSubMesh.end())
it->second->RemoveNode(aNode, /*deleted=*/false);
}
}
//=======================================================================
@ -1193,7 +1179,7 @@ SMESHDS_SubMesh * SMESHDS_Mesh::NewSubMesh(int Index)
TShapeIndexToSubMesh::iterator anIter = myShapeIndexToSubMesh.find(Index);
if (anIter == myShapeIndexToSubMesh.end())
{
SM = new SMESHDS_SubMesh();
SM = new SMESHDS_SubMesh(this, Index);
myShapeIndexToSubMesh[Index]=SM;
}
else
@ -1274,8 +1260,9 @@ int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const
//=======================================================================
void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode, int Index)
{
//add(aNode, getSubmesh(Index));
if ( add( aNode, getSubmesh( Index )))
((SMDS_MeshNode*) aNode)->SetPosition( volumePosition( Index ));
((SMDS_MeshNode*) aNode)->SetPosition( SMDS_SpacePosition::originSpacePosition());
}
//=======================================================================
@ -1286,7 +1273,7 @@ void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode* aNode, int Index, double u, doub
{
//Set Position on Node
if ( add( aNode, getSubmesh( Index )))
aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition(Index, u, v)));
aNode->SetPosition(SMDS_PositionPtr(new SMDS_FacePosition( u, v)));
}
//=======================================================================
@ -1299,7 +1286,7 @@ void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode* aNode,
{
//Set Position on Node
if ( add( aNode, getSubmesh( Index )))
aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(Index, u)));
aNode->SetPosition(SMDS_PositionPtr(new SMDS_EdgePosition(u)));
}
//=======================================================================
@ -1310,7 +1297,7 @@ void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode* aNode, int Index)
{
//Set Position on Node
if ( add( aNode, getSubmesh( Index )))
aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition(Index)));
aNode->SetPosition(SMDS_PositionPtr(new SMDS_VertexPosition()));
}
//=======================================================================
@ -1940,13 +1927,13 @@ void SMESHDS_Mesh::compactMesh()
this->myScript->SetModified(true); // notify GUI client for buildPrs when update
// ---TODO: myNodes, myElements in submeshes
// --- compact list myNodes and myElements in submeshes
// map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.begin();
// for(; it != myShapeIndexToSubMesh.end(); ++it)
// {
// (*it).second->compactList(idNodesOldToNew, newNodeSize, idCellsOldToNew, newCellSize);
// }
map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.begin();
for(; it != myShapeIndexToSubMesh.end(); ++it)
{
(*it).second->compactList();
}
}

View File

@ -453,7 +453,7 @@ private:
//Update or build submesh
std::map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
if ( it == myShapeIndexToSubMesh.end() )
it = myShapeIndexToSubMesh.insert( std::make_pair(Index, new SMESHDS_SubMesh() )).first;
it = myShapeIndexToSubMesh.insert( std::make_pair(Index, new SMESHDS_SubMesh(this, Index) )).first;
it->second->AddNode( aNode ); // add aNode to submesh
}

View File

@ -27,6 +27,7 @@
// $Header:
//
#include "SMESHDS_SubMesh.hxx"
#include "SMESHDS_Mesh.hxx"
#include "utilities.h"
#include "SMDS_SetIterator.hxx"
@ -35,10 +36,12 @@
using namespace std;
SMESHDS_SubMesh::SMESHDS_SubMesh()
SMESHDS_SubMesh::SMESHDS_SubMesh(SMESHDS_Mesh *parent, int index)
{
myParent = parent;
myElements.clear();
myNodes.clear();
myIndex = index;
myUnusedIdNodes = 0;
myUnusedIdElements = 0;
}
@ -59,6 +62,7 @@ void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME)
throw SALOME_Exception(LOCALIZED("add element in subshape already belonging to a subshape"));
}
SMDS_MeshElement* elem = (SMDS_MeshElement*) (ME);
elem->setShapeId(myIndex);
elem->setIdInShape(myElements.size());
myElements.push_back(ME);
}
@ -70,30 +74,26 @@ void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME)
//=======================================================================
bool SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME, bool isElemDeleted)
{
// MESSAGE("--------------------------------------> RemoveElement " << isElemDeleted);
// if ( !IsComplexSubmesh() && NbElements() ) {
if (!isElemDeleted) // alive element has valid ID and can be found
{
int idInSubShape = ME->getIdInShape();
//MESSAGE("SMESHDS_SubMesh::RemoveElement " << idInSubShape << " " << ME->GetID() << " " << myUnusedIdElements);
assert(idInSubShape >= 0);
assert(idInSubShape < myElements.size());
myElements[idInSubShape] = 0; // this vector entry is no more used
myUnusedIdElements++;
return true;
}
// --- strange ?
// TElemSet::iterator e = myElements.begin(), eEnd = myElements.end();
// for ( ; e != eEnd; ++e )
// if ( ME == *e ) {
// myElements.erase( e );
// return true;
// }
// }
// MESSAGE("--------------------------------------> RemoveElement " << isElemDeleted);
if (!IsComplexSubmesh())
{
if (!isElemDeleted) // alive element has valid ID and can be found
{
int idInSubShape = ME->getIdInShape();
//MESSAGE("SMESHDS_SubMesh::RemoveElement " << idInSubShape << " " << ME->GetID() << " " << myUnusedIdElements);
assert(idInSubShape >= 0);
assert(idInSubShape < myElements.size());
SMDS_MeshElement* elem = (SMDS_MeshElement*) (ME);
elem->setShapeId(0);
elem->setIdInShape(-1);
myElements[idInSubShape] = 0; // this vector entry is no more used
myUnusedIdElements++;
return true;
}
MESSAGE("Try to remove an already deleted element from a submesh ");
return false;
}
MESSAGE("Try to remove an element from a complex submesh ");
return false;
}
@ -106,11 +106,19 @@ void SMESHDS_SubMesh::AddNode(const SMDS_MeshNode * N)
if ( !IsComplexSubmesh() )
{
int idInSubShape = N->getIdInShape();
assert(idInSubShape == -1);
int shapeId = N->getshapeId();
if ((shapeId > 0) && (idInSubShape >= 0))
{
MESSAGE("========== AddNode already belonging to other subShape " << N->GetID());
// OK for vertex nodes
//this->getParent()->UnSetNodeOnShape(N);
}
SMDS_MeshNode* node = (SMDS_MeshNode*)(N);
node->setShapeId(myIndex);
node->setIdInShape(myNodes.size());
myNodes.push_back(N);
}
MESSAGE("try to add node in a complex submesh " << N->GetID());
}
//=======================================================================
@ -120,28 +128,26 @@ void SMESHDS_SubMesh::AddNode(const SMDS_MeshNode * N)
bool SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N, bool isNodeDeleted)
{
// if ( !IsComplexSubmesh() && NbNodes() ) {
if (!isNodeDeleted) // alive node has valid ID and can be found
{
int idInSubShape = N->getIdInShape();
//MESSAGE("SMESHDS_SubMesh::RemoveNode " << idInSubShape << " " << N->GetID());
assert(idInSubShape >= 0);
assert(idInSubShape < myNodes.size());
myNodes[idInSubShape] = 0; // this vector entry is no more used
myUnusedIdNodes++;
return true;
}
// --- strange ?
// TElemSet::iterator e = myNodes.begin(), eEnd = myNodes.end();
// for ( ; e != eEnd; ++e )
// if ( N == *e ) {
// myNodes.erase( e );
// return true;
// }
// }
if (!IsComplexSubmesh())
{
if (!isNodeDeleted) // alive node has valid ID and can be found
{
int idInSubShape = N->getIdInShape();
int shapeId = N->getshapeId();
MESSAGE("SMESHDS_SubMesh::RemoveNode " << shapeId << " " << idInSubShape << " " << N->GetID());
//assert(idInSubShape >= 0);
//assert(idInSubShape < myNodes.size());
SMDS_MeshNode* node = (SMDS_MeshNode*) (N);
node->setShapeId(0);
node->setIdInShape(-1);
myNodes[idInSubShape] = 0; // this vector entry is no more used
myUnusedIdNodes++;
return true;
}
MESSAGE("Try to remove an already deleted node from a submesh");
return false;
}
MESSAGE("Try to remove a node from a complex submesh");
return false;
}
@ -151,6 +157,7 @@ bool SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N, bool isNodeDeleted)
//=======================================================================
int SMESHDS_SubMesh::NbElements() const
{
//MESSAGE(this << " NbElements " << IsComplexSubmesh() << " " << myElements.size() - myUnusedIdElements);
if ( !IsComplexSubmesh() )
return myElements.size() - myUnusedIdElements;
@ -169,8 +176,9 @@ int SMESHDS_SubMesh::NbElements() const
int SMESHDS_SubMesh::NbNodes() const
{
if ( !IsComplexSubmesh() )
return myNodes.size() - myUnusedIdNodes;
//MESSAGE(this << " NbNodes " << IsComplexSubmesh() << " " << myNodes.size() - myUnusedIdNodes);
if ( !IsComplexSubmesh() )
return myNodes.size() - myUnusedIdNodes;
int nbElems = 0;
set<const SMESHDS_SubMesh*>::const_iterator it = mySubMeshes.begin();
@ -192,41 +200,28 @@ template <class ELEM, typename TSET> class MySetIterator : public SMDS_Iterator<
protected:
typename TSET::const_iterator _it, _end;
TSET _table;
// int _ind;
public:
MySetIterator(const TSET& table)
// : _it(table.begin()), _end(table.end())
{
// MESSAGE("table.size()="<< table.size());
_table = table;
_it = _table.begin();
_end = _table.end();
// for (int i=0; i< _table.size(); i++)
// if (_table[i]) { MESSAGE("_table["<< i << "]="<< _table[i]);}
// else
// { MESSAGE("_table["<< i << "]=NULL"); }
// _ind = 0;
_table = table;
_it = _table.begin();
_end = _table.end();
while ((_it != _end) && (*_it == 0))
_it++;
}
virtual bool more()
{
while((_it != _end) && (*_it == 0))
{
while ((_it != _end) && (*_it == 0))
_it++;
// _ind++;
}
// MESSAGE("more _ind=" << _ind);
return (_it != _end);
}
virtual ELEM next()
{
ELEM e=*_it;
// if (e) { MESSAGE("next _ind=" << _ind << " *_it=" << *_it);}
// else { MESSAGE("next _ind=" << _ind << " *_it=NULL");}
// _ind++;
_it++;
return e;
ELEM e = *_it;
_it++;
return e;
}
};
@ -327,31 +322,33 @@ bool SMESHDS_SubMesh::Contains(const SMDS_MeshElement * ME) const
{
// DO NOT TRY TO FIND A REMOVED ELEMENT !!
//if ( IsComplexSubmesh() || !ME )
if (!ME )
if (!ME)
return false;
if ( IsComplexSubmesh() )
{
set<const SMESHDS_SubMesh*>::const_iterator aSubIt = mySubMeshes.begin();
for ( ; aSubIt != mySubMeshes.end(); aSubIt++ )
if ( (*aSubIt)->Contains( ME ))
return true;
return false;
}
if (IsComplexSubmesh())
{
set<const SMESHDS_SubMesh*>::const_iterator aSubIt = mySubMeshes.begin();
for (; aSubIt != mySubMeshes.end(); aSubIt++)
if ((*aSubIt)->Contains(ME))
return true;
return false;
}
if ( ME->GetType() == SMDSAbs_Node )
if (ME->GetType() == SMDSAbs_Node)
{
int idInShape = ME->getIdInShape();
if ((idInShape >= 0) && (idInShape < myNodes.size()))
if (myNodes[idInShape] == ME) return true;
if (myNodes[idInShape] == ME)
return true;
}
else
{
int idInShape = ME->getIdInShape();
if ((idInShape >= 0) && (idInShape < myElements.size()))
if (myElements[idInShape] == ME) return true;
if (myElements[idInShape] == ME)
return true;
}
return false;
return false;
}
//=======================================================================
@ -407,6 +404,8 @@ void SMESHDS_SubMesh::Clear()
{
myElements.clear();
myNodes.clear();
myUnusedIdNodes = 0;
myUnusedIdElements = 0;
SMESHDS_SubMeshIteratorPtr sub = GetSubMeshIterator();
while ( sub->more() ) {
if ( SMESHDS_SubMesh* sm = (SMESHDS_SubMesh*) sub->next())
@ -425,5 +424,29 @@ int SMESHDS_SubMesh::getSize()
void SMESHDS_SubMesh::compactList()
{
// todo : compact vector of nodes and elements
MESSAGE("compactList old: nodes " << myNodes.size() << " elements " << myElements.size());
std::vector<const SMDS_MeshElement*> newElems;
newElems.clear();
for (int i = 0; i < myElements.size(); i++)
if (myElements[i])
{
SMDS_MeshElement* elem = (SMDS_MeshElement*)myElements[i];
elem->setIdInShape(newElems.size());
newElems.push_back(elem);
}
myElements.swap(newElems);
myUnusedIdElements = 0;
std::vector<const SMDS_MeshNode*> newNodes;
newNodes.clear();
for (int i = 0; i < myNodes.size(); i++)
if (myNodes[i])
{
SMDS_MeshNode* node = (SMDS_MeshNode*)myNodes[i];
node->setIdInShape(newNodes.size());
newNodes.push_back(node);
}
myNodes.swap(newNodes);
myUnusedIdNodes = 0;
//MESSAGE("compactList new: nodes " << myNodes.size() << " elements " << myElements.size());
}

View File

@ -37,10 +37,12 @@ class SMESHDS_SubMesh;
typedef SMDS_Iterator<const SMESHDS_SubMesh*> SMESHDS_SubMeshIterator;
typedef boost::shared_ptr< SMESHDS_SubMeshIterator > SMESHDS_SubMeshIteratorPtr;
class SMESHDS_Mesh;
class SMESHDS_EXPORT SMESHDS_SubMesh
{
public:
SMESHDS_SubMesh();
SMESHDS_SubMesh(SMESHDS_Mesh *parent, int index);
bool IsComplexSubmesh() const { return !mySubMeshes.empty(); }
@ -69,13 +71,16 @@ class SMESHDS_EXPORT SMESHDS_SubMesh
int getSize();
void compactList();
private:
inline SMESHDS_Mesh *getParent() {return myParent; };
private:
SMESHDS_Mesh * myParent;
std::vector<const SMDS_MeshElement*> myElements;
std::vector<const SMDS_MeshNode*> myNodes;
int myUnusedIdNodes;
int myUnusedIdElements;
int myIndex;
std::set<const SMESHDS_SubMesh*> mySubMeshes;
};

View File

@ -4004,7 +4004,6 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
// add
if ( isNode ) {
SMDS_PositionPtr pos = aPositionCreator.MakePosition( smType[ smID ]);
pos->SetShapeId( smID );
SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>( static_cast<const SMDS_MeshNode*>( elem ));
node->SetPosition( pos );
sm->AddNode( node );

View File

@ -2985,7 +2985,7 @@ SMESH::NodePosition* SMESH_Mesh_i::GetNodePosition(CORBA::Long NodeID)
{
if ( SMDS_PositionPtr pos = aNode->GetPosition() )
{
aNodePosition->shapeID = pos->GetShapeId();
aNodePosition->shapeID = aNode->getshapeId();
switch ( pos->GetTypeOfPosition() ) {
case SMDS_TOP_EDGE:
aNodePosition->shapeType = GEOM::EDGE;
@ -3033,11 +3033,7 @@ CORBA::Long SMESH_Mesh_i::GetShapeID(const CORBA::Long id)
// try to find node
const SMDS_MeshNode* aNode = aSMESHDS_Mesh->FindNode(id);
if(aNode) {
SMDS_PositionPtr pos = aNode->GetPosition();
if(!pos)
return -1;
else
return pos->GetShapeId();
return aNode->getshapeId();
}
return -1;

View File

@ -613,9 +613,9 @@ bool StdMeshers_MEFISTO_2D::LoadPoints(TWireVector & wires,
case SMDS_TOP_EDGE:
// In order to detect degenerated faces easily, we replace
// nodes on a degenerated edge by node on the vertex of that edge
if ( myTool->IsDegenShape( uvPt->node->GetPosition()->GetShapeId() ))
if ( myTool->IsDegenShape( uvPt->node->getshapeId() ))
{
int edgeID = uvPt->node->GetPosition()->GetShapeId();
int edgeID = uvPt->node->getshapeId();
SMESH_subMesh* edgeSM = myTool->GetMesh()->GetSubMeshContaining( edgeID );
SMESH_subMeshIteratorPtr smIt = edgeSM->getDependsOnIterator( /*includeSelf=*/0,
/*complexShapeFirst=*/0);
@ -640,7 +640,7 @@ bool StdMeshers_MEFISTO_2D::LoadPoints(TWireVector & wires,
int m = *mIt;
if ( iW && !VWMap.IsEmpty()) { // except outer wire
// avoid passing same uv point for a vertex common to 2 wires
int vID = mefistoToDS[m]->GetPosition()->GetShapeId();
int vID = mefistoToDS[m]->getshapeId();
TopoDS_Vertex V = TopoDS::Vertex( myTool->GetMeshDS()->IndexToShape( vID ));
if ( fixCommonVertexUV( uvslf[m], V, F, VWMap, *myTool->GetMesh(),
scalex, scaley, _quadraticMesh )) {

View File

@ -478,7 +478,7 @@ bool StdMeshers_Prism_3D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape& theSh
if ( !myBlock.ComputeParameters( topCoords, topParams, ID_TOP_FACE, topParams ))
return error(TCom("Can't compute normalized parameters ")
<< "for node " << column.back()->GetID()
<< " on the face #"<< column.back()->GetPosition()->GetShapeId() );
<< " on the face #"<< column.back()->getshapeId() );
}
// vertical loop
@ -806,6 +806,8 @@ bool StdMeshers_Prism_3D::assocOrProjBottom2Top()
botSMDS->NbElements() != topSMDS->NbElements() ||
botSMDS->NbNodes() != topSMDS->NbNodes())
{
MESSAGE("nb elem bot " << botSMDS->NbElements() << " top " << topSMDS->NbElements());
MESSAGE("nb node bot " << botSMDS->NbNodes() << " top " << topSMDS->NbNodes());
if ( myBlock.HasNotQuadElemOnTop() )
return error(TCom("Mesh on faces #") << botSM->GetId()
<<" and #"<< topSM->GetId() << " seems different" );
@ -1208,6 +1210,7 @@ bool StdMeshers_PrismAsBlock::Init(SMESH_MesherHelper* helper,
}
myNotQuadOnTop = ( nbNotQuadMeshed > 1 );
MESSAGE("myNotQuadOnTop " << myNotQuadOnTop << " nbNotQuadMeshed " << nbNotQuadMeshed);
// ----------------------------------------------------------
@ -1364,11 +1367,11 @@ bool StdMeshers_PrismAsBlock::Init(SMESH_MesherHelper* helper,
// columns for vertices
// 1
const SMDS_MeshNode* n0 = faceColumns.begin()->second.front();
id = n0->GetPosition()->GetShapeId();
id = n0->getshapeId();
myShapeIndex2ColumnMap[ id ] = make_pair( & faceColumns, isForward );
// 2
const SMDS_MeshNode* n1 = faceColumns.rbegin()->second.front();
id = n1->GetPosition()->GetShapeId();
id = n1->getshapeId();
myShapeIndex2ColumnMap[ id ] = make_pair( & faceColumns, isForward );
// SHOWYXZ("\np1 F "<<iE, gpXYZ(faceColumns.begin()->second.front() ));
// SHOWYXZ("p2 F "<<iE, gpXYZ(faceColumns.rbegin()->second.front() ));
@ -1578,11 +1581,11 @@ bool StdMeshers_PrismAsBlock::Init(SMESH_MesherHelper* helper,
// columns for vertices
const SMDS_MeshNode* n0 = cols->begin()->second.front();
id = n0->GetPosition()->GetShapeId();
id = n0->getshapeId();
myShapeIndex2ColumnMap[ id ] = make_pair( cols, isForward );
const SMDS_MeshNode* n1 = cols->rbegin()->second.front();
id = n1->GetPosition()->GetShapeId();
id = n1->getshapeId();
myShapeIndex2ColumnMap[ id ] = make_pair( cols, !isForward );
}
}
@ -1609,7 +1612,7 @@ bool StdMeshers_PrismAsBlock::Init(SMESH_MesherHelper* helper,
const TNodeColumn* StdMeshers_PrismAsBlock::GetNodeColumn(const SMDS_MeshNode* node) const
{
int sID = node->GetPosition()->GetShapeId();
int sID = node->getshapeId();
map<int, pair< TParam2ColumnMap*, bool > >::const_iterator col_frw =
myShapeIndex2ColumnMap.find( sID );

View File

@ -1645,7 +1645,7 @@ FindMatchingNodesOnFaces( const TopoDS_Face& face1,
const SMDS_MeshElement* f = ( iF ? f2 : f1 );
for ( int i = 0; !notSeamNode[ iF ] && i < f->NbNodes(); ++i ) {
const SMDS_MeshNode* node = f->GetNode( i );
if ( !helper->IsSeamShape( node->GetPosition()->GetShapeId() ))
if ( !helper->IsSeamShape( node->getshapeId() ))
notSeamNode[ iF ] = node;
}
}

View File

@ -375,7 +375,7 @@ namespace {
const TAssocTool::TShapeShapeMap& shape2ShapeMap)
{
MESSAGE("projectPartner");
const double tol = 1e-6;
const double tol = 1.e-7*srcMesh->GetMeshDS()->getMaxDim();
gp_Trsf trsf; // transformation to get location of target nodes from source ones
if ( tgtFace.IsPartner( srcFace ))
@ -407,13 +407,13 @@ namespace {
{
case 0: pOK = true; break;
case 1: pOK = ( srcPP[0].SquareDistance( p ) > tol ); break;
case 1: pOK = ( srcPP[0].SquareDistance( p ) > 10*tol ); break;
case 2:
{
gp_Vec p0p1( srcPP[0], srcPP[1] ), p0p( srcPP[0], p );
pOK = !p0p1.IsParallel( p0p, tol );
// TODO angle pOK = !p0p1.IsParallel( p0p, 3.14/6 );
// pOK = !p0p1.IsParallel( p0p, tol );
pOK = !p0p1.IsParallel( p0p, 3.14/20 ); // angle min 18 degrees
break;
}
}
@ -436,6 +436,7 @@ namespace {
{
double srcDist = srcPP[0].Distance( p );
double eTol = BRep_Tool::Tolerance( TopoDS::Edge( tgtShape ));
if (eTol < tol) eTol = tol;
SMDS_NodeIteratorPtr nItT = tgtSmds->GetNodes();
while ( nItT->more() && !pOK )
{
@ -492,7 +493,7 @@ namespace {
if ( !tgtEdge.IsPartner( srcEdge.Current() ))
{
// check that transormation is OK by three nodes
// check that transformation is OK by three nodes
gp_Pnt p0S = SMESH_MeshEditor::TNodeXYZ( (srcNodes.begin()) ->second);
gp_Pnt p1S = SMESH_MeshEditor::TNodeXYZ( (srcNodes.rbegin()) ->second);
gp_Pnt p2S = SMESH_MeshEditor::TNodeXYZ( (++srcNodes.begin())->second);
@ -501,7 +502,7 @@ namespace {
gp_Pnt p1T = SMESH_MeshEditor::TNodeXYZ( (tgtNodes.rbegin()) ->second);
gp_Pnt p2T = SMESH_MeshEditor::TNodeXYZ( (++tgtNodes.begin())->second);
// transform source points, they must coinside with target ones
// transform source points, they must coincide with target ones
if ( p0T.SquareDistance( p0S.Transformed( trsf )) > tol ||
p1T.SquareDistance( p1S.Transformed( trsf )) > tol ||
p2T.SquareDistance( p2S.Transformed( trsf )) > tol )
@ -524,6 +525,7 @@ namespace {
// prepare the helper adding quadratic elements if necessary
SMESH_MesherHelper helper( *tgtMesh );
helper.SetSubShape( tgtFace );
helper.IsQuadraticSubMesh( tgtFace );
helper.SetElementsOnShape( true );
@ -540,6 +542,8 @@ namespace {
while ( nodeIt->more() ) // loop on nodes of the source element
{
const SMDS_MeshNode* srcNode = (const SMDS_MeshNode*) nodeIt->next();
if (elem->IsMediumNode(srcNode))
continue;
srcN_tgtN = src2tgtNodes.insert( make_pair( srcNode, nullNode )).first;
if ( srcN_tgtN->second == nullNode )
{
@ -551,10 +555,18 @@ namespace {
tgtFaceNodes.push_back( srcN_tgtN->second );
}
// create a new face (with reversed orientation)
if ( tgtFaceNodes.size() == 3 )
helper.AddFace( tgtFaceNodes[0],tgtFaceNodes[2],tgtFaceNodes[1]);
else
helper.AddFace( tgtFaceNodes[0],tgtFaceNodes[3],tgtFaceNodes[2],tgtFaceNodes[1]);
//MESSAGE("tgtFaceNodes.size() " << tgtFaceNodes.size());
switch (tgtFaceNodes.size())
{
case 3:
case 6:
helper.AddFace(tgtFaceNodes[0], tgtFaceNodes[2], tgtFaceNodes[1]);
break;
case 4:
case 8:
helper.AddFace(tgtFaceNodes[0], tgtFaceNodes[3], tgtFaceNodes[2], tgtFaceNodes[1]);
break;
}
}
return true;
}