{
bool aShowFaceOrientation = myIsFacesOriented;
aShowFaceOrientation &= vtkLODActor::GetVisibility(); //GetVisibility(); -- avoid calling GetUnstructuredGrid()
- aShowFaceOrientation &= myRepresentation == eSurface;
+ aShowFaceOrientation &= ( myRepresentation != ePoint );
myFaceOrientation->SetVisibility(aShowFaceOrientation);
}
return found;
}
+//=======================================================================
+//function : ChangePolyhedronNodes
+//purpose :
+//=======================================================================
+
+bool SMDS_Mesh::ChangePolyhedronNodes(const SMDS_MeshElement * element,
+ const std::vector<const SMDS_MeshNode*>& nodes,
+ const std::vector<int>& quantities)
+{
+ // keep current nodes of element
+ std::set<const SMDS_MeshNode*> oldNodes( element->begin_nodes(), element->end_nodes() );
+
+ // change nodes
+ bool Ok = false;
+ if ( const SMDS_MeshVolume* vol = DownCast<SMDS_MeshVolume>( element ))
+ Ok = vol->ChangeNodes( nodes, quantities );
+
+ if ( Ok )
+ {
+ setMyModified();
+ updateInverseElements( element, &nodes[0], nodes.size(), oldNodes );
+ }
+ return Ok;
+}
+
//=======================================================================
//function : ChangeElementNodes
//purpose :
Ok = cell->ChangeNodes(nodes, nbnodes);
if ( Ok )
+ {
setMyModified();
+ updateInverseElements( element, nodes, nbnodes, oldNodes );
+ }
+ return Ok;
+}
+
+//=======================================================================
+//function : updateInverseElements
+//purpose : update InverseElements when element changes node
+//=======================================================================
- if ( Ok && GetGrid()->HasLinks() ) // update InverseElements
+void SMDS_Mesh::updateInverseElements( const SMDS_MeshElement * element,
+ const SMDS_MeshNode* const* nodes,
+ const int nbnodes,
+ std::set<const SMDS_MeshNode*>& oldNodes )
+{
+ if ( GetGrid()->HasLinks() ) // update InverseElements
{
std::set<const SMDS_MeshNode*>::iterator it;
// AddInverseElement to new nodes
- for ( int i = 0; i < nbnodes; i++ ) {
+ for ( int i = 0; i < nbnodes; i++ )
+ {
it = oldNodes.find( nodes[i] );
if ( it == oldNodes.end() )
// new node
}
}
- return Ok;
}
const SMDS_Mesh0DElement* SMDS_Mesh::Find0DElement(const SMDS_MeshNode * node)
bool ChangeElementNodes(const SMDS_MeshElement * elem,
const SMDS_MeshNode * nodes[],
const int nbnodes);
+ bool ChangePolyhedronNodes(const SMDS_MeshElement * elem,
+ const std::vector<const SMDS_MeshNode*>& nodes,
+ const std::vector<int>& quantities);
//virtual void Renumber (const bool isNodes, const int startID = 1, const int deltaID = 1);
// Renumber all nodes or elements.
void Modified();
vtkMTimeType GetMTime() const;
-protected:
+ protected:
SMDS_Mesh(SMDS_Mesh * parent);
void addChildrenWithNodes(std::set<const SMDS_MeshElement*>& setOfChildren,
else if (z < zmin) zmin = z;
}
+ void updateInverseElements( const SMDS_MeshElement * element,
+ const SMDS_MeshNode* const* nodes,
+ const int nbnodes,
+ std::set<const SMDS_MeshNode*>& oldNodes );
+
void setNbShapes( size_t nbShapes );
SMDS_MeshCell::init( aType, vtkNodeIds );
}
+bool SMDS_MeshVolume::ChangeNodes(const std::vector<const SMDS_MeshNode*>& nodes,
+ const std::vector<int>& quantities) const
+{
+ if ( !IsPoly() )
+ return false;
+
+ vtkIdType nFaces = 0;
+ vtkIdType* ptIds = 0;
+ getGrid()->GetFaceStream( GetVtkID(), nFaces, ptIds );
+
+ // stream size and nb faces should not change
+
+ if ((int) quantities.size() != nFaces )
+ {
+ return false;
+ }
+ int id = 0, nbPoints = 0;
+ for ( int i = 0; i < nFaces; i++ )
+ {
+ int nodesInFace = ptIds[id];
+ nbPoints += nodesInFace;
+ id += (nodesInFace + 1);
+ }
+ if ((int) nodes.size() != nbPoints )
+ {
+ return false;
+ }
+
+ // update ptIds
+ size_t iP = 0, iN = 0;
+ for ( size_t i = 0; i < quantities.size(); ++i )
+ {
+ ptIds[ iP++ ] = quantities[ i ]; // nb face nodes
+ for ( int j = 0; j < quantities[ i ]; ++j )
+ ptIds[ iP++ ] = nodes[ iN++ ]->GetVtkID();
+ }
+ return true;
+}
+
const SMDS_MeshNode* SMDS_MeshVolume::GetNode(const int ind) const
{
if ( !IsPoly() )
virtual SMDS_ElemIteratorPtr nodesIterator() const = 0;
virtual SMDS_NodeIteratorPtr nodeIterator() const = 0;
+ bool ChangeNodes(const std::vector<const SMDS_MeshNode*>& nodes,
+ const std::vector<int>& quantities) const;
+
// 1 <= face_ind <= NbFaces()
int NbFaceNodes (const int face_ind) const;
+
// 1 <= face_ind <= NbFaces()
// 1 <= node_ind <= NbFaceNodes()
const SMDS_MeshNode* GetFaceNode (const int face_ind, const int node_ind) const;
i++;
for (int k = 0; k < nbnodes; k++)
{
- setOfNodes.insert(pts[i]);
+ if ( setOfNodes.insert( pts[i] ).second )
+ {
+ this->Links->ResizeCellList( pts[i], 1 );
+ this->Links->AddCellReference( cellid, pts[i] );
+ }
i++;
}
}
- std::set<vtkIdType>::iterator it = setOfNodes.begin();
- for (; it != setOfNodes.end(); ++it)
- {
- this->Links->ResizeCellList(*it, 1);
- this->Links->AddCellReference(cellid, *it);
- }
-
return cellid;
}
//=======================================================================
//function : ChangePolyhedronNodes
-//purpose :
+//purpose :
//=======================================================================
-bool SMESHDS_Mesh::ChangePolyhedronNodes
-(const SMDS_MeshElement * elem,
- std::vector<const SMDS_MeshNode*> nodes,
- std::vector<int> quantities)
+bool SMESHDS_Mesh
+::ChangePolyhedronNodes (const SMDS_MeshElement * elem,
+ const std::vector<const SMDS_MeshNode*>& nodes,
+ const std::vector<int> & quantities)
{
ASSERT(nodes.size() > 3);
- //if (!SMDS_Mesh::ChangePolyhedronNodes(elem, nodes, quantities))
- return false;
+ if ( !SMDS_Mesh::ChangePolyhedronNodes( elem, nodes, quantities ))
+ return false;
int i, len = nodes.size();
std::vector<int> nodes_ids (len);
//=======================================================================
//function : Renumber
-//purpose :
+//purpose :
//=======================================================================
void SMESHDS_Mesh::Renumber (const bool isNodes, const int startID, const int deltaID)
const int nbnodes);
bool ChangePolygonNodes(const SMDS_MeshElement * elem,
std::vector<const SMDS_MeshNode*> nodes);
- bool ChangePolyhedronNodes(const SMDS_MeshElement * elem,
- std::vector<const SMDS_MeshNode*> nodes,
- std::vector<int> quantities);
+ bool ChangePolyhedronNodes(const SMDS_MeshElement * elem,
+ const std::vector<const SMDS_MeshNode*>& nodes,
+ const std::vector<int>& quantities);
bool ModifyCellNodes(int smdsVolId, std::map<int,int> localClonedNodeIds);
void Renumber (const bool isNodes, const int startID=1, const int deltaID=1);
isOut( intPnt[1].myNode, planeNormal, intPnt[1].myIsOutPln, 1 );
const Segment * closeSeg[2] = { 0, 0 };
if ( intPnt[0].myIsOutPln[0] )
- closeSeg[0] = findTooCloseSegment( intPnt[0], 0.5 * theWidth - tol, tol,
+ closeSeg[0] = findTooCloseSegment( intPnt[0], 0.5 * theWidth - 1e-3*tol, tol,
segment, n1, segmentsOfNode );
if ( intPnt[1].myIsOutPln[0] )
- closeSeg[1] = findTooCloseSegment( intPnt[1], 0.5 * theWidth - tol, tol,
+ closeSeg[1] = findTooCloseSegment( intPnt[1], 0.5 * theWidth - 1e-3*tol, tol,
segment, n1, segmentsOfNode );
int nbCut = bool( closeSeg[0] ) + bool( closeSeg[1] );
if ( nbCut == 0 )