ADD_PRISM,
ADD_HEXAHEDRON,
REMOVE_NODE,
- REMOVE_ELEMENT
+ REMOVE_ELEMENT,
+ REMOVE_ALL
};
struct log_block
}
///////////////////////////////////////////////////////////////////////////////
-///Return an iterator on volumes of the current mesh. Once used this iterator
+///Return an iterator on egdes of the current mesh. Once used this iterator
///must be free by the caller
///////////////////////////////////////////////////////////////////////////////
SMDS_Iterator<const SMDS_MeshEdge *> * SMDS_Mesh::edgesIterator() const
delete s2;
delete s1;
}
+
+/**
+ * Concat the coordinates of all nodes in an array.
+ * Its used to display the mesh.
+ * @return A array of size 3*NbNodes() containing the coordinates of nodes.
+ */
+double * SMDS_Mesh::getNodesCoordinates()
+{
+ double * toReturn=new double[3*NbNodes()];
+ SMDS_Iterator<const SMDS_MeshNode*> * it=nodesIterator();
+ int i=0;
+ while(it->more())
+ {
+ const SMDS_MeshNode * n=it->next();
+ toReturn[i]=n->X();
+ i++;
+ toReturn[i]=n->Y();
+ i++;
+ toReturn[i]=n->Z();
+ i++;
+ }
+ delete it;
+ return toReturn;
+}
+
+/**
+ * Concat the id of all nodes in an array.
+ * Its used to display the mesh.
+ * @return A array of size NbNodes() containing the ids of nodes.
+ */
+long * SMDS_Mesh::getNodesID()
+{
+ long * toReturn=new long[NbNodes()];
+ SMDS_Iterator<const SMDS_MeshNode*> * it=nodesIterator();
+ int i=0;
+ while(it->more())
+ {
+ const SMDS_MeshNode * n=it->next();
+ toReturn[i]=n->GetID();
+ i++;
+ }
+ delete it;
+ return toReturn;
+}
+
+/**
+ * Concat the id of nodes of edges in an array.
+ * Array format is {edge_id, node1_id, node2_id}
+ * Its used to display the mesh.
+ * @return A array of size 3*NbEdges() containing the edges.
+ */
+long * SMDS_Mesh::getEdgesIndices()
+{
+ long * toReturn=new long[NbEdges()*3];
+ SMDS_Iterator<const SMDS_MeshEdge*> * it=edgesIterator();
+ int i=0;
+
+ while(it->more())
+ {
+ const SMDS_MeshEdge * e=it->next();
+ toReturn[i]=e->GetID();
+ i++;
+ SMDS_Iterator<const SMDS_MeshElement*> * itn=e->nodesIterator();
+ while(itn->more())
+ {
+ const SMDS_MeshElement * n=itn->next();
+ toReturn[i]=n->GetID();
+ i++;
+ }
+ delete itn;
+ }
+ delete it;
+ return toReturn;
+}
+
+/**
+ * Concat the id of nodes of triangles in an array.
+ * Array format is {tria_id, node1_id, node2_id, node3_id}
+ * Its used to display the mesh.
+ * @return A array of size 4*NbTriangles() containing the edges.
+ */
+long * SMDS_Mesh::getTrianglesIndices()
+{
+ long * toReturn=new long[NbTriangles()*4];
+ SMDS_Iterator<const SMDS_MeshFace*> * it=facesIterator();
+ int i=0;
+ while(it->more())
+ {
+ const SMDS_MeshFace * f=it->next();
+ if(f->NbNodes()==3)
+ {
+ toReturn[i]=f->GetID();
+ i++;
+ SMDS_Iterator<const SMDS_MeshElement*> * itn=f->nodesIterator();
+ while(itn->more())
+ {
+ const SMDS_MeshElement * n=itn->next();
+ toReturn[i]=n->GetID();
+ i++;
+ }
+ delete itn;
+ }
+ }
+ delete it;
+ return toReturn;
+}
+
+/**
+ * Return the number of 3 nodes faces in the mesh.
+ * This method run in O(n).
+ * @return The number of face whose number of nodes is 3
+ */
+int SMDS_Mesh::NbTriangles() const
+{
+ SMDS_Iterator<const SMDS_MeshFace*> * it=facesIterator();
+ int toReturn=0;
+ while(it->more())
+ {
+ const SMDS_MeshFace * f=it->next();
+ if(f->NbNodes()==3) toReturn++;
+ }
+ return toReturn;
+}
int NbNodes() const;
int NbEdges() const;
int NbFaces() const;
+ int NbTriangles() const;
int NbVolumes() const;
int NbSubMesh() const;
void DumpNodes() const;
void setConstructionFaces(bool);
void setInverseElements(bool);
+ double * getNodesCoordinates();
+ long * getNodesID();
+ long * getEdgesIndices();
+ long * getTrianglesIndices();
+
private:
SMDS_Mesh(SMDS_Mesh * parent);
SMDS_MeshFace * createTriangle(SMDS_MeshNode * node1,
//=============================================================================
/*!
- *
+ * @TODO Doing a full update after computation is not optimal when doing a local
+ * remeshing.
*/
//=============================================================================
/*
Algo : s'appuie ou non sur une geometrie
Si geometrie:
-Vertex : rien à faire (range le point)
+Vertex : rien �faire (range le point)
Edge, Wire, collection d'edge et wire : 1D
Face, Shell, collection de Face et Shells : 2D
Solid, Collection de Solid : 3D
smToCompute = sm->GetFirstToCompute();
}
+ aMesh.GetMeshDS()->logFullUpdate();
+
return ret;
}
reader->SetFile(string(fileName));
reader->Read();
+ mesh->GetMeshDS()->logFullUpdate();
+
return mesh;
}
#include "SMESHDS_CommandType.hxx"
#include <list>
+using namespace std;
class SMESHDS_Command
{
SMESHDS_AddHexahedron,
SMESHDS_RemoveNode,
SMESHDS_RemoveElement,
-SMESHDS_MoveNode
+SMESHDS_MoveNode,
+SMESHDS_UpdateAll
};
SMESHDS_Mesh::~SMESHDS_Mesh()
{
}
+
+/**
+ * Add FULL_UPDATE command to the log of this mesh. Once interpreted by the
+ * graphical client it will (re)draw the full mesh.
+ */
+void SMESHDS_Mesh::logFullUpdate()
+{
+ myScript->UpdateAll();
+}
void SetNodeOnVertex(SMDS_MeshNode * aNode, int Index);
void SetMeshElementOnShape(const SMDS_MeshElement * anElt, int Index);
~SMESHDS_Mesh();
-
+ void logFullUpdate();
+
private:
struct HashTopoDS_Shape
{
// Module : SMESH
// $Header:
-using namespace std;
#include "SMESHDS_Script.hxx"
//=======================================================================
{
return myCommands;
}
+
+/**
+ * Add UpdateAll command to the log of this mesh. Once interpreted by the
+ * graphical client it will (re)draw the full mesh.
+ */
+void SMESHDS_Script::UpdateAll()
+{
+ myCommands.insert(myCommands.end(), new SMESHDS_Command(SMESHDS_UpdateAll));
+}
void RemoveElement(int ElementID);
void Clear();
const list<SMESHDS_Command*> & GetCommands();
+ void UpdateAll();
~SMESHDS_Script();
private:
return false;
}
-//=============================================================================
-/*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
- * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
+/**
+ * Ensures that the actor for the given <theIO> exists in the active VTK view
+ * @TODO Handle multiple selection.
*/
-//=============================================================================
void SMESHGUI::BuildPresentation(const Handle(SALOME_InteractiveObject) & theIO)
{
+ MESSAGE("SMESHGUI::BuildPresentation("<<theIO->getEntry()<<")");
/* Create or retrieve an object SMESHGUI */
SMESHGUI::GetOrCreateSMESHGUI(QAD_Application::getDesktop());
if (activeFrame->getTypeView() == VIEW_VTK)
{
// VTK
- SALOMEDS::SObject_var fatherSF =
+ // Some ideas to handle multiple selection...
+ /*SALOMEDS::SObject_var fatherSF =
smeshGUI->myStudy->FindObjectID(activeFrame->entry());
SALOME_Selection *Sel =
getSelection());
SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
-// for(;It.More();It.Next()) {
-// Handle(SALOME_InteractiveObject) IObject = It.Value();
+ for(;It.More();It.Next()) {
+ Handle(SALOME_InteractiveObject) IObject = It.Value();*/
Handle(SALOME_InteractiveObject) IObject = theIO;
if (IObject->hasEntry())
{
Standard_Boolean res;
SMESH_Actor *ac =
smeshGUI->FindActorByEntry(IObject->getEntry(), res, false);
-
- // Actor not found at all -> mesh is not computed -> do nothing!!!
+
if (!res)
{
- /*SMESH::SMESH_Mesh_var aM;
- * SALOMEDS::SObject_var aMorSM = smeshGUI->myStudy->FindObjectID( IObject->getEntry() );
- * SALOMEDS::SObject_var father = aMorSM->GetFather();
- * SALOMEDS::SObject_var fatherComp = aMorSM->GetFatherComponent();
- *
- * // Non-displayable objects (Hypo, Algo) have tags < 3 or have a father different from component
- * if (aMorSM->Tag() < 3 || strcmp(father->GetID(), fatherComp->GetID()) != 0)
- * continue;
- *
- * SALOMEDS::GenericAttribute_var anAttr;
- * SALOMEDS::AttributeIOR_var anIOR;
- * if ( !aMorSM->_is_nil() ) {
- * if (aMorSM->FindAttribute(anAttr, "AttributeIOR") ) {
- * anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- * aM = SMESH::SMESH_Mesh::_narrow( _orb->string_to_object(anIOR->Value()) );
- * }
- * }
- *
- * if (!aM->_is_nil()) {
- * smeshGUI->InitActor(aM);
- * ac = smeshGUI->ReadScript(aM);
- * }
- *
- * if (ac) {
- * smeshGUI->DisplayActor( ac, true );
- * smeshGUI->DisplayEdges( ac );
- * smeshGUI->ChangeRepresentation( ac, ac->getDisplayMode() );
- * } */
-// continue;
+ SALOMEDS::SObject_var aMorSM=smeshGUI->myStudy->FindObjectID( IObject->getEntry());
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeIOR_var anIOR;
+ if(aMorSM->FindAttribute(anAttr, "AttributeIOR"))
+ {
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ SMESH::SMESH_Mesh_var aM =
+ SMESH::SMESH_Mesh::_narrow( _orb->string_to_object(anIOR->Value()));
+ if(!aM->_is_nil())
+ {
+ smeshGUI->InitActor(aM);
+ ac = smeshGUI->ReadScript(aM);
+ smeshGUI->DisplayActor( ac, true );
+ smeshGUI->DisplayEdges( ac );
+ smeshGUI->ChangeRepresentation( ac, ac->getDisplayMode() );
+ }
+ else
+ {
+ MESSAGE("Do not know how to display something which is not a SMESH_Mesh");
+ }
+ }
+ else
+ {
+ MESSAGE("The object "<<theIO->getEntry()<<
+ " do not have \"AttributeIOR\" attribute");
+ }
}
else
- { // The actor exists in some view
+ {
+ // The actor exists in some view
// Check whether the actor belongs to the active view
VTKViewer_RenderWindowInteractor *rwInter =
((VTKViewer_ViewFrame *) activeFrame->getRightFrame()->
smeshGUI->ChangeRepresentation(ac, ac->getDisplayMode());
}
}
-// }
}
else
{
- MESSAGE
- ("BuildPresentation() must not be called while non-VTK view is active")}
+ MESSAGE("BuildPresentation() must not be called while non-VTK view is active");
+ }
}
//=============================================================================
ASSERT(!CORBA::is_nil(_orb));
}
-//=============================================================================
-/*!
- *
+/**
+ * Get the history of all commands made in the SMESH server. This list of command
+ * is used to display the mesh in the VTK view
+ * @TODO Handle the REMOVE_ALL command.
*/
-//=============================================================================
SMESH_Actor *SMESHGUI::ReadScript(SMESH::SMESH_Mesh_ptr aMesh)
{
+ MESSAGE("SMESHGUI::ReadScript");
SMESH_Actor *MeshActor;
if (!aMesh->_is_nil())
{
if (result)
{
SMESH::log_array_var aSeq = aMesh->GetLog(true);
-
- if (aSeq->length() == 0)
- {
- MESSAGE("ReadScript(): log is empty") return MeshActor;
- }
+ MESSAGE("SMESHGUI::ReadScript: The log contains "<<aSeq->length()
+ <<" commands.");
for (unsigned int ind = 0; ind < aSeq->length(); ind++)
{
aSeq[ind].coords, aSeq[ind].indexes);
break;
}
+ case SMESH::REMOVE_ALL:
+ MESSAGE("REMOVE_ALL command not yet implemented");
+ break;
+ default: MESSAGE("Warning: Unknown script command.");
}
}
return MeshActor;
void SMESHGUI::AddNodes(SMESH_Actor * Mactor, int number,
const SMESH::double_array & coords, const SMESH::long_array & indexes)
{
+ MESSAGE("SMESHGUI::AddNodes(number="<<number<<")");
QApplication::setOverrideCursor(Qt::waitCursor);
if (Mactor->GetMapper() == NULL)
{
float z)
{
QApplication::setOverrideCursor(Qt::waitCursor);
- MESSAGE("SMESHGUI::AddNode " << idnode << " : " << x << ";" << y << ";" <<
- z) if (Mactor->GetMapper() == NULL)
+ MESSAGE("SMESHGUI::AddNode " << idnode << " : " << x << ";" << y << ";" << z);
+
+ if (Mactor->GetMapper() == NULL)
{
vtkPoints *Pts = vtkPoints::New();
int idVTK = Pts->InsertNextPoint(x, y, z);
void SMESHGUI::AddTriangles(SMESH_Actor * Mactor, int number,
const SMESH::double_array & coords, const SMESH::long_array & indexes)
{
+ MESSAGE("SMESHGUI::AddTriangles(number="<<number<<")");
QApplication::setOverrideCursor(Qt::waitCursor);
//vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
//=============================================================================
void SMESHGUI::Update()
{
+ MESSAGE("SMESHGUI::Update");
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK)
{ //VTK
vtkRenderer *theRenderer =
myReader->SetMeshId(myMeshId);
myReader->SetFile(datafilename);
myReader->Read();
+ mySMESHDSMesh->logFullUpdate();
MESSAGE("Loaded a mesh with " << mySMESHDSMesh->NbNodes() <<" nodes");
}
}
return ret;
};
-//=============================================================================
-/*!
- *
+/**
+ *@TODO Not implemented
*/
-//=============================================================================
-
SMESH::ListOfHypothesis *
SMESH_Mesh_i::GetHypothesisList(GEOM::GEOM_Shape_ptr aSubShape)
throw(SALOME::SALOME_Exception)
{
- MESSAGE("GetHypothesisList");
- // ****
+ MESSAGE("GetHypothesisList: Not implemented");
+ return NULL;
};
//=============================================================================
return SMESH::SMESH_subMesh::_duplicate(_mapSubMeshIor[subMeshId]);
}
-//=============================================================================
-/*!
- *
+/**
+ * Translate the UpdateAll SMESHDS_Command to a set of SMESH::log_command.
+ * As the input log need to be resized, it is realocated.
+ * @param logBlock The log where to insert created commands
+ * @param index The place where to insert created commands in log
+ * @return The realocated and resized log.
+ * @TODO Add support for other type of elements
*/
-//=============================================================================
+SMESH::log_array_var SMESH_Mesh_i::
+ createUpdateAllCommand(SMESH::log_array_var log, int * index)
+{
+ MESSAGE("SMESH_Mesh_i::createUpdateAllCommand");
+ SMESH::log_array_var aLog=new SMESH::log_array(log->length()+4);
+ aLog->length(log->length()+4);
+
+ for(int i=0;i<*index;i++)
+ {
+ aLog[i]=log[i];
+ }
+
+ log->length(0);
+ int id=*index;
+
+ //Remove all elements
+ aLog[id].commandType=SMESH::REMOVE_ALL;
+ id++;
+
+ //Export nodes
+ aLog[id].commandType=SMESH::ADD_NODE;
+ aLog[id].number=_impl->GetMeshDS()->NbNodes();
+
+ double * nodesCoordinates=_impl->GetMeshDS()->getNodesCoordinates();
+ aLog[id].coords=SMESH::double_array(
+ aLog[id].number*3,
+ aLog[id].number*3,
+ nodesCoordinates);
+
+ long * nodesID=_impl->GetMeshDS()->getNodesID();
+ aLog[id].indexes=SMESH::long_array(
+ aLog[id].number,
+ aLog[id].number,
+ nodesID);
+
+ id++;
+
+ MESSAGE("Export edges");
+ //Export edges
+ aLog[id].commandType=SMESH::ADD_EDGE;
+ aLog[id].number=_impl->GetMeshDS()->NbEdges();
+ aLog[id].coords.length(0);
+
+ long * edgesIndices=_impl->GetMeshDS()->getEdgesIndices();
+ aLog[id].indexes=SMESH::long_array(
+ aLog[id].number*3,
+ aLog[id].number*3,
+ edgesIndices);
+
+ id++;
+
+ MESSAGE("Export triangles");
+ //Export triangles
+ aLog[id].commandType=SMESH::ADD_TRIANGLE;
+ aLog[id].number=_impl->GetMeshDS()->NbTriangles();
+ aLog[id].coords.length(0);
+
+ long * triasIndices=_impl->GetMeshDS()->getTrianglesIndices();
+ aLog[id].indexes=SMESH::long_array(
+ aLog[id].number*4,
+ aLog[id].number*4,
+ triasIndices);
+
+ (*index)+=4;
+ return aLog;
+}
+/**
+ * Return the log of the current mesh. CORBA wrap of the SMESH::GetLog method
+ * with a special treatment for SMESHDS_UpdateAll commands
+ * @param clearAfterGet Tell if the log must be cleared after being returned
+ * @return the log
+ */
SMESH::log_array * SMESH_Mesh_i::GetLog(CORBA::Boolean clearAfterGet)
-throw(SALOME::SALOME_Exception)
+ throw(SALOME::SALOME_Exception)
{
MESSAGE("SMESH_Mesh_i::GetLog");
SMESH::log_array_var aLog;
- try
- {
+ /*try
+ {*/
list < SMESHDS_Command * >logDS = _impl->GetLog();
aLog = new SMESH::log_array;
int indexLog = 0;
int lg = logDS.size();
- SCRUTE(lg);
+ MESSAGE("Number of command in the log: "<<lg);
aLog->length(lg);
list < SMESHDS_Command * >::iterator its = logDS.begin();
while (its != logDS.end())
//SCRUTE(rnum);
list < double >::const_iterator ir = coordList.begin();
aLog[indexLog].commandType = comType;
- aLog[indexLog].number = lgcom;
- aLog[indexLog].coords.length(rnum);
- aLog[indexLog].indexes.length(inum);
- for (int i = 0; i < rnum; i++)
+ if(comType==SMESHDS_UpdateAll)
{
- aLog[indexLog].coords[i] = *ir;
- //MESSAGE(" "<<i<<" "<<ir.Value());
- ir++;
+ aLog=createUpdateAllCommand(aLog, &indexLog);
}
- for (int i = 0; i < inum; i++)
+ else
{
- aLog[indexLog].indexes[i] = *ii;
- //MESSAGE(" "<<i<<" "<<ii.Value());
- ii++;
- }
- indexLog++;
+ aLog[indexLog].number = lgcom;
+ aLog[indexLog].coords.length(rnum);
+ aLog[indexLog].indexes.length(inum);
+ for (int i = 0; i < rnum; i++)
+ {
+ aLog[indexLog].coords[i] = *ir;
+ //MESSAGE(" "<<i<<" "<<ir.Value());
+ ir++;
+ }
+ for (int i = 0; i < inum; i++)
+ {
+ aLog[indexLog].indexes[i] = *ii;
+ //MESSAGE(" "<<i<<" "<<ii.Value());
+ ii++;
+ }
+ indexLog++;
+ }
its++;
}
- if (clearAfterGet)
- _impl->ClearLog();
- }
+ if (clearAfterGet) _impl->ClearLog();
+ return aLog._retn();
+ /*}
catch(SALOME_Exception & S_ex)
{
THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
- }
- return aLog._retn();
+ }*/
}
// SMESH::string_array* SMESH_Mesh_i::GetLog(CORBA::Boolean clearAfterGet)
map<int, ::SMESH_subMesh*> _mapSubMesh; //NRI
private:
-
+ SMESH::log_array_var createUpdateAllCommand(SMESH::log_array_var log, int * index);
::SMESH_Mesh* _impl; // :: force no namespace here
SMESH_Gen_i* _gen_i;
// CORBA::ORB_ptr _orb;