From 2d46bce2985c40bfac0593abad88d590a8efca48 Mon Sep 17 00:00:00 2001 From: jrt Date: Thu, 4 Sep 2003 07:14:51 +0000 Subject: [PATCH] Remove Opencascade dependencies. Change to STL. --- src/SMESHDS/Makefile.in | 71 +--- src/SMESHDS/SMESHDS_Command.cxx | 313 +++++++-------- src/SMESHDS/SMESHDS_Command.hxx | 143 ++----- src/SMESHDS/SMESHDS_Document.cxx | 127 +++--- src/SMESHDS/SMESHDS_Document.hxx | 151 ++------ src/SMESHDS/SMESHDS_Hypothesis.cxx | 6 +- src/SMESHDS/SMESHDS_Hypothesis.hxx | 10 +- src/SMESHDS/SMESHDS_Mesh.cxx | 595 +++++++++++++---------------- src/SMESHDS/SMESHDS_Mesh.hxx | 242 ++++-------- src/SMESHDS/SMESHDS_Script.cxx | 406 ++++++++++---------- src/SMESHDS/SMESHDS_Script.hxx | 126 ++---- src/SMESHDS/SMESHDS_SubMesh.cxx | 93 ++--- src/SMESHDS/SMESHDS_SubMesh.hxx | 147 ++----- 13 files changed, 941 insertions(+), 1489 deletions(-) diff --git a/src/SMESHDS/Makefile.in b/src/SMESHDS/Makefile.in index b83adba02..bc62fc4ca 100644 --- a/src/SMESHDS/Makefile.in +++ b/src/SMESHDS/Makefile.in @@ -36,36 +36,13 @@ VPATH=.:@srcdir@:@top_srcdir@/idl # Libraries targets LIB = libSMESHDS.la -LIB_SRC = SMESHDS_DataMapIteratorOfDataMapOfIntegerMesh_0.cxx \ - SMESHDS_DataMapIteratorOfDataMapOfIntegerPtrHypothesis_0.cxx \ - SMESHDS_DataMapIteratorOfDataMapOfShapeListOfPtrHypothesis_0.cxx \ - SMESHDS_DataMapIteratorOfDataMapOfShapeSubMesh_0.cxx \ - SMESHDS_DataMapIteratorOfDataMapOfIntegerSubMesh_0.cxx \ - SMESHDS_DataMapNodeOfDataMapOfIntegerMesh_0.cxx \ - SMESHDS_DataMapNodeOfDataMapOfIntegerPtrHypothesis_0.cxx \ - SMESHDS_DataMapNodeOfDataMapOfShapeListOfPtrHypothesis_0.cxx \ - SMESHDS_DataMapNodeOfDataMapOfShapeSubMesh_0.cxx \ - SMESHDS_DataMapNodeOfDataMapOfIntegerSubMesh_0.cxx \ - SMESHDS_DataMapOfIntegerMesh_0.cxx \ - SMESHDS_DataMapOfIntegerPtrHypothesis_0.cxx \ - SMESHDS_DataMapOfShapeListOfPtrHypothesis_0.cxx \ - SMESHDS_DataMapOfShapeSubMesh_0.cxx \ - SMESHDS_DataMapOfIntegerSubMesh_0.cxx \ +LIB_SRC = \ SMESHDS_Document.cxx \ SMESHDS_Hypothesis.cxx \ - SMESHDS_ListIteratorOfListOfAsciiString_0.cxx \ - SMESHDS_ListIteratorOfListOfPtrHypothesis_0.cxx \ - SMESHDS_ListIteratorOfListOfCommand_0.cxx \ - SMESHDS_ListNodeOfListOfAsciiString_0.cxx \ - SMESHDS_ListNodeOfListOfPtrHypothesis_0.cxx \ - SMESHDS_ListNodeOfListOfCommand_0.cxx \ - SMESHDS_ListOfAsciiString_0.cxx \ - SMESHDS_ListOfPtrHypothesis_0.cxx \ - SMESHDS_ListOfCommand_0.cxx \ - SMESHDS_Mesh.cxx \ SMESHDS_Script.cxx \ SMESHDS_Command.cxx \ - SMESHDS_SubMesh.cxx + SMESHDS_SubMesh.cxx \ + SMESHDS_Mesh.cxx LIB_CLIENT_IDL = LIB_SERVER_IDL = @@ -77,47 +54,10 @@ BIN_CLIENT_IDL = BIN_SERVER_IDL = # header files -EXPORT_HEADERS= Handle_SMESHDS_DataMapNodeOfDataMapOfIntegerMesh.hxx \ - Handle_SMESHDS_DataMapNodeOfDataMapOfIntegerPtrHypothesis.hxx \ - Handle_SMESHDS_DataMapNodeOfDataMapOfShapeListOfPtrHypothesis.hxx \ - Handle_SMESHDS_DataMapNodeOfDataMapOfShapeSubMesh.hxx \ - Handle_SMESHDS_DataMapNodeOfDataMapOfIntegerSubMesh.hxx \ - Handle_SMESHDS_Document.hxx \ - Handle_SMESHDS_ListNodeOfListOfAsciiString.hxx \ - Handle_SMESHDS_ListNodeOfListOfPtrHypothesis.hxx \ - Handle_SMESHDS_ListNodeOfListOfCommand.hxx \ - Handle_SMESHDS_Mesh.hxx \ - Handle_SMESHDS_Script.hxx \ - Handle_SMESHDS_Command.hxx \ - Handle_SMESHDS_SubMesh.hxx \ - SMESHDS_DataMapIteratorOfDataMapOfIntegerMesh.hxx \ - SMESHDS_DataMapIteratorOfDataMapOfIntegerPtrHypothesis.hxx \ - SMESHDS_DataMapIteratorOfDataMapOfShapeListOfPtrHypothesis.hxx \ - SMESHDS_DataMapIteratorOfDataMapOfShapeSubMesh.hxx \ - SMESHDS_DataMapIteratorOfDataMapOfIntegerSubMesh.hxx \ - SMESHDS_DataMapNodeOfDataMapOfIntegerMesh.hxx \ - SMESHDS_DataMapNodeOfDataMapOfIntegerPtrHypothesis.hxx \ - SMESHDS_DataMapNodeOfDataMapOfShapeListOfPtrHypothesis.hxx \ - SMESHDS_DataMapNodeOfDataMapOfShapeSubMesh.hxx \ - SMESHDS_DataMapNodeOfDataMapOfIntegerSubMesh.hxx \ - SMESHDS_DataMapOfIntegerMesh.hxx \ - SMESHDS_DataMapOfIntegerPtrHypothesis.hxx \ - SMESHDS_DataMapOfShapeListOfPtrHypothesis.hxx \ - SMESHDS_DataMapOfShapeSubMesh.hxx \ - SMESHDS_DataMapOfIntegerSubMesh.hxx \ +EXPORT_HEADERS= \ SMESHDS_Document.hxx \ SMESHDS_Hypothesis.hxx \ - SMESHDS_ListIteratorOfListOfAsciiString.hxx \ - SMESHDS_ListIteratorOfListOfPtrHypothesis.hxx \ - SMESHDS_ListIteratorOfListOfCommand.hxx \ - SMESHDS_ListNodeOfListOfAsciiString.hxx \ - SMESHDS_ListNodeOfListOfPtrHypothesis.hxx \ - SMESHDS_ListNodeOfListOfCommand.hxx \ - SMESHDS_ListOfAsciiString.hxx \ - SMESHDS_ListOfPtrHypothesis.hxx \ - SMESHDS_ListOfCommand.hxx \ SMESHDS_Mesh.hxx \ - SMESHDS_PtrHypothesis.hxx \ SMESHDS_Script.hxx \ SMESHDS_Command.hxx \ SMESHDS_CommandType.hxx \ @@ -126,7 +66,7 @@ EXPORT_HEADERS= Handle_SMESHDS_DataMapNodeOfDataMapOfIntegerMesh.hxx \ # additionnal information to compil and link file CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome -LDFLAGS += $(OCC_LIBS) +LDFLAGS += $(OCC_KERNEL_LIBS) # additional file to be cleaned @@ -135,4 +75,3 @@ CLEAN = DISTCLEAN = @CONCLUDE@ - diff --git a/src/SMESHDS/SMESHDS_Command.cxx b/src/SMESHDS/SMESHDS_Command.cxx index 64b85565e..05f529d0e 100644 --- a/src/SMESHDS/SMESHDS_Command.cxx +++ b/src/SMESHDS/SMESHDS_Command.cxx @@ -27,246 +27,229 @@ // $Header: using namespace std; -#include "SMESHDS_Command.ixx" -#include "SMESHDS_CommandType.hxx" +#include "SMESHDS_Command.hxx" #include "utilities.h" //======================================================================= //function : //purpose : //======================================================================= -SMESHDS_Command::SMESHDS_Command(const SMESHDS_CommandType aType) - : myType(aType), myNumber(0) -{} +SMESHDS_Command::SMESHDS_Command(const SMESHDS_CommandType aType):myType(aType), +myNumber(0) +{ +} //======================================================================= //function : //purpose : //======================================================================= -void SMESHDS_Command::AddNode(const Standard_Integer NewNodeID, - const Standard_Real x, - const Standard_Real y, - const Standard_Real z) +void SMESHDS_Command::AddNode(int NewNodeID, double x, double y, double z) { - if (!myType == SMESHDS_AddNode) { - MESSAGE("SMESHDS_Command::AddNode : Bad Type"); - return; - } - myIntegers.Append(NewNodeID); - myReals.Append(x); - myReals.Append(y); - myReals.Append(z); - myNumber++; + if (!myType == SMESHDS_AddNode) + { + MESSAGE("SMESHDS_Command::AddNode : Bad Type"); + return; + } + myIntegers.push_back(NewNodeID); + myReals.push_back(x); + myReals.push_back(y); + myReals.push_back(z); + myNumber++; } //======================================================================= //function : //purpose : //======================================================================= -void SMESHDS_Command::MoveNode(const Standard_Integer NodeID, - const Standard_Real x, - const Standard_Real y, - const Standard_Real z) +void SMESHDS_Command::MoveNode(int NodeID, double x, double y, double z) { - if (!myType == SMESHDS_MoveNode) { - MESSAGE("SMESHDS_Command::MoveNode : Bad Type"); - return; - } - myIntegers.Append(NodeID); - myReals.Append(x); - myReals.Append(y); - myReals.Append(z); - myNumber++; + if (!myType == SMESHDS_MoveNode) + { + MESSAGE("SMESHDS_Command::MoveNode : Bad Type"); + return; + } + myIntegers.push_back(NodeID); + myReals.push_back(x); + myReals.push_back(y); + myReals.push_back(z); + myNumber++; } //======================================================================= //function : //purpose : //======================================================================= -void SMESHDS_Command::AddEdge(const Standard_Integer NewEdgeID, - const Standard_Integer idnode1, - const Standard_Integer idnode2) +void SMESHDS_Command::AddEdge(int NewEdgeID, int idnode1, int idnode2) { - if (!myType == SMESHDS_AddEdge) { - MESSAGE("SMESHDS_Command::AddEdge : Bad Type"); - return; - } - myIntegers.Append(NewEdgeID); - myIntegers.Append(idnode1); - myIntegers.Append(idnode2); - myNumber++; + if (!myType == SMESHDS_AddEdge) + { + MESSAGE("SMESHDS_Command::AddEdge : Bad Type"); + return; + } + myIntegers.push_back(NewEdgeID); + myIntegers.push_back(idnode1); + myIntegers.push_back(idnode2); + myNumber++; } //======================================================================= //function : //purpose : //======================================================================= -void SMESHDS_Command::AddFace(const Standard_Integer NewFaceID, - const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3) +void SMESHDS_Command::AddFace(int NewFaceID, + int idnode1, int idnode2, int idnode3) { - if (!myType == SMESHDS_AddTriangle) { - MESSAGE("SMESHDS_Command::AddFace : Bad Type"); - return; - } - myIntegers.Append(NewFaceID); - myIntegers.Append(idnode1); - myIntegers.Append(idnode2); - myIntegers.Append(idnode3); - myNumber++; + if (!myType == SMESHDS_AddTriangle) + { + MESSAGE("SMESHDS_Command::AddFace : Bad Type"); + return; + } + myIntegers.push_back(NewFaceID); + myIntegers.push_back(idnode1); + myIntegers.push_back(idnode2); + myIntegers.push_back(idnode3); + myNumber++; } //======================================================================= //function : //purpose : //======================================================================= -void SMESHDS_Command::AddFace(const Standard_Integer NewFaceID, - const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3, - const Standard_Integer idnode4) +void SMESHDS_Command::AddFace(int NewFaceID, + int idnode1, int idnode2, int idnode3, int idnode4) { - if (!myType == SMESHDS_AddQuadrangle) { - MESSAGE("SMESHDS_Command::AddFace : Bad Type"); - return; - } - myIntegers.Append(NewFaceID); - myIntegers.Append(idnode1); - myIntegers.Append(idnode2); - myIntegers.Append(idnode3); - myIntegers.Append(idnode4); - myNumber++; + if (!myType == SMESHDS_AddQuadrangle) + { + MESSAGE("SMESHDS_Command::AddFace : Bad Type"); + return; + } + myIntegers.push_back(NewFaceID); + myIntegers.push_back(idnode1); + myIntegers.push_back(idnode2); + myIntegers.push_back(idnode3); + myIntegers.push_back(idnode4); + myNumber++; } //======================================================================= //function : //purpose : //======================================================================= -void SMESHDS_Command::AddVolume(const Standard_Integer NewVolID, - const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3, - const Standard_Integer idnode4) +void SMESHDS_Command::AddVolume(int NewVolID, + int idnode1, int idnode2, int idnode3, int idnode4) { - if (!myType == SMESHDS_AddTetrahedron) { - MESSAGE("SMESHDS_Command::AddVolume : Bad Type"); - return; - } - myIntegers.Append(NewVolID); - myIntegers.Append(idnode1); - myIntegers.Append(idnode2); - myIntegers.Append(idnode3); - myIntegers.Append(idnode4); - myNumber++; + if (!myType == SMESHDS_AddTetrahedron) + { + MESSAGE("SMESHDS_Command::AddVolume : Bad Type"); + return; + } + myIntegers.push_back(NewVolID); + myIntegers.push_back(idnode1); + myIntegers.push_back(idnode2); + myIntegers.push_back(idnode3); + myIntegers.push_back(idnode4); + myNumber++; } //======================================================================= //function : //purpose : //======================================================================= -void SMESHDS_Command::AddVolume(const Standard_Integer NewVolID, - const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3, - const Standard_Integer idnode4, - const Standard_Integer idnode5) +void SMESHDS_Command::AddVolume(int NewVolID, + int idnode1, int idnode2, int idnode3, int idnode4, int idnode5) { - if (!myType == SMESHDS_AddPyramid) { - MESSAGE("SMESHDS_Command::AddVolume : Bad Type"); - return; - } - myIntegers.Append(NewVolID); - myIntegers.Append(idnode1); - myIntegers.Append(idnode2); - myIntegers.Append(idnode3); - myIntegers.Append(idnode4); - myIntegers.Append(idnode5); - myNumber++; + if (!myType == SMESHDS_AddPyramid) + { + MESSAGE("SMESHDS_Command::AddVolume : Bad Type"); + return; + } + myIntegers.push_back(NewVolID); + myIntegers.push_back(idnode1); + myIntegers.push_back(idnode2); + myIntegers.push_back(idnode3); + myIntegers.push_back(idnode4); + myIntegers.push_back(idnode5); + myNumber++; } //======================================================================= //function : //purpose : //======================================================================= -void SMESHDS_Command::AddVolume(const Standard_Integer NewVolID, - const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3, - const Standard_Integer idnode4, - const Standard_Integer idnode5, - const Standard_Integer idnode6) +void SMESHDS_Command::AddVolume(int NewVolID, + int idnode1, + int idnode2, int idnode3, int idnode4, int idnode5, int idnode6) { - if (!myType == SMESHDS_AddPrism) { - MESSAGE("SMESHDS_Command::AddVolume : Bad Type"); - return; - } - myIntegers.Append(NewVolID); - myIntegers.Append(idnode1); - myIntegers.Append(idnode2); - myIntegers.Append(idnode3); - myIntegers.Append(idnode4); - myIntegers.Append(idnode5); - myIntegers.Append(idnode6); - myNumber++; + if (!myType == SMESHDS_AddPrism) + { + MESSAGE("SMESHDS_Command::AddVolume : Bad Type"); + return; + } + myIntegers.push_back(NewVolID); + myIntegers.push_back(idnode1); + myIntegers.push_back(idnode2); + myIntegers.push_back(idnode3); + myIntegers.push_back(idnode4); + myIntegers.push_back(idnode5); + myIntegers.push_back(idnode6); + myNumber++; } //======================================================================= //function : //purpose : //======================================================================= -void SMESHDS_Command::AddVolume(const Standard_Integer NewVolID, - const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3, - const Standard_Integer idnode4, - const Standard_Integer idnode5, - const Standard_Integer idnode6, - const Standard_Integer idnode7, - const Standard_Integer idnode8) +void SMESHDS_Command::AddVolume(int NewVolID, + int idnode1, + int idnode2, + int idnode3, + int idnode4, int idnode5, int idnode6, int idnode7, int idnode8) { - if (!myType == SMESHDS_AddHexahedron) { - MESSAGE("SMESHDS_Command::AddVolume : Bad Type"); - return; - } - myIntegers.Append(NewVolID); - myIntegers.Append(idnode1); - myIntegers.Append(idnode2); - myIntegers.Append(idnode3); - myIntegers.Append(idnode4); - myIntegers.Append(idnode5); - myIntegers.Append(idnode6); - myIntegers.Append(idnode7); - myIntegers.Append(idnode8); - myNumber++; + if (!myType == SMESHDS_AddHexahedron) + { + MESSAGE("SMESHDS_Command::AddVolume : Bad Type"); + return; + } + myIntegers.push_back(NewVolID); + myIntegers.push_back(idnode1); + myIntegers.push_back(idnode2); + myIntegers.push_back(idnode3); + myIntegers.push_back(idnode4); + myIntegers.push_back(idnode5); + myIntegers.push_back(idnode6); + myIntegers.push_back(idnode7); + myIntegers.push_back(idnode8); + myNumber++; } //======================================================================= //function : //purpose : //======================================================================= -void SMESHDS_Command::RemoveNode(const Standard_Integer NodeID) +void SMESHDS_Command::RemoveNode(int NodeID) { - if (!myType == SMESHDS_RemoveNode) { - MESSAGE("SMESHDS_Command::RemoveNode : Bad Type"); - return; - } - myIntegers.Append(NodeID); - myNumber++; + if (!myType == SMESHDS_RemoveNode) + { + MESSAGE("SMESHDS_Command::RemoveNode : Bad Type"); + return; + } + myIntegers.push_back(NodeID); + myNumber++; } //======================================================================= //function : //purpose : //======================================================================= -void SMESHDS_Command::RemoveElement(const Standard_Integer ElementID) +void SMESHDS_Command::RemoveElement(int ElementID) { - if (!myType == SMESHDS_RemoveElement) { - MESSAGE("SMESHDS_Command::RemoveElement : Bad Type"); - return; - } - myIntegers.Append(ElementID); - myNumber++; + if (!myType == SMESHDS_RemoveElement) + { + MESSAGE("SMESHDS_Command::RemoveElement : Bad Type"); + return; + } + myIntegers.push_back(ElementID); + myNumber++; } //======================================================================= @@ -275,32 +258,32 @@ void SMESHDS_Command::RemoveElement(const Standard_Integer ElementID) //======================================================================= SMESHDS_CommandType SMESHDS_Command::GetType() { - return myType; + return myType; } //======================================================================= //function : //purpose : //======================================================================= -Standard_Integer SMESHDS_Command::GetNumber() +int SMESHDS_Command::GetNumber() { - return myNumber; + return myNumber; } //======================================================================= //function : //purpose : //======================================================================= -const TColStd_ListOfInteger& SMESHDS_Command::GetIndexes() +const list < int >&SMESHDS_Command::GetIndexes() { - return myIntegers; + return myIntegers; } //======================================================================= //function : //purpose : //======================================================================= -const TColStd_ListOfReal& SMESHDS_Command::GetCoords() +const list < double >&SMESHDS_Command::GetCoords() { - return myReals; + return myReals; } diff --git a/src/SMESHDS/SMESHDS_Command.hxx b/src/SMESHDS/SMESHDS_Command.hxx index 581b6e8d1..7c3014e7d 100644 --- a/src/SMESHDS/SMESHDS_Command.hxx +++ b/src/SMESHDS/SMESHDS_Command.hxx @@ -27,116 +27,39 @@ #ifndef _SMESHDS_Command_HeaderFile #define _SMESHDS_Command_HeaderFile -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Handle_SMESHDS_Command_HeaderFile -#include "Handle_SMESHDS_Command.hxx" -#endif - -#ifndef _SMESHDS_CommandType_HeaderFile #include "SMESHDS_CommandType.hxx" -#endif -#ifndef _Standard_Integer_HeaderFile -#include -#endif -#ifndef _TColStd_ListOfReal_HeaderFile -#include -#endif -#ifndef _TColStd_ListOfInteger_HeaderFile -#include -#endif -#ifndef _MMgt_TShared_HeaderFile -#include -#endif -#ifndef _Standard_Real_HeaderFile -#include -#endif -class TColStd_ListOfInteger; -class TColStd_ListOfReal; - - -class SMESHDS_Command : public MMgt_TShared { - -public: - - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // -Standard_EXPORT SMESHDS_Command(const SMESHDS_CommandType aType); -Standard_EXPORT void AddNode(const Standard_Integer NewNodeID,const Standard_Real x,const Standard_Real y,const Standard_Real z) ; -Standard_EXPORT void AddEdge(const Standard_Integer NewEdgeID,const Standard_Integer idnode1,const Standard_Integer idnode2) ; -Standard_EXPORT void AddFace(const Standard_Integer NewFaceID,const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3) ; -Standard_EXPORT void AddFace(const Standard_Integer NewFaceID,const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3,const Standard_Integer idnode4) ; -Standard_EXPORT void AddVolume(const Standard_Integer NewVolID,const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3,const Standard_Integer idnode4) ; -Standard_EXPORT void AddVolume(const Standard_Integer NewVolID,const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3,const Standard_Integer idnode4,const Standard_Integer idnode5) ; -Standard_EXPORT void AddVolume(const Standard_Integer NewVolID,const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3,const Standard_Integer idnode4,const Standard_Integer idnode5,const Standard_Integer idnode6) ; -Standard_EXPORT void AddVolume(const Standard_Integer NewVolID,const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3,const Standard_Integer idnode4,const Standard_Integer idnode5,const Standard_Integer idnode6,const Standard_Integer idnode7,const Standard_Integer idnode8) ; -Standard_EXPORT void MoveNode(const Standard_Integer NewNodeID,const Standard_Real x,const Standard_Real y,const Standard_Real z) ; -Standard_EXPORT void RemoveNode(const Standard_Integer NodeID) ; -Standard_EXPORT void RemoveElement(const Standard_Integer ElementID) ; -Standard_EXPORT SMESHDS_CommandType GetType() ; -Standard_EXPORT Standard_Integer GetNumber() ; -Standard_EXPORT const TColStd_ListOfInteger& GetIndexes() ; -Standard_EXPORT const TColStd_ListOfReal& GetCoords() ; -Standard_EXPORT ~SMESHDS_Command(); - - - - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& SMESHDS_Command_Type_(); - Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // -SMESHDS_CommandType myType; -Standard_Integer myNumber; -TColStd_ListOfReal myReals; -TColStd_ListOfInteger myIntegers; - - +#include + +class SMESHDS_Command +{ + + public: + SMESHDS_Command(const SMESHDS_CommandType aType); + void AddNode(int NewNodeID, double x, double y, double z); + void AddEdge(int NewEdgeID, int idnode1, int idnode2); + void AddFace(int NewFaceID, int idnode1, int idnode2, int idnode3); + void AddFace(int NewFaceID, int idnode1, int idnode2, int idnode3, + int idnode4); + void AddVolume(int NewVolID, int idnode1, int idnode2, int idnode3, + int idnode4); + void AddVolume(int NewVolID, int idnode1, int idnode2, int idnode3, + int idnode4, int idnode5); + void AddVolume(int NewVolID, int idnode1, int idnode2, int idnode3, + int idnode4, int idnode5, int idnode6); + void AddVolume(int NewVolID, int idnode1, int idnode2, int idnode3, + int idnode4, int idnode5, int idnode6, int idnode7, int idnode8); + void MoveNode(int NewNodeID, double x, double y, double z); + void RemoveNode(int NodeID); + void RemoveElement(int ElementID); + SMESHDS_CommandType GetType(); + int GetNumber(); + const list & GetIndexes(); + const list & GetCoords(); + ~SMESHDS_Command(); + private: + SMESHDS_CommandType myType; + int myNumber; + list myReals; + list myIntegers; }; - - - - - -// other inline functions and methods (like "C++: function call" methods) -// - - #endif diff --git a/src/SMESHDS/SMESHDS_Document.cxx b/src/SMESHDS/SMESHDS_Document.cxx index 81949891f..f5b03b514 100644 --- a/src/SMESHDS/SMESHDS_Document.cxx +++ b/src/SMESHDS/SMESHDS_Document.cxx @@ -27,166 +27,165 @@ // $Header: using namespace std; -#include "SMESHDS_Document.ixx" -#include "SMESHDS_Hypothesis.hxx" - -#include +#include "SMESHDS_Document.hxx" +#include //======================================================================= //function : Create //purpose : //======================================================================= -SMESHDS_Document::SMESHDS_Document(const Standard_Integer UserID): myUserID(UserID) -{} +SMESHDS_Document::SMESHDS_Document(int UserID):myUserID(UserID) +{ +} //======================================================================= //function : NewMesh //purpose : //======================================================================= -Standard_Integer SMESHDS_Document::NewMesh() +int SMESHDS_Document::NewMesh() { - static Standard_Integer NewMeshID = 0; - NewMeshID++; - Handle (SMESHDS_Mesh) aNewMesh = new SMESHDS_Mesh (NewMeshID); - myMeshes.Bind(NewMeshID ,aNewMesh); - return NewMeshID; + static int NewMeshID = 0; + NewMeshID++; + SMESHDS_Mesh *aNewMesh = new SMESHDS_Mesh(NewMeshID); + myMeshes[NewMeshID] = aNewMesh; + return NewMeshID; } //======================================================================= //function : GetMesh //purpose : //======================================================================= -Handle(SMESHDS_Mesh) SMESHDS_Document::GetMesh(const Standard_Integer MeshID) +SMESHDS_Mesh *SMESHDS_Document::GetMesh(int MeshID) { - if (!myMeshes.IsBound(MeshID)) - Standard_OutOfRange::Raise("SMESHDS_Document::RemoveMesh"); - return myMeshes.Find(MeshID); + map::iterator it=myMeshes.find(MeshID); + if (it==myMeshes.end()) + { + MESSAGE("SMESHDS_Document::GetMesh : ID not found"); + return NULL; + } + else return (*it).second; } //======================================================================= //function : RemoveMesh //purpose : //======================================================================= -void SMESHDS_Document::RemoveMesh(const Standard_Integer MeshID) +void SMESHDS_Document::RemoveMesh(int MeshID) { - if (!myMeshes.IsBound(MeshID)) - Standard_OutOfRange::Raise("SMESHDS_Document::RemoveMesh"); - myMeshes.UnBind(MeshID); + map::iterator it=myMeshes.find(MeshID); + if (it==myMeshes.end()) + MESSAGE("SMESHDS_Document::RemoveMesh : ID not found"); + myMeshes.erase(it); } //======================================================================= //function : AddHypothesis //purpose : //======================================================================= -void SMESHDS_Document::AddHypothesis(const SMESHDS_PtrHypothesis& H) +void SMESHDS_Document::AddHypothesis(SMESHDS_Hypothesis * H) { - myHypothesis.Bind (H->GetID(), H); + myHypothesis[H->GetID()]=H; } //======================================================================= //function : GetHypothesis //purpose : //======================================================================= -SMESHDS_PtrHypothesis SMESHDS_Document::GetHypothesis(const Standard_Integer HypID) +SMESHDS_Hypothesis * SMESHDS_Document::GetHypothesis(int HypID) { - if (!myHypothesis.IsBound(HypID)) - Standard_OutOfRange::Raise("SMESHDS_Document::GetHypothesis"); - return myHypothesis.Find(HypID); + map::iterator it=myHypothesis.find(HypID); + if (it==myHypothesis.end()) + { + MESSAGE("SMESHDS_Document::GetHypothesis : ID not found"); + return NULL; + } + else return (*it).second; } //======================================================================= //function : RemoveHypothesis //purpose : //======================================================================= -void SMESHDS_Document::RemoveHypothesis(const Standard_Integer HypID) +void SMESHDS_Document::RemoveHypothesis(int HypID) { - if (!myHypothesis.IsBound(HypID)) - Standard_OutOfRange::Raise("SMESHDS_Document::RemoveHypothesis"); - myMeshes.UnBind(HypID); + map::iterator it=myHypothesis.find(HypID); + if (it==myHypothesis.end()) + MESSAGE("SMESHDS_Document::RemoveHypothesis : ID not found"); + myHypothesis.erase(it); } //======================================================================= //function : NbMeshes //purpose : //======================================================================= -Standard_Integer SMESHDS_Document::NbMeshes() +int SMESHDS_Document::NbMeshes() { - return myMeshes.Extent(); + return myMeshes.size(); } //======================================================================= //function : NbHypothesis //purpose : //======================================================================= -Standard_Integer SMESHDS_Document::NbHypothesis() +int SMESHDS_Document::NbHypothesis() { - return myHypothesis.Extent(); + return myHypothesis.size(); } //======================================================================= //function : InitMeshesIterator //purpose : //======================================================================= -void SMESHDS_Document::InitMeshesIterator() +void SMESHDS_Document::InitMeshesIterator() { - myMeshesIt.Initialize(myMeshes); + myMeshesIt=myMeshes.begin(); } + //======================================================================= //function : NextMesh //purpose : //======================================================================= -void SMESHDS_Document::NextMesh() +SMESHDS_Mesh * SMESHDS_Document::NextMesh() { - myMeshesIt.Next(); + SMESHDS_Mesh * toReturn=(*myMeshesIt).second; + myMeshesIt++; + return toReturn; } + //======================================================================= //function : MoreMesh //purpose : //======================================================================= -Standard_Boolean SMESHDS_Document::MoreMesh() -{ - return myMeshesIt.More(); -} -//======================================================================= -//function : CurrentMesh -//purpose : -//======================================================================= -Handle_SMESHDS_Mesh SMESHDS_Document::CurrentMesh() +bool SMESHDS_Document::MoreMesh() { - return myMeshesIt.Value(); + return myMeshesIt!=myMeshes.end(); } //======================================================================= //function : InitHypothesisIterator //purpose : //======================================================================= -void SMESHDS_Document::InitHypothesisIterator() +void SMESHDS_Document::InitHypothesisIterator() { - myHypothesisIt.Initialize(myHypothesis); + myHypothesisIt=myHypothesis.begin(); } + //======================================================================= //function : NextMesh //purpose : //======================================================================= -void SMESHDS_Document::NextHypothesis() +SMESHDS_Hypothesis * SMESHDS_Document::NextHypothesis() { - myHypothesisIt.Next(); + SMESHDS_Hypothesis * toReturn=(*myHypothesisIt).second; + myHypothesisIt++; + return toReturn; } + //======================================================================= //function : MoreMesh //purpose : //======================================================================= -Standard_Boolean SMESHDS_Document::MoreHypothesis() +bool SMESHDS_Document::MoreHypothesis() { - return myHypothesisIt.More(); + return myHypothesisIt!=myHypothesis.end(); } -//======================================================================= -//function : CurrentMesh -//purpose : -//======================================================================= -SMESHDS_PtrHypothesis SMESHDS_Document::CurrentHypothesis() -{ - return myHypothesisIt.Value(); -} - - diff --git a/src/SMESHDS/SMESHDS_Document.hxx b/src/SMESHDS/SMESHDS_Document.hxx index 8f77ee4c6..4da7a3c47 100644 --- a/src/SMESHDS/SMESHDS_Document.hxx +++ b/src/SMESHDS/SMESHDS_Document.hxx @@ -27,126 +27,37 @@ #ifndef _SMESHDS_Document_HeaderFile #define _SMESHDS_Document_HeaderFile -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Handle_SMESHDS_Document_HeaderFile -#include "Handle_SMESHDS_Document.hxx" -#endif - -#ifndef _Standard_Integer_HeaderFile -#include -#endif -#ifndef _SMESHDS_DataMapOfIntegerMesh_HeaderFile -#include "SMESHDS_DataMapOfIntegerMesh.hxx" -#endif -#ifndef _SMESHDS_DataMapOfIntegerPtrHypothesis_HeaderFile -#include "SMESHDS_DataMapOfIntegerPtrHypothesis.hxx" -#endif -#ifndef _SMESHDS_DataMapIteratorOfDataMapOfIntegerMesh_HeaderFile -#include "SMESHDS_DataMapIteratorOfDataMapOfIntegerMesh.hxx" -#endif -#ifndef _SMESHDS_DataMapIteratorOfDataMapOfIntegerPtrHypothesis_HeaderFile -#include "SMESHDS_DataMapIteratorOfDataMapOfIntegerPtrHypothesis.hxx" -#endif -#ifndef _MMgt_TShared_HeaderFile -#include -#endif -#ifndef _Handle_SMESHDS_Mesh_HeaderFile -#include "Handle_SMESHDS_Mesh.hxx" -#endif -#ifndef _SMESHDS_PtrHypothesis_HeaderFile -#include "SMESHDS_PtrHypothesis.hxx" -#endif -#ifndef _Standard_Boolean_HeaderFile -#include -#endif -class SMESHDS_Mesh; - - -class SMESHDS_Document : public MMgt_TShared { - -public: - - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // -Standard_EXPORT SMESHDS_Document(const Standard_Integer UserID); -Standard_EXPORT Standard_Integer NewMesh() ; -Standard_EXPORT void RemoveMesh(const Standard_Integer MeshID) ; -Standard_EXPORT Handle_SMESHDS_Mesh GetMesh(const Standard_Integer MeshID) ; -Standard_EXPORT void AddHypothesis(const SMESHDS_PtrHypothesis& H) ; -Standard_EXPORT void RemoveHypothesis(const Standard_Integer HypID) ; -Standard_EXPORT SMESHDS_PtrHypothesis GetHypothesis(const Standard_Integer HypID) ; -Standard_EXPORT Standard_Integer NbMeshes() ; -Standard_EXPORT Standard_Integer NbHypothesis() ; -Standard_EXPORT void InitMeshesIterator() ; -Standard_EXPORT void NextMesh() ; -Standard_EXPORT Standard_Boolean MoreMesh() ; -Standard_EXPORT Handle_SMESHDS_Mesh CurrentMesh() ; -Standard_EXPORT void InitHypothesisIterator() ; -Standard_EXPORT void NextHypothesis() ; -Standard_EXPORT Standard_Boolean MoreHypothesis() ; -Standard_EXPORT SMESHDS_PtrHypothesis CurrentHypothesis() ; -Standard_EXPORT ~SMESHDS_Document(); - - - - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& SMESHDS_Document_Type_(); - Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // -Standard_Integer myUserID; -SMESHDS_DataMapOfIntegerMesh myMeshes; -SMESHDS_DataMapOfIntegerPtrHypothesis myHypothesis; -SMESHDS_DataMapIteratorOfDataMapOfIntegerMesh myMeshesIt; -SMESHDS_DataMapIteratorOfDataMapOfIntegerPtrHypothesis myHypothesisIt; - - +#include +#include "SMESHDS_Mesh.hxx" +#include "SMESHDS_Hypothesis.hxx" +using namespace std; + +class SMESHDS_Document +{ + public: + SMESHDS_Document(int UserID); + int NewMesh(); + void RemoveMesh(int MeshID); + SMESHDS_Mesh * GetMesh(int MeshID); + void AddHypothesis(SMESHDS_Hypothesis * H); + void RemoveHypothesis(int HypID); + SMESHDS_Hypothesis * GetHypothesis(int HypID); + int NbMeshes(); + int NbHypothesis(); + void InitMeshesIterator(); + SMESHDS_Mesh * NextMesh(); + bool MoreMesh(); + void InitHypothesisIterator(); + SMESHDS_Hypothesis * NextHypothesis(); + bool MoreHypothesis(); + ~SMESHDS_Document(); + + private: + int myUserID; + map myMeshes; + map myHypothesis; + map::iterator myMeshesIt; + map::iterator myHypothesisIt; }; - - - - -// other inline functions and methods (like "C++: function call" methods) -// - - #endif diff --git a/src/SMESHDS/SMESHDS_Hypothesis.cxx b/src/SMESHDS/SMESHDS_Hypothesis.cxx index 35b551f46..b1cf717b8 100644 --- a/src/SMESHDS/SMESHDS_Hypothesis.cxx +++ b/src/SMESHDS/SMESHDS_Hypothesis.cxx @@ -63,7 +63,7 @@ SMESHDS_Hypothesis::~SMESHDS_Hypothesis() */ //============================================================================= -const char* SMESHDS_Hypothesis::GetName() +const char* SMESHDS_Hypothesis::GetName() const { // MESSAGE("SMESHDS_Hypothesis::GetName"); // SCRUTE(_name); @@ -77,7 +77,7 @@ const char* SMESHDS_Hypothesis::GetName() */ //============================================================================= -int SMESHDS_Hypothesis::GetID() +int SMESHDS_Hypothesis::GetID() const { // MESSAGE("SMESHDS_Hypothesis::GetId"); // SCRUTE(_hypId); @@ -90,7 +90,7 @@ int SMESHDS_Hypothesis::GetID() */ //============================================================================= -int SMESHDS_Hypothesis::GetType() +int SMESHDS_Hypothesis::GetType() const { // MESSAGE("SMESHDS_Hypothesis::GetType"); // SCRUTE(_type); diff --git a/src/SMESHDS/SMESHDS_Hypothesis.hxx b/src/SMESHDS/SMESHDS_Hypothesis.hxx index b6e21c2cd..3a79039b8 100644 --- a/src/SMESHDS/SMESHDS_Hypothesis.hxx +++ b/src/SMESHDS/SMESHDS_Hypothesis.hxx @@ -38,9 +38,7 @@ #include #include #endif - -// class istream; -// class ostream; +using namespace std; class SMESHDS_Hypothesis { @@ -48,9 +46,9 @@ public: SMESHDS_Hypothesis(int hypId); virtual ~SMESHDS_Hypothesis(); - const char* GetName(); - int GetID(); - int GetType(); + const char* GetName() const; + int GetID() const; + int GetType() const; virtual ostream & SaveTo(ostream & save)=0; virtual istream & LoadFrom(istream & load)=0; diff --git a/src/SMESHDS/SMESHDS_Mesh.cxx b/src/SMESHDS/SMESHDS_Mesh.cxx index 930818b47..b9023b3e6 100644 --- a/src/SMESHDS/SMESHDS_Mesh.cxx +++ b/src/SMESHDS/SMESHDS_Mesh.cxx @@ -26,64 +26,51 @@ // Module : SMESH // $Header: -using namespace std; -#include "SMESHDS_Mesh.ixx" -#include "SMESHDS_Hypothesis.hxx" -#include "SMESHDS_DataMapOfShapeListOfPtrHypothesis.hxx" -#include "SMESHDS_ListIteratorOfListOfPtrHypothesis.hxx" +#include "SMESHDS_Mesh.hxx" #include "SMDS_VertexPosition.hxx" #include "SMDS_EdgePosition.hxx" #include "SMDS_FacePosition.hxx" #include #include -#include #include "utilities.h" - //======================================================================= //function : Create //purpose : //======================================================================= -SMESHDS_Mesh::SMESHDS_Mesh(const Standard_Integer MeshID) : myMeshID( MeshID) +SMESHDS_Mesh::SMESHDS_Mesh(int MeshID):myMeshID(MeshID) { - myScript = new SMESHDS_Script(); + myScript = new SMESHDS_Script(); } //======================================================================= //function : ShapeToMesh //purpose : //======================================================================= -void SMESHDS_Mesh::ShapeToMesh(const TopoDS_Shape& S) +void SMESHDS_Mesh::ShapeToMesh(const TopoDS_Shape & S) { - myShape = S; - TopExp::MapShapes(myShape,myIndexToShape); + myShape = S; + TopExp::MapShapes(myShape, myIndexToShape); } - - + //======================================================================= //function : AddHypothesis //purpose : //======================================================================= -Standard_Boolean SMESHDS_Mesh::AddHypothesis(const TopoDS_Shape& SS, - const SMESHDS_PtrHypothesis& H) +bool SMESHDS_Mesh::AddHypothesis(const TopoDS_Shape & SS, + const SMESHDS_Hypothesis * H) { - if (!myShapeToHypothesis.IsBound(SS)){ - SMESHDS_ListOfPtrHypothesis empty; - myShapeToHypothesis.Bind(SS,empty); - } - else { - //Check if the Hypothesis is still present - SMESHDS_ListOfPtrHypothesis& Hypos = myShapeToHypothesis.ChangeFind (SS); + list& alist=myShapeToHypothesis[SS]; + + //Check if the Hypothesis is still present + list::iterator ith=alist.begin(); + + for (; ith!=alist.end(); ith++) + if (H == *ith) return false; - for (SMESHDS_ListIteratorOfListOfPtrHypothesis it(Hypos); it.More(); it.Next()) { - if (H == it.Value()) { - return Standard_False; - } - } - } - myShapeToHypothesis(SS).Append(H); - return Standard_True; + alist.push_back(H); + return true; } //======================================================================= @@ -91,530 +78,476 @@ Standard_Boolean SMESHDS_Mesh::AddHypothesis(const TopoDS_Shape& SS, //purpose : //======================================================================= -Standard_Boolean SMESHDS_Mesh::RemoveHypothesis(const TopoDS_Shape& S, - const SMESHDS_PtrHypothesis& H) +bool SMESHDS_Mesh::RemoveHypothesis(const TopoDS_Shape & S, + const SMESHDS_Hypothesis * H) { - if (myShapeToHypothesis.IsBound(S)){ - SMESHDS_ListOfPtrHypothesis& Hypos = myShapeToHypothesis.ChangeFind (S); - for (SMESHDS_ListIteratorOfListOfPtrHypothesis it(Hypos); it.More(); it.Next()) { - if (H == it.Value()) { - Hypos.Remove(it); - return Standard_True; - } - } - } - return Standard_False; + ShapeToHypothesis::iterator its=myShapeToHypothesis.find(S); + if(its!=myShapeToHypothesis.end()) + { + list::iterator ith=(*its).second.begin(); + + for (; ith!=(*its).second.end(); ith++) + if (H == *ith) + { + (*its).second.erase(ith); + return true; + } + } + return false; } - - + //======================================================================= //function : AddNode //purpose : //======================================================================= -Standard_Integer SMESHDS_Mesh::AddNode(const Standard_Real x, - const Standard_Real y, - const Standard_Real z) +SMDS_MeshNode* SMESHDS_Mesh::AddNode(double x, double y, double z) { - Standard_Integer NodeID = SMDS_Mesh::AddNode(x,y,z); - myScript->AddNode(NodeID,x,y,z); - return NodeID; + SMDS_MeshNode* node = SMDS_Mesh::AddNode(x, y, z); + if(node!=NULL) myScript->AddNode(node->GetID(), x, y, z); + return node; } //======================================================================= //function : MoveNode //purpose : //======================================================================= -void SMESHDS_Mesh::MoveNode(const Standard_Integer ID, - const Standard_Real x, - const Standard_Real y, - const Standard_Real z) +void SMESHDS_Mesh::MoveNode(int ID, double x, double y, double z) { - - Handle(SMDS_MeshNode) Node = Handle(SMDS_MeshNode)::DownCast(FindNode(ID)); - gp_Pnt P(x,y,z); - Node->SetPnt(P); - myScript->MoveNode(ID,x,y,z); + SMDS_MeshNode * node=const_cast(FindNode(ID)); + node->setXYZ(x,y,z); + myScript->MoveNode(ID, x, y, z); } - - //======================================================================= //function : AddEdge //purpose : //======================================================================= -Standard_Integer SMESHDS_Mesh::AddEdge(const Standard_Integer idnode1, - const Standard_Integer idnode2) +SMDS_MeshEdge* SMESHDS_Mesh::AddEdge(int idnode1, int idnode2) { - Standard_Integer ID = SMDS_Mesh::AddEdge(idnode1,idnode2); - myScript->AddEdge (ID,idnode1,idnode2); - return ID; + SMDS_MeshEdge* e = SMDS_Mesh::AddEdge(idnode1, idnode2); + if(e!=NULL) myScript->AddEdge(e->GetID(), idnode1, idnode2); + return e; } - //======================================================================= //function :AddFace //purpose : //======================================================================= -Standard_Integer SMESHDS_Mesh::AddFace(const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3) +SMDS_MeshFace* SMESHDS_Mesh::AddFace(int idnode1, int idnode2, int idnode3) { - Standard_Integer ID = SMDS_Mesh::AddFace(idnode1,idnode2,idnode3); - myScript->AddFace (ID,idnode1,idnode2,idnode3); - return ID; + SMDS_MeshFace *f = SMDS_Mesh::AddFace(idnode1, idnode2, idnode3); + if(f!=NULL) myScript->AddFace(f->GetID(), idnode1, idnode2, idnode3); + return f; } //======================================================================= //function :AddFace //purpose : //======================================================================= -Standard_Integer SMESHDS_Mesh::AddFace(const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3, - const Standard_Integer idnode4) +SMDS_MeshFace* SMESHDS_Mesh::AddFace(int idnode1, int idnode2, int idnode3, + int idnode4) { - Standard_Integer ID = SMDS_Mesh::AddFace(idnode1,idnode2,idnode3,idnode4); - myScript->AddFace (ID,idnode1,idnode2,idnode3,idnode4); - return ID; + SMDS_MeshFace *f = SMDS_Mesh::AddFace(idnode1, idnode2, idnode3, idnode4); + if(f!=NULL) + myScript->AddFace(f->GetID(), idnode1, idnode2, idnode3, idnode4); + return f; } - //======================================================================= //function :AddVolume //purpose : //======================================================================= -Standard_Integer SMESHDS_Mesh::AddVolume(const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3, - const Standard_Integer idnode4) +SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(int idnode1, int idnode2, int idnode3, + int idnode4) { - Standard_Integer ID = SMDS_Mesh::AddVolume(idnode1,idnode2,idnode3,idnode4); - myScript->AddVolume (ID,idnode1,idnode2,idnode3,idnode4); - return ID; + SMDS_MeshVolume *f = SMDS_Mesh::AddVolume(idnode1, idnode2, idnode3, + idnode4); + if(f!=NULL) + myScript->AddVolume(f->GetID(), idnode1, idnode2, idnode3, idnode4); + return f; } - //======================================================================= //function :AddVolume //purpose : //======================================================================= -Standard_Integer SMESHDS_Mesh::AddVolume(const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3, - const Standard_Integer idnode4, - const Standard_Integer idnode5) +SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(int idnode1, int idnode2, int idnode3, + int idnode4, int idnode5) { - Standard_Integer ID = SMDS_Mesh::AddVolume(idnode1,idnode2,idnode3,idnode4,idnode5); - myScript->AddVolume (ID,idnode1,idnode2,idnode3,idnode4,idnode5); - return ID; + SMDS_MeshVolume *v = SMDS_Mesh::AddVolume(idnode1, idnode2, idnode3, + idnode4, idnode5); + if(v!=NULL) + myScript->AddVolume(v->GetID(), idnode1, idnode2, idnode3, idnode4, + idnode5); + return v; } - //======================================================================= //function :AddVolume //purpose : //======================================================================= -Standard_Integer SMESHDS_Mesh::AddVolume(const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3, - const Standard_Integer idnode4, - const Standard_Integer idnode5, - const Standard_Integer idnode6) +SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(int idnode1, int idnode2, int idnode3, + int idnode4, int idnode5, int idnode6) { - Standard_Integer ID = SMDS_Mesh::AddVolume(idnode1,idnode2,idnode3,idnode4,idnode5,idnode6); - myScript->AddVolume (ID,idnode1,idnode2,idnode3,idnode4,idnode5,idnode6); - return ID; + SMDS_MeshVolume *v= + SMDS_Mesh::AddVolume(idnode1, idnode2, idnode3, idnode4, idnode5, + idnode6); + if(v!=NULL) + myScript->AddVolume(v->GetID(), idnode1, idnode2, idnode3, idnode4, + idnode5, idnode6); + return v; } //======================================================================= //function :AddVolume //purpose : //======================================================================= -Standard_Integer SMESHDS_Mesh::AddVolume(const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3, - const Standard_Integer idnode4, - const Standard_Integer idnode5, - const Standard_Integer idnode6, - const Standard_Integer idnode7, - const Standard_Integer idnode8) +SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(int idnode1, int idnode2, int idnode3, + int idnode4, int idnode5, int idnode6, int idnode7, int idnode8) { - Standard_Integer ID = SMDS_Mesh::AddVolume(idnode1,idnode2,idnode3,idnode4,idnode5,idnode6,idnode7,idnode8); - myScript->AddVolume (ID,idnode1,idnode2,idnode3,idnode4,idnode5,idnode6,idnode7,idnode8); - return ID; + SMDS_MeshVolume *v= + SMDS_Mesh::AddVolume(idnode1, idnode2, idnode3, idnode4, idnode5, + idnode6, idnode7, idnode8); + if(v!=NULL) + myScript->AddVolume(v->GetID(), idnode1, idnode2, idnode3, idnode4, + idnode5, idnode6, idnode7, idnode8); + return v; } - //======================================================================= //function : RemoveNode //purpose : //======================================================================= -void SMESHDS_Mesh::RemoveNode(const Standard_Integer ID) +void SMESHDS_Mesh::RemoveNode(int ID) { - SMDS_Mesh::RemoveNode (ID); - myScript->RemoveNode (ID); + SMDS_Mesh::RemoveNode(ID); + myScript->RemoveNode(ID); } - - //======================================================================= //function : RemoveElement //purpose : //======================================================================== -void SMESHDS_Mesh::RemoveElement(const Standard_Integer ID) +void SMESHDS_Mesh::RemoveElement(int ID) { - SMDS_Mesh::RemoveElement (ID); - myScript->RemoveElement (ID); + SMDS_Mesh::RemoveElement(ID); + myScript->RemoveElement(ID); } //======================================================================= //function : SetNodeOnVolume //purpose : //======================================================================= -void SMESHDS_Mesh::SetNodeInVolume (const Handle(SMDS_MeshNode)& aNode, - const TopoDS_Shell& S) +void SMESHDS_Mesh::SetNodeInVolume(SMDS_MeshNode * aNode, + const TopoDS_Shell & S) { - if (myShape.IsNull()) - Standard_NullObject::Raise("SMESHDS_Mesh::SetNodeOnVolume"); - - Standard_Integer Index = myIndexToShape.FindIndex(S); - - //Set Position on Node - //Handle (SMDS_FacePosition) aPos = new SMDS_FacePosition (myFaceToId(S),0.,0.);; - //aNode->SetPosition(aPos); - - //Update or build submesh - if (!myShapeIndexToSubMesh.IsBound(Index)) { - Handle(SMESHDS_SubMesh) SM = new SMESHDS_SubMesh (this); - myShapeIndexToSubMesh.Bind(Index,SM); - } - myShapeIndexToSubMesh(Index)->AddNode (aNode); + if (myShape.IsNull()) MESSAGE("myShape is NULL"); + + int Index = myIndexToShape.FindIndex(S); + + //Set Position on Node + //Handle (SMDS_FacePosition) aPos = new SMDS_FacePosition (myFaceToId(S),0.,0.);; + //aNode->SetPosition(aPos); + + //Update or build submesh + map::iterator it=myShapeIndexToSubMesh.find(Index); + if (it==myShapeIndexToSubMesh.end()) + myShapeIndexToSubMesh[Index]= new SMESHDS_SubMesh(this); + + myShapeIndexToSubMesh[Index]->AddNode(aNode); } //======================================================================= //function : SetNodeOnFace //purpose : //======================================================================= -void SMESHDS_Mesh::SetNodeOnFace (const Handle(SMDS_MeshNode)& aNode, - const TopoDS_Face& S) +void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode * aNode, + const TopoDS_Face & S) { - if (myShape.IsNull()) - Standard_NullObject::Raise("SMESHDS_Mesh::SetNodeOnFace"); - - Standard_Integer Index = myIndexToShape.FindIndex(S); - - //Set Position on Node - Handle (SMDS_FacePosition) aPos = new SMDS_FacePosition (Index,0.,0.);; - aNode->SetPosition(aPos); - - //Update or build submesh - if (!myShapeIndexToSubMesh.IsBound(Index)) { - Handle(SMESHDS_SubMesh) SM = new SMESHDS_SubMesh (this); - myShapeIndexToSubMesh.Bind(Index,SM); - } - myShapeIndexToSubMesh(Index)->AddNode (aNode); + if (myShape.IsNull()) MESSAGE("myShape is NULL"); + + int Index = myIndexToShape.FindIndex(S); + + //Set Position on Node + aNode->SetPosition(new SMDS_FacePosition(Index, 0., 0.)); + + //Update or build submesh + map::iterator it=myShapeIndexToSubMesh.find(Index); + if (it==myShapeIndexToSubMesh.end()) + myShapeIndexToSubMesh[Index]= new SMESHDS_SubMesh(this); + + myShapeIndexToSubMesh[Index]->AddNode(aNode); } //======================================================================= //function : SetNodeOnEdge //purpose : //======================================================================= -void SMESHDS_Mesh::SetNodeOnEdge (const Handle(SMDS_MeshNode)& aNode, - const TopoDS_Edge& S) +void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode * aNode, + const TopoDS_Edge & S) { - if (myShape.IsNull()) - Standard_NullObject::Raise("SMESHDS_Mesh::SetNodeOnEdge"); - - Standard_Integer Index = myIndexToShape.FindIndex(S); - - //Set Position on Node - Handle (SMDS_EdgePosition) aPos = new SMDS_EdgePosition (Index,0.);; - aNode->SetPosition(aPos); - - //Update or build submesh - if (!myShapeIndexToSubMesh.IsBound(Index)) { - Handle(SMESHDS_SubMesh) SM = new SMESHDS_SubMesh (this); - myShapeIndexToSubMesh.Bind(Index,SM); - } - myShapeIndexToSubMesh(Index)->AddNode (aNode); - + if (myShape.IsNull()) MESSAGE("myShape is NULL"); + + int Index = myIndexToShape.FindIndex(S); + + //Set Position on Node + aNode->SetPosition(new SMDS_EdgePosition(Index, 0.)); + + //Update or build submesh + map::iterator it=myShapeIndexToSubMesh.find(Index); + if (it==myShapeIndexToSubMesh.end()) + myShapeIndexToSubMesh[Index]= new SMESHDS_SubMesh(this); + + myShapeIndexToSubMesh[Index]->AddNode(aNode); } //======================================================================= //function : SetNodeOnVertex //purpose : //======================================================================= -void SMESHDS_Mesh::SetNodeOnVertex (const Handle(SMDS_MeshNode)& aNode, - const TopoDS_Vertex& S) -{ - if (myShape.IsNull()) - Standard_NullObject::Raise("SMESHDS_Mesh::SetNodeOnVertex"); - - Standard_Integer Index = myIndexToShape.FindIndex(S); - - //Set Position on Node - Handle (SMDS_VertexPosition) aPos = new SMDS_VertexPosition (Index);; - aNode->SetPosition(aPos); - - //Update or build submesh - if (!myShapeIndexToSubMesh.IsBound(Index)) { - Handle(SMESHDS_SubMesh) SM = new SMESHDS_SubMesh (this); - myShapeIndexToSubMesh.Bind(Index,SM); - } - myShapeIndexToSubMesh(Index)->AddNode (aNode); -} +void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode * aNode, + const TopoDS_Vertex & S) +{ + if (myShape.IsNull()) MESSAGE("myShape is NULL"); + + int Index = myIndexToShape.FindIndex(S); + + //Set Position on Node + aNode->SetPosition(new SMDS_VertexPosition(Index)); + //Update or build submesh + map::iterator it=myShapeIndexToSubMesh.find(Index); + if (it==myShapeIndexToSubMesh.end()) + myShapeIndexToSubMesh[Index]= new SMESHDS_SubMesh(this); + + myShapeIndexToSubMesh[Index]->AddNode(aNode); +} //======================================================================= //function : UnSetNodeOnShape //purpose : //======================================================================= -void SMESHDS_Mesh::UnSetNodeOnShape(const Handle(SMDS_MeshNode)& aNode) -{ - MESSAGE("not implemented"); +void SMESHDS_Mesh::UnSetNodeOnShape(const SMDS_MeshNode* aNode) +{ + MESSAGE("not implemented"); } - //======================================================================= //function : SetMeshElementOnShape //purpose : //======================================================================= -void SMESHDS_Mesh::SetMeshElementOnShape (const Handle(SMDS_MeshElement)& anElement, - const TopoDS_Shape& S) +void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement * anElement, + const TopoDS_Shape & S) { - if (myShape.IsNull()) - Standard_NullObject::Raise("SMESHDS_Mesh::SetMeshElementOnShape"); - - Standard_Integer Index = myIndexToShape.FindIndex(S); - + if (myShape.IsNull()) MESSAGE("myShape is NULL"); + + int Index = myIndexToShape.FindIndex(S); - if (!myShapeIndexToSubMesh.IsBound(Index)) { - Handle(SMESHDS_SubMesh) SM = new SMESHDS_SubMesh (this); - myShapeIndexToSubMesh.Bind(Index,SM); - } - myShapeIndexToSubMesh(Index)->AddElement (anElement); + if (myShapeIndexToSubMesh.find(Index)==myShapeIndexToSubMesh.end()) + myShapeIndexToSubMesh[Index]=new SMESHDS_SubMesh(this); + + myShapeIndexToSubMesh[Index]->AddElement(anElement); } //======================================================================= //function : UnSetMeshElementOnShape //purpose : //======================================================================= -void SMESHDS_Mesh::UnSetMeshElementOnShape (const Handle(SMDS_MeshElement)& anElement, - const TopoDS_Shape& S) - +void SMESHDS_Mesh:: +UnSetMeshElementOnShape(const SMDS_MeshElement * anElement, + const TopoDS_Shape & S) { - if (myShape.IsNull()) - Standard_NullObject::Raise("SMESHDS_Mesh::UnSetMeshElementOnShape"); - - Standard_Integer Index = myIndexToShape.FindIndex(S); + if (myShape.IsNull()) MESSAGE("myShape is NULL"); + + int Index = myIndexToShape.FindIndex(S); - if (myShapeIndexToSubMesh.IsBound(Index)) - myShapeIndexToSubMesh(Index)->RemoveElement (anElement); + if (myShapeIndexToSubMesh.find(Index)!=myShapeIndexToSubMesh.end()) + myShapeIndexToSubMesh[Index]->RemoveElement(anElement); } //======================================================================= //function : ShapeToMesh //purpose : //======================================================================= -TopoDS_Shape SMESHDS_Mesh::ShapeToMesh() +TopoDS_Shape SMESHDS_Mesh::ShapeToMesh() const { - return myShape; + return myShape; } -//======================================================================= -//function : MeshElements -//purpose : -//======================================================================= -Handle_SMESHDS_SubMesh SMESHDS_Mesh::MeshElements(const TopoDS_Shape& S) +/////////////////////////////////////////////////////////////////////////////// +/// Return the sub mesh linked to the a given TopoDS_Shape or NULL if the given +/// TopoDS_Shape is unknown +/////////////////////////////////////////////////////////////////////////////// +SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) { - if (myShape.IsNull()) - Standard_NullObject::Raise("SMESHDS_Mesh::MeshElements"); - - Standard_Integer Index = myIndexToShape.FindIndex(S); + if (myShape.IsNull()) MESSAGE("myShape is NULL"); - if (myShapeIndexToSubMesh.IsBound(Index)) - return myShapeIndexToSubMesh(Index); - Handle(SMESHDS_SubMesh) SM; - return SM; + int Index = myIndexToShape.FindIndex(S); + if (myShapeIndexToSubMesh.find(Index)!=myShapeIndexToSubMesh.end()) + return myShapeIndexToSubMesh[Index]; + else + return NULL; } //======================================================================= //function : GetHypothesis //purpose : //======================================================================= -const SMESHDS_ListOfPtrHypothesis& SMESHDS_Mesh::GetHypothesis(const TopoDS_Shape& S) + +const list& SMESHDS_Mesh::GetHypothesis( + const TopoDS_Shape & S) const { - if (myShapeToHypothesis.IsBound(S)) - return myShapeToHypothesis(S); - - static SMESHDS_ListOfPtrHypothesis empty; - return empty; + if (myShapeToHypothesis.find(S)!=myShapeToHypothesis.end()) + return myShapeToHypothesis.find(S)->second; + + static list empty; + return empty; } //======================================================================= //function : GetScript //purpose : //======================================================================= -const Handle (SMESHDS_Script)& SMESHDS_Mesh::GetScript() +SMESHDS_Script* SMESHDS_Mesh::GetScript() { - return myScript; + return myScript; } //======================================================================= //function : ClearScript //purpose : //======================================================================= -void SMESHDS_Mesh::ClearScript() +void SMESHDS_Mesh::ClearScript() { - myScript->Clear(); + myScript->Clear(); } //======================================================================= //function : HasMeshElements //purpose : //======================================================================= -Standard_Boolean SMESHDS_Mesh::HasMeshElements(const TopoDS_Shape& S) +bool SMESHDS_Mesh::HasMeshElements(const TopoDS_Shape & S) { - if (myShape.IsNull()) - Standard_NullObject::Raise("SMESHDS_Mesh::MeshElements"); - - Standard_Integer Index = myIndexToShape.FindIndex(S); - - return myShapeIndexToSubMesh.IsBound(Index); + if (myShape.IsNull()) MESSAGE("myShape is NULL"); + int Index = myIndexToShape.FindIndex(S); + return myShapeIndexToSubMesh.find(Index)!=myShapeIndexToSubMesh.end(); } //======================================================================= //function : HasHypothesis //purpose : //======================================================================= -Standard_Boolean SMESHDS_Mesh::HasHypothesis(const TopoDS_Shape& S) +bool SMESHDS_Mesh::HasHypothesis(const TopoDS_Shape & S) { - return myShapeToHypothesis.IsBound(S); + return myShapeToHypothesis.find(S)!=myShapeToHypothesis.end(); } //======================================================================= //function : NewSubMesh //purpose : //======================================================================= -void SMESHDS_Mesh::NewSubMesh(const Standard_Integer Index) +void SMESHDS_Mesh::NewSubMesh(int Index) { - if (!myShapeIndexToSubMesh.IsBound(Index)) { - Handle(SMESHDS_SubMesh) SM = new SMESHDS_SubMesh (this); - myShapeIndexToSubMesh.Bind(Index,SM); - } + if (myShapeIndexToSubMesh.find(Index)==myShapeIndexToSubMesh.end()) + { + SMESHDS_SubMesh* SM = new SMESHDS_SubMesh(this); + myShapeIndexToSubMesh[Index]=SM; + } } //======================================================================= //function : IndexToShape //purpose : //======================================================================= -TopoDS_Shape SMESHDS_Mesh::IndexToShape(const Standard_Integer ShapeIndex) +TopoDS_Shape SMESHDS_Mesh::IndexToShape(int ShapeIndex) { - return myIndexToShape.FindKey(ShapeIndex); -} + return myIndexToShape.FindKey(ShapeIndex); +} //======================================================================= //function : ShapeToIndex //purpose : //======================================================================= -Standard_Integer SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape& S) +int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) { - if (myShape.IsNull()) - Standard_NullObject::Raise("SMESHDS_Mesh::SetNodeOnVolume"); - - return myIndexToShape.FindIndex(S); + if (myShape.IsNull()) MESSAGE("myShape is NULL"); + return myIndexToShape.FindIndex(S); } //======================================================================= //function : SetNodeOnVolume //purpose : //======================================================================= -void SMESHDS_Mesh::SetNodeInVolume (const Handle(SMDS_MeshNode)& aNode, - const Standard_Integer Index) +void SMESHDS_Mesh::SetNodeInVolume(const SMDS_MeshNode* aNode, int Index) { - - //Set Position on Node - //Handle (SMDS_FacePosition) aPos = new SMDS_FacePosition (myFaceToId(S),0.,0.);; - //aNode->SetPosition(aPos); - - //Update or build submesh - if (!myShapeIndexToSubMesh.IsBound(Index)) { - Handle(SMESHDS_SubMesh) SM = new SMESHDS_SubMesh (this); - myShapeIndexToSubMesh.Bind(Index,SM); - } - myShapeIndexToSubMesh(Index)->AddNode (aNode); + //Set Position on Node + //Handle (SMDS_FacePosition) aPos = new SMDS_FacePosition (myFaceToId(S),0.,0.);; + //aNode->SetPosition(aPos); + + //Update or build submesh + if (myShapeIndexToSubMesh.find(Index)==myShapeIndexToSubMesh.end()) + myShapeIndexToSubMesh[Index]=new SMESHDS_SubMesh(this); + + myShapeIndexToSubMesh[Index]->AddNode(aNode); } //======================================================================= //function : SetNodeOnFace //purpose : //======================================================================= -void SMESHDS_Mesh::SetNodeOnFace (const Handle(SMDS_MeshNode)& aNode, - const Standard_Integer Index) +void SMESHDS_Mesh::SetNodeOnFace(SMDS_MeshNode* aNode, int Index) { - - //Set Position on Node - Handle (SMDS_FacePosition) aPos = new SMDS_FacePosition (Index,0.,0.);; - aNode->SetPosition(aPos); - - //Update or build submesh - if (!myShapeIndexToSubMesh.IsBound(Index)) { - Handle(SMESHDS_SubMesh) SM = new SMESHDS_SubMesh (this); - myShapeIndexToSubMesh.Bind(Index,SM); - } - myShapeIndexToSubMesh(Index)->AddNode (aNode); + //Set Position on Node + aNode->SetPosition(new SMDS_FacePosition(Index, 0., 0.)); + + //Update or build submesh + if (myShapeIndexToSubMesh.find(Index)==myShapeIndexToSubMesh.end()) + myShapeIndexToSubMesh[Index]=new SMESHDS_SubMesh(this); + + myShapeIndexToSubMesh[Index]->AddNode(aNode); } //======================================================================= //function : SetNodeOnEdge //purpose : //======================================================================= -void SMESHDS_Mesh::SetNodeOnEdge (const Handle(SMDS_MeshNode)& aNode, - const Standard_Integer Index) +void SMESHDS_Mesh::SetNodeOnEdge(SMDS_MeshNode* aNode, int Index) { - - //Set Position on Node - Handle (SMDS_EdgePosition) aPos = new SMDS_EdgePosition (Index,0.);; - aNode->SetPosition(aPos); - - //Update or build submesh - if (!myShapeIndexToSubMesh.IsBound(Index)) { - Handle(SMESHDS_SubMesh) SM = new SMESHDS_SubMesh (this); - myShapeIndexToSubMesh.Bind(Index,SM); - } - myShapeIndexToSubMesh(Index)->AddNode (aNode); - + //Set Position on Node + aNode->SetPosition(new SMDS_EdgePosition(Index, 0.)); + + //Update or build submesh + if (myShapeIndexToSubMesh.find(Index)==myShapeIndexToSubMesh.end()) + myShapeIndexToSubMesh[Index]=new SMESHDS_SubMesh(this); + + myShapeIndexToSubMesh[Index]->AddNode(aNode); } //======================================================================= //function : SetNodeOnVertex //purpose : //======================================================================= -void SMESHDS_Mesh::SetNodeOnVertex (const Handle(SMDS_MeshNode)& aNode, - const Standard_Integer Index) -{ - //Set Position on Node - Handle (SMDS_VertexPosition) aPos = new SMDS_VertexPosition (Index);; - aNode->SetPosition(aPos); - - //Update or build submesh - if (!myShapeIndexToSubMesh.IsBound(Index)) { - Handle(SMESHDS_SubMesh) SM = new SMESHDS_SubMesh (this); - myShapeIndexToSubMesh.Bind(Index,SM); - } - myShapeIndexToSubMesh(Index)->AddNode (aNode); +void SMESHDS_Mesh::SetNodeOnVertex(SMDS_MeshNode* aNode, int Index) +{ + //Set Position on Node + aNode->SetPosition(new SMDS_VertexPosition(Index)); + + //Update or build submesh + if (myShapeIndexToSubMesh.find(Index)==myShapeIndexToSubMesh.end()) + myShapeIndexToSubMesh[Index]=new SMESHDS_SubMesh(this); + + myShapeIndexToSubMesh[Index]->AddNode(aNode); } //======================================================================= //function : SetMeshElementOnShape //purpose : //======================================================================= -void SMESHDS_Mesh::SetMeshElementOnShape (const Handle(SMDS_MeshElement)& anElement, - const Standard_Integer Index) +void SMESHDS_Mesh::SetMeshElementOnShape(const SMDS_MeshElement* anElement, + int Index) { - if (!myShapeIndexToSubMesh.IsBound(Index)) { - Handle(SMESHDS_SubMesh) SM = new SMESHDS_SubMesh (this); - myShapeIndexToSubMesh.Bind(Index,SM); - } - myShapeIndexToSubMesh(Index)->AddElement (anElement); + if (myShapeIndexToSubMesh.find(Index)==myShapeIndexToSubMesh.end()) + myShapeIndexToSubMesh[Index]=new SMESHDS_SubMesh(this); + + myShapeIndexToSubMesh[Index]->AddElement(anElement); } diff --git a/src/SMESHDS/SMESHDS_Mesh.hxx b/src/SMESHDS/SMESHDS_Mesh.hxx index d7eccde86..ef18cb416 100644 --- a/src/SMESHDS/SMESHDS_Mesh.hxx +++ b/src/SMESHDS/SMESHDS_Mesh.hxx @@ -27,171 +27,87 @@ #ifndef _SMESHDS_Mesh_HeaderFile #define _SMESHDS_Mesh_HeaderFile -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Handle_SMESHDS_Mesh_HeaderFile -#include "Handle_SMESHDS_Mesh.hxx" -#endif +#include "SMDS_Mesh.hxx" +#include "SMDS_MeshNode.hxx" +#include "SMDS_MeshEdge.hxx" +#include "SMDS_MeshFace.hxx" +#include "SMDS_MeshVolume.hxx" +#include "SMESHDS_Hypothesis.hxx" +#include "SMESHDS_SubMesh.hxx" +#include "SMESHDS_Script.hxx" -#ifndef _Standard_Integer_HeaderFile -#include -#endif -#ifndef _TopoDS_Shape_HeaderFile +#include #include -#endif -#ifndef _TopoDS_Shell_HeaderFile #include -#endif -#ifndef _TopTools_IndexedMapOfShape_HeaderFile -#include -#endif -#ifndef _SMESHDS_DataMapOfIntegerSubMesh_HeaderFile -#include "SMESHDS_DataMapOfIntegerSubMesh.hxx" -#endif -#ifndef _SMESHDS_DataMapOfShapeListOfPtrHypothesis_HeaderFile -#include "SMESHDS_DataMapOfShapeListOfPtrHypothesis.hxx" -#endif -#ifndef _Handle_SMESHDS_Script_HeaderFile -#include "Handle_SMESHDS_Script.hxx" -#endif -#ifndef _SMDS_Mesh_HeaderFile -#include "SMDS_Mesh.hxx" -#endif -#ifndef _Standard_Boolean_HeaderFile -#include -#endif -#ifndef _SMESHDS_PtrHypothesis_HeaderFile -#include "SMESHDS_PtrHypothesis.hxx" -#endif -#ifndef _Standard_Real_HeaderFile -#include -#endif -#ifndef _Handle_SMDS_MeshNode_HeaderFile -#include "Handle_SMDS_MeshNode.hxx" -#endif -#ifndef _Handle_SMDS_MeshElement_HeaderFile -#include "Handle_SMDS_MeshElement.hxx" -#endif -#ifndef _Handle_SMESHDS_SubMesh_HeaderFile -#include "Handle_SMESHDS_SubMesh.hxx" -#endif -class SMESHDS_Script; -class TopoDS_Shape; -class SMDS_MeshNode; -class TopoDS_Shell; -class TopoDS_Face; -class TopoDS_Edge; -class TopoDS_Vertex; -class SMDS_MeshElement; -class SMESHDS_SubMesh; -class SMESHDS_ListOfPtrHypothesis; - - -class SMESHDS_Mesh : public SMDS_Mesh { - -public: - - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // -Standard_EXPORT SMESHDS_Mesh(const Standard_Integer MeshID); -Standard_EXPORT void ShapeToMesh(const TopoDS_Shape& S) ; -Standard_EXPORT Standard_Boolean AddHypothesis(const TopoDS_Shape& SS,const SMESHDS_PtrHypothesis& H) ; -Standard_EXPORT Standard_Boolean RemoveHypothesis(const TopoDS_Shape& S,const SMESHDS_PtrHypothesis& H) ; -Standard_EXPORT virtual Standard_Integer AddNode(const Standard_Real x,const Standard_Real y,const Standard_Real z) ; -Standard_EXPORT virtual void RemoveNode(const Standard_Integer ID) ; -Standard_EXPORT void MoveNode(const Standard_Integer ID,const Standard_Real x,const Standard_Real y,const Standard_Real z) ; -Standard_EXPORT virtual Standard_Integer AddEdge(const Standard_Integer idnode1,const Standard_Integer idnode2) ; -Standard_EXPORT virtual Standard_Integer AddFace(const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3) ; -Standard_EXPORT virtual Standard_Integer AddFace(const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3,const Standard_Integer idnode4) ; -Standard_EXPORT virtual Standard_Integer AddVolume(const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3,const Standard_Integer idnode4) ; -Standard_EXPORT virtual Standard_Integer AddVolume(const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3,const Standard_Integer idnode4,const Standard_Integer idnode5) ; -Standard_EXPORT virtual Standard_Integer AddVolume(const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3,const Standard_Integer idnode4,const Standard_Integer idnode5,const Standard_Integer idnode6) ; -Standard_EXPORT virtual Standard_Integer AddVolume(const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3,const Standard_Integer idnode4,const Standard_Integer idnode5,const Standard_Integer idnode6,const Standard_Integer idnode7,const Standard_Integer idnode8) ; -Standard_EXPORT virtual void RemoveElement(const Standard_Integer IDelem) ; -Standard_EXPORT void SetNodeInVolume(const Handle(SMDS_MeshNode)& aNode,const TopoDS_Shell& S) ; -Standard_EXPORT void SetNodeOnFace(const Handle(SMDS_MeshNode)& aNode,const TopoDS_Face& S) ; -Standard_EXPORT void SetNodeOnEdge(const Handle(SMDS_MeshNode)& aNode,const TopoDS_Edge& S) ; -Standard_EXPORT void SetNodeOnVertex(const Handle(SMDS_MeshNode)& aNode,const TopoDS_Vertex& S) ; -Standard_EXPORT void UnSetNodeOnShape(const Handle(SMDS_MeshNode)& aNode) ; -Standard_EXPORT void SetMeshElementOnShape(const Handle(SMDS_MeshElement)& anElt,const TopoDS_Shape& S) ; -Standard_EXPORT void UnSetMeshElementOnShape(const Handle(SMDS_MeshElement)& anElt,const TopoDS_Shape& S) ; -Standard_EXPORT TopoDS_Shape ShapeToMesh() ; -Standard_EXPORT Standard_Boolean HasMeshElements(const TopoDS_Shape& S) ; -Standard_EXPORT Handle_SMESHDS_SubMesh MeshElements(const TopoDS_Shape& S) ; -Standard_EXPORT Standard_Boolean HasHypothesis(const TopoDS_Shape& S) ; -Standard_EXPORT const SMESHDS_ListOfPtrHypothesis& GetHypothesis(const TopoDS_Shape& S) ; -Standard_EXPORT const Handle_SMESHDS_Script& GetScript() ; -Standard_EXPORT void ClearScript() ; -Standard_EXPORT Standard_Integer ShapeToIndex(const TopoDS_Shape& aShape) ; -Standard_EXPORT TopoDS_Shape IndexToShape(const Standard_Integer ShapeIndex) ; -Standard_EXPORT void NewSubMesh(const Standard_Integer Index) ; -Standard_EXPORT void SetNodeInVolume(const Handle(SMDS_MeshNode)& aNode,const Standard_Integer Index) ; -Standard_EXPORT void SetNodeOnFace(const Handle(SMDS_MeshNode)& aNode,const Standard_Integer Index) ; -Standard_EXPORT void SetNodeOnEdge(const Handle(SMDS_MeshNode)& aNode,const Standard_Integer Index) ; -Standard_EXPORT void SetNodeOnVertex(const Handle(SMDS_MeshNode)& aNode,const Standard_Integer Index) ; -Standard_EXPORT void SetMeshElementOnShape(const Handle(SMDS_MeshElement)& anElt,const Standard_Integer Index) ; -Standard_EXPORT ~SMESHDS_Mesh(); - - - - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& SMESHDS_Mesh_Type_(); - Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // -Standard_Integer myMeshID; -TopoDS_Shape myShape; -TopTools_IndexedMapOfShape myIndexToShape; -SMESHDS_DataMapOfIntegerSubMesh myShapeIndexToSubMesh; -SMESHDS_DataMapOfShapeListOfPtrHypothesis myShapeToHypothesis; -Handle_SMESHDS_Script myScript; - - +#include +#include +#include +//Not portable see http://gcc.gnu.org/onlinedocs/libstdc++/faq/index.html#5_4 to know more. +#include +using namespace __gnu_cxx; + +using namespace std; + +class SMESHDS_Mesh:public SMDS_Mesh +{ + + public: + + SMESHDS_Mesh(int MeshID); + void ShapeToMesh(const TopoDS_Shape & S); + bool AddHypothesis(const TopoDS_Shape & SS, const SMESHDS_Hypothesis * H); + bool RemoveHypothesis(const TopoDS_Shape & S, const SMESHDS_Hypothesis * H); + SMDS_MeshNode * AddNode(double x, double y, double z); + virtual void RemoveNode(int ID); + void MoveNode(int ID, double x, double y, double z); + SMDS_MeshEdge* AddEdge(int idnode1, int idnode2); + SMDS_MeshFace* AddFace(int idnode1, int idnode2, int idnode3); + SMDS_MeshFace* AddFace(int idnode1, int idnode2, int idnode3, int idnode4); + SMDS_MeshVolume* AddVolume(int idnode1, int idnode2, int idnode3, int idnode4); + SMDS_MeshVolume* AddVolume(int idnode1, int idnode2, int idnode3, int idnode4, + int idnode5); + SMDS_MeshVolume* AddVolume(int idnode1, int idnode2, int idnode3, int idnode4, + int idnode5, int idnode6); + SMDS_MeshVolume* AddVolume(int idnode1, int idnode2, int idnode3, int idnode4, + int idnode5, int idnode6, int idnode7, int idnode8); + virtual void RemoveElement(int IDelem); + void SetNodeInVolume(SMDS_MeshNode * aNode, const TopoDS_Shell & S); + void SetNodeOnFace(SMDS_MeshNode * aNode, const TopoDS_Face & S); + void SetNodeOnEdge(SMDS_MeshNode * aNode, const TopoDS_Edge & S); + void SetNodeOnVertex(SMDS_MeshNode * aNode, const TopoDS_Vertex & S); + void UnSetNodeOnShape(const SMDS_MeshNode * aNode); + void SetMeshElementOnShape(const SMDS_MeshElement * anElt, + const TopoDS_Shape & S); + void UnSetMeshElementOnShape(const SMDS_MeshElement * anElt, + const TopoDS_Shape & S); + TopoDS_Shape ShapeToMesh() const; + bool HasMeshElements(const TopoDS_Shape & S); + SMESHDS_SubMesh * MeshElements(const TopoDS_Shape & S); + bool HasHypothesis(const TopoDS_Shape & S); + const list& GetHypothesis(const TopoDS_Shape & S) const; + SMESHDS_Script * GetScript(); + void ClearScript(); + int ShapeToIndex(const TopoDS_Shape & aShape); + TopoDS_Shape IndexToShape(int ShapeIndex); + void NewSubMesh(int Index); + void SetNodeInVolume(const SMDS_MeshNode * aNode, int Index); + void SetNodeOnFace(SMDS_MeshNode * aNode, int Index); + void SetNodeOnEdge(SMDS_MeshNode * aNode, int Index); + void SetNodeOnVertex(SMDS_MeshNode * aNode, int Index); + void SetMeshElementOnShape(const SMDS_MeshElement * anElt, int Index); + ~SMESHDS_Mesh(); + + private: + struct HashTopoDS_Shape + { + size_t operator()(const TopoDS_Shape& S) const {return S.HashCode(2147483647);} + }; + typedef hash_map,HashTopoDS_Shape > ShapeToHypothesis; + int myMeshID; + TopoDS_Shape myShape; + TopTools_IndexedMapOfShape myIndexToShape; + map myShapeIndexToSubMesh; + ShapeToHypothesis myShapeToHypothesis; + SMESHDS_Script * myScript; }; - - - - - -// other inline functions and methods (like "C++: function call" methods) -// - - #endif diff --git a/src/SMESHDS/SMESHDS_Script.cxx b/src/SMESHDS/SMESHDS_Script.cxx index 9a9d8fed8..f8d3aff53 100644 --- a/src/SMESHDS/SMESHDS_Script.cxx +++ b/src/SMESHDS/SMESHDS_Script.cxx @@ -27,297 +27,297 @@ // $Header: using namespace std; -#include "SMESHDS_Script.ixx" -#include "SMESHDS_Command.hxx" -#include "SMESHDS_CommandType.hxx" -#include "SMESHDS_ListOfCommand.hxx" +#include "SMESHDS_Script.hxx" //======================================================================= //function : //purpose : //======================================================================= -void SMESHDS_Script::AddNode(const Standard_Integer NewNodeID, - const Standard_Real x, - const Standard_Real y, - const Standard_Real z) +void SMESHDS_Script::AddNode(int NewNodeID, double x, double y, double z) { - Handle(SMESHDS_Command) com; - if (myCommands.IsEmpty()) { - com = new SMESHDS_Command(SMESHDS_AddNode); - myCommands.Append (com); - } - else { - com = myCommands.Last(); - if (com->GetType() != SMESHDS_AddNode) { - com = new SMESHDS_Command(SMESHDS_AddNode); - myCommands.Append (com); - } - } - com->AddNode (NewNodeID,x,y,z); + SMESHDS_Command* com; + if (myCommands.empty()) + { + com = new SMESHDS_Command(SMESHDS_AddNode); + myCommands.insert(myCommands.end(),com); + } + else + { + com = myCommands.back(); + if (com->GetType() != SMESHDS_AddNode) + { + com = new SMESHDS_Command(SMESHDS_AddNode); + myCommands.insert(myCommands.end(),com); + } + } + com->AddNode(NewNodeID, x, y, z); } - //======================================================================= //function : //purpose : //======================================================================= -void SMESHDS_Script::AddEdge(const Standard_Integer NewEdgeID, - const Standard_Integer idnode1, - const Standard_Integer idnode2) +void SMESHDS_Script::AddEdge(int NewEdgeID, int idnode1, int idnode2) { - Handle(SMESHDS_Command) com; - if (myCommands.IsEmpty()) { - com = new SMESHDS_Command(SMESHDS_AddEdge); - myCommands.Append (com); - } - else { - com = myCommands.Last(); - if (com->GetType() != SMESHDS_AddEdge) { - com = new SMESHDS_Command(SMESHDS_AddEdge); - myCommands.Append (com); - } - } - com->AddEdge (NewEdgeID,idnode1,idnode2); + SMESHDS_Command* com; + if (myCommands.empty()) + { + com = new SMESHDS_Command(SMESHDS_AddEdge); + myCommands.insert(myCommands.end(), com); + } + else + { + com = myCommands.back(); + if (com->GetType() != SMESHDS_AddEdge) + { + com = new SMESHDS_Command(SMESHDS_AddEdge); + myCommands.insert(myCommands.end(), com); + } + } + com->AddEdge(NewEdgeID, idnode1, idnode2); } //======================================================================= //function : //purpose : //======================================================================= -void SMESHDS_Script::AddFace(const Standard_Integer NewFaceID, - const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3) +void SMESHDS_Script::AddFace(int NewFaceID, + int idnode1, int idnode2, int idnode3) { - Handle(SMESHDS_Command) com; - if (myCommands.IsEmpty()) { - com = new SMESHDS_Command(SMESHDS_AddTriangle); - myCommands.Append (com); - } - else { - com = myCommands.Last(); - if (com->GetType() != SMESHDS_AddTriangle) { - com = new SMESHDS_Command(SMESHDS_AddTriangle); - myCommands.Append (com); - } - } - com->AddFace (NewFaceID,idnode1,idnode2,idnode3); + SMESHDS_Command * com; + if (myCommands.empty()) + { + com = new SMESHDS_Command(SMESHDS_AddTriangle); + myCommands.insert(myCommands.end(),com); + } + else + { + com = myCommands.back(); + if (com->GetType() != SMESHDS_AddTriangle) + { + com = new SMESHDS_Command(SMESHDS_AddTriangle); + myCommands.insert(myCommands.end(),com); + } + } + com->AddFace(NewFaceID, idnode1, idnode2, idnode3); } //======================================================================= //function : //purpose : //======================================================================= -void SMESHDS_Script::AddFace(const Standard_Integer NewFaceID, - const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3, - const Standard_Integer idnode4) +void SMESHDS_Script::AddFace(int NewFaceID, + int idnode1, int idnode2, int idnode3, int idnode4) { - Handle(SMESHDS_Command) com; - if (myCommands.IsEmpty()) { - com = new SMESHDS_Command(SMESHDS_AddQuadrangle); - myCommands.Append (com); - } - else { - com = myCommands.Last(); - if (com->GetType() != SMESHDS_AddQuadrangle) { - com = new SMESHDS_Command(SMESHDS_AddQuadrangle); - myCommands.Append (com); - } - } - com->AddFace (NewFaceID,idnode1,idnode2,idnode3,idnode4); + SMESHDS_Command * com; + if (myCommands.empty()) + { + com = new SMESHDS_Command(SMESHDS_AddQuadrangle); + myCommands.insert(myCommands.end(),com); + } + else + { + com = myCommands.back(); + if (com->GetType() != SMESHDS_AddQuadrangle) + { + com = new SMESHDS_Command(SMESHDS_AddQuadrangle); + myCommands.insert(myCommands.end(),com); + } + } + com->AddFace(NewFaceID, idnode1, idnode2, idnode3, idnode4); } //======================================================================= //function : //purpose : //======================================================================= -void SMESHDS_Script::AddVolume(const Standard_Integer NewID, - const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3, - const Standard_Integer idnode4) +void SMESHDS_Script::AddVolume(int NewID, + int idnode1, int idnode2, int idnode3, int idnode4) { - Handle(SMESHDS_Command) com; - if (myCommands.IsEmpty()) { - com = new SMESHDS_Command(SMESHDS_AddTetrahedron); - myCommands.Append (com); - } - else { - com = myCommands.Last(); - if (com->GetType() != SMESHDS_AddQuadrangle) { - com = new SMESHDS_Command(SMESHDS_AddQuadrangle); - myCommands.Append (com); - } - } - com->AddVolume (NewID,idnode1,idnode2,idnode3,idnode4); + SMESHDS_Command * com; + if (myCommands.empty()) + { + com = new SMESHDS_Command(SMESHDS_AddTetrahedron); + myCommands.insert(myCommands.end(),com); + } + else + { + com = myCommands.back(); + if (com->GetType() != SMESHDS_AddQuadrangle) + { + com = new SMESHDS_Command(SMESHDS_AddQuadrangle); + myCommands.insert(myCommands.end(),com); + } + } + com->AddVolume(NewID, idnode1, idnode2, idnode3, idnode4); } //======================================================================= //function : //purpose : //======================================================================= -void SMESHDS_Script::AddVolume(const Standard_Integer NewID, - const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3, - const Standard_Integer idnode4, - const Standard_Integer idnode5) +void SMESHDS_Script::AddVolume(int NewID, + int idnode1, int idnode2, int idnode3, int idnode4, int idnode5) { - Handle(SMESHDS_Command) com; - if (myCommands.IsEmpty()) { - com = new SMESHDS_Command(SMESHDS_AddPyramid); - myCommands.Append (com); - } - else { - com = myCommands.Last(); - if (com->GetType() != SMESHDS_AddPyramid) { - com = new SMESHDS_Command(SMESHDS_AddPyramid); - myCommands.Append (com); - } - } - com->AddVolume (NewID,idnode1,idnode2,idnode3,idnode4,idnode5); + SMESHDS_Command * com; + if (myCommands.empty()) + { + com = new SMESHDS_Command(SMESHDS_AddPyramid); + myCommands.insert(myCommands.end(),com); + } + else + { + com = myCommands.back(); + if (com->GetType() != SMESHDS_AddPyramid) + { + com = new SMESHDS_Command(SMESHDS_AddPyramid); + myCommands.insert(myCommands.end(),com); + } + } + com->AddVolume(NewID, idnode1, idnode2, idnode3, idnode4, idnode5); } //======================================================================= //function : //purpose : //======================================================================= -void SMESHDS_Script::AddVolume(const Standard_Integer NewID, - const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3, - const Standard_Integer idnode4, - const Standard_Integer idnode5, - const Standard_Integer idnode6) +void SMESHDS_Script::AddVolume(int NewID, + int idnode1, + int idnode2, int idnode3, int idnode4, int idnode5, int idnode6) { - Handle(SMESHDS_Command) com; - if (myCommands.IsEmpty()) { - com = new SMESHDS_Command(SMESHDS_AddPrism); - myCommands.Append (com); - } - else { - com = myCommands.Last(); - if (com->GetType() != SMESHDS_AddPrism) { - com = new SMESHDS_Command(SMESHDS_AddPrism); - myCommands.Append (com); - } - } - com->AddVolume (NewID,idnode1,idnode2,idnode3,idnode4,idnode5,idnode6); + SMESHDS_Command * com; + if (myCommands.empty()) + { + com = new SMESHDS_Command(SMESHDS_AddPrism); + myCommands.insert(myCommands.end(),com); + } + else + { + com = myCommands.back(); + if (com->GetType() != SMESHDS_AddPrism) + { + com = new SMESHDS_Command(SMESHDS_AddPrism); + myCommands.insert(myCommands.end(),com); + } + } + com->AddVolume(NewID, idnode1, idnode2, idnode3, idnode4, idnode5, idnode6); } //======================================================================= //function : //purpose : //======================================================================= -void SMESHDS_Script::AddVolume(const Standard_Integer NewID, - const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3, - const Standard_Integer idnode4, - const Standard_Integer idnode5, - const Standard_Integer idnode6, - const Standard_Integer idnode7, - const Standard_Integer idnode8) +void SMESHDS_Script::AddVolume(int NewID, + int idnode1, + int idnode2, + int idnode3, + int idnode4, int idnode5, int idnode6, int idnode7, int idnode8) { - Handle(SMESHDS_Command) com; - if (myCommands.IsEmpty()) { - com = new SMESHDS_Command(SMESHDS_AddHexahedron); - myCommands.Append (com); - } - else { - com = myCommands.Last(); - if (com->GetType() != SMESHDS_AddHexahedron) { - com = new SMESHDS_Command(SMESHDS_AddHexahedron); - myCommands.Append (com); - } - } - com->AddVolume (NewID,idnode1,idnode2,idnode3,idnode4, - idnode5,idnode6,idnode7,idnode8); + SMESHDS_Command * com; + if (myCommands.empty()) + { + com = new SMESHDS_Command(SMESHDS_AddHexahedron); + myCommands.insert(myCommands.end(),com); + } + else + { + com = myCommands.back(); + if (com->GetType() != SMESHDS_AddHexahedron) + { + com = new SMESHDS_Command(SMESHDS_AddHexahedron); + myCommands.insert(myCommands.end(),com); + } + } + com->AddVolume(NewID, idnode1, idnode2, idnode3, idnode4, + idnode5, idnode6, idnode7, idnode8); } //======================================================================= //function : //purpose : //======================================================================= -void SMESHDS_Script::MoveNode(const Standard_Integer NewNodeID, - const Standard_Real x, - const Standard_Real y, - const Standard_Real z) +void SMESHDS_Script::MoveNode(int NewNodeID, double x, double y, double z) { - Handle(SMESHDS_Command) com; - if (myCommands.IsEmpty()) { - com = new SMESHDS_Command(SMESHDS_MoveNode); - myCommands.Append (com); - } - else { - com = myCommands.Last(); - if (com->GetType() != SMESHDS_MoveNode) { - com = new SMESHDS_Command(SMESHDS_MoveNode); - myCommands.Append (com); - } - } - com->MoveNode (NewNodeID,x,y,z); + SMESHDS_Command * com; + if (myCommands.empty()) + { + com = new SMESHDS_Command(SMESHDS_MoveNode); + myCommands.insert(myCommands.end(),com); + } + else + { + com = myCommands.back(); + if (com->GetType() != SMESHDS_MoveNode) + { + com = new SMESHDS_Command(SMESHDS_MoveNode); + myCommands.insert(myCommands.end(),com); + } + } + com->MoveNode(NewNodeID, x, y, z); } - //======================================================================= //function : //purpose : //======================================================================= -void SMESHDS_Script::RemoveNode(const Standard_Integer ID) +void SMESHDS_Script::RemoveNode(int ID) { - Handle(SMESHDS_Command) com; - if (myCommands.IsEmpty()) { - com = new SMESHDS_Command(SMESHDS_RemoveNode); - myCommands.Append (com); - } - else { - com = myCommands.Last(); - if (com->GetType() != SMESHDS_RemoveNode) { - com = new SMESHDS_Command(SMESHDS_RemoveNode); - myCommands.Append (com); - } - } - com->RemoveNode (ID); + SMESHDS_Command * com; + if (myCommands.empty()) + { + com = new SMESHDS_Command(SMESHDS_RemoveNode); + myCommands.insert(myCommands.end(),com); + } + else + { + com = myCommands.back(); + if (com->GetType() != SMESHDS_RemoveNode) + { + com = new SMESHDS_Command(SMESHDS_RemoveNode); + myCommands.insert(myCommands.end(),com); + } + } + com->RemoveNode(ID); } //======================================================================= //function : //purpose : //======================================================================= - void SMESHDS_Script::RemoveElement(const Standard_Integer ElementID) +void SMESHDS_Script::RemoveElement(int ElementID) { - Handle(SMESHDS_Command) com; - if (myCommands.IsEmpty()) { - com = new SMESHDS_Command(SMESHDS_RemoveElement); - myCommands.Append (com); - } - else { - com = myCommands.Last(); - if (com->GetType() != SMESHDS_RemoveElement) { - com = new SMESHDS_Command(SMESHDS_RemoveElement); - myCommands.Append (com); - } - } - com->RemoveElement (ElementID); + SMESHDS_Command * com; + if (myCommands.empty()) + { + com = new SMESHDS_Command(SMESHDS_RemoveElement); + myCommands.insert(myCommands.end(),com); + } + else + { + com = myCommands.back(); + if (com->GetType() != SMESHDS_RemoveElement) + { + com = new SMESHDS_Command(SMESHDS_RemoveElement); + myCommands.insert(myCommands.end(),com); + } + } + com->RemoveElement(ElementID); } //======================================================================= //function : //purpose : //======================================================================= -void SMESHDS_Script::Clear() +void SMESHDS_Script::Clear() { - myCommands.Clear(); + myCommands.clear(); } //======================================================================= //function : //purpose : //======================================================================= -const SMESHDS_ListOfCommand& SMESHDS_Script::GetCommands() +const list& SMESHDS_Script::GetCommands() { - return myCommands; + return myCommands; } diff --git a/src/SMESHDS/SMESHDS_Script.hxx b/src/SMESHDS/SMESHDS_Script.hxx index 2183cc5f0..8a67c98fe 100644 --- a/src/SMESHDS/SMESHDS_Script.hxx +++ b/src/SMESHDS/SMESHDS_Script.hxx @@ -27,103 +27,35 @@ #ifndef _SMESHDS_Script_HeaderFile #define _SMESHDS_Script_HeaderFile -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Handle_SMESHDS_Script_HeaderFile -#include "Handle_SMESHDS_Script.hxx" -#endif - -#ifndef _SMESHDS_ListOfCommand_HeaderFile -#include "SMESHDS_ListOfCommand.hxx" -#endif -#ifndef _MMgt_TShared_HeaderFile -#include -#endif -#ifndef _Standard_Integer_HeaderFile -#include -#endif -#ifndef _Standard_Real_HeaderFile -#include -#endif -class SMESHDS_ListOfCommand; - - -class SMESHDS_Script : public MMgt_TShared { - -public: - - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // -Standard_EXPORT void AddNode(const Standard_Integer NewNodeID,const Standard_Real x,const Standard_Real y,const Standard_Real z) ; -Standard_EXPORT void AddEdge(const Standard_Integer NewEdgeID,const Standard_Integer idnode1,const Standard_Integer idnode2) ; -Standard_EXPORT void AddFace(const Standard_Integer NewFaceID,const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3) ; -Standard_EXPORT void AddFace(const Standard_Integer NewFaceID,const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3,const Standard_Integer idnode4) ; -Standard_EXPORT void AddVolume(const Standard_Integer NewVolID,const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3,const Standard_Integer idnode4) ; -Standard_EXPORT void AddVolume(const Standard_Integer NewVolID,const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3,const Standard_Integer idnode4,const Standard_Integer idnode5) ; -Standard_EXPORT void AddVolume(const Standard_Integer NewVolID,const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3,const Standard_Integer idnode4,const Standard_Integer idnode5,const Standard_Integer idnode6) ; -Standard_EXPORT void AddVolume(const Standard_Integer NewVolID,const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3,const Standard_Integer idnode4,const Standard_Integer idnode5,const Standard_Integer idnode6,const Standard_Integer idnode7,const Standard_Integer idnode8) ; -Standard_EXPORT void MoveNode(const Standard_Integer NewNodeID,const Standard_Real x,const Standard_Real y,const Standard_Real z) ; -Standard_EXPORT void RemoveNode(const Standard_Integer NodeID) ; -Standard_EXPORT void RemoveElement(const Standard_Integer ElementID) ; -Standard_EXPORT void Clear() ; -Standard_EXPORT const SMESHDS_ListOfCommand& GetCommands() ; -Standard_EXPORT ~SMESHDS_Script(); - - - - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& SMESHDS_Script_Type_(); - Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // -SMESHDS_ListOfCommand myCommands; - - +#include "SMESHDS_Command.hxx" +#include +using namespace std; + +class SMESHDS_Script +{ + public: + void AddNode(int NewNodeID, double x, double y, double z); + void AddEdge(int NewEdgeID, int idnode1, int idnode2); + void AddFace(int NewFaceID, int idnode1, int idnode2, int idnode3); + void AddFace(int NewFaceID, int idnode1, int idnode2, int idnode3, + int idnode4); + void AddVolume(int NewVolID, int idnode1, int idnode2, int idnode3, + int idnode4); + void AddVolume(int NewVolID, int idnode1, int idnode2, int idnode3, + int idnode4, int idnode5); + void AddVolume(int NewVolID, int idnode1, int idnode2, int idnode3, + int idnode4, int idnode5, int idnode6); + void AddVolume(int NewVolID, int idnode1, int idnode2, int idnode3, + int idnode4, int idnode5, int idnode6, int idnode7, int idnode8); + void MoveNode(int NewNodeID, double x, double y, double z); + void RemoveNode(int NodeID); + void RemoveElement(int ElementID); + void Clear(); + const list & GetCommands(); + ~SMESHDS_Script(); + + private: + list myCommands; }; - - - - -// other inline functions and methods (like "C++: function call" methods) -// - - #endif diff --git a/src/SMESHDS/SMESHDS_SubMesh.cxx b/src/SMESHDS/SMESHDS_SubMesh.cxx index f38b346c5..e2e1494ad 100644 --- a/src/SMESHDS/SMESHDS_SubMesh.cxx +++ b/src/SMESHDS/SMESHDS_SubMesh.cxx @@ -27,121 +27,128 @@ // $Header: using namespace std; -#include "SMESHDS_SubMesh.ixx" -#include "SMDS_MapIteratorOfExtendedMap.hxx" +#include "SMESHDS_SubMesh.hxx" //======================================================================= //function : SMESHDS_SubMesh //purpose : //======================================================================= -SMESHDS_SubMesh::SMESHDS_SubMesh(const Handle(SMDS_Mesh)& M) : myMesh(M) +SMESHDS_SubMesh::SMESHDS_SubMesh(const SMDS_Mesh * M):myMesh(M) { - myListOfEltIDIsUpdate = Standard_False; - myListOfNodeIDIsUpdate = Standard_False; + myListOfEltIDIsUpdate = false; + myListOfNodeIDIsUpdate = false; } //======================================================================= //function : AddElement //purpose : //======================================================================= -void SMESHDS_SubMesh::AddElement (const Handle(SMDS_MeshElement)& ME) +void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME) { - myElements.Add(ME); - myListOfEltIDIsUpdate = Standard_False; + myElements.insert(ME); + myListOfEltIDIsUpdate = false; } //======================================================================= //function : RemoveElement //purpose : //======================================================================= -void SMESHDS_SubMesh::RemoveElement(const Handle(SMDS_MeshElement)& ME) +void SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME) { - myElements.Remove(ME); - myListOfEltIDIsUpdate = Standard_False; + myElements.erase(ME); + myListOfEltIDIsUpdate = false; } + //======================================================================= //function : AddNode //purpose : //======================================================================= -void SMESHDS_SubMesh::AddNode (const Handle(SMDS_MeshNode)& N) +void SMESHDS_SubMesh::AddNode(const SMDS_MeshNode * N) { - myNodes.Add(N); - myListOfNodeIDIsUpdate = Standard_False; + myNodes.insert(N); + myListOfNodeIDIsUpdate = false; } //======================================================================= //function : RemoveNode //purpose : //======================================================================= -void SMESHDS_SubMesh::RemoveNode (const Handle(SMDS_MeshNode)& N) +void SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N) { - myNodes.Remove(N); - myListOfNodeIDIsUpdate = Standard_False; + myNodes.erase(N); + myListOfNodeIDIsUpdate = false; } //======================================================================= //function : NbElements //purpose : //======================================================================= -Standard_Integer SMESHDS_SubMesh::NbElements() +int SMESHDS_SubMesh::NbElements() const { - return myElements.Extent(); + return myElements.size(); } //======================================================================= //function : GetElements //purpose : //======================================================================= -const SMDS_MapOfMeshElement& SMESHDS_SubMesh::GetElements() +const set & SMESHDS_SubMesh::GetElements() { - return myElements; + return myElements; } + //======================================================================= //function : NbNodes //purpose : //======================================================================= -Standard_Integer SMESHDS_SubMesh::NbNodes() +int SMESHDS_SubMesh::NbNodes() const { - return myNodes.Extent(); + return myNodes.size(); } //======================================================================= //function : GetNodes //purpose : //======================================================================= -const SMDS_MapOfMeshElement& SMESHDS_SubMesh::GetNodes() +const set & SMESHDS_SubMesh::GetNodes() const { - return myNodes; + return myNodes; } //======================================================================= //function : GetIDElements //purpose : //======================================================================= -const TColStd_ListOfInteger& SMESHDS_SubMesh::GetIDElements() +const vector & SMESHDS_SubMesh::GetIDElements() { - if (!myListOfEltIDIsUpdate) { - myListOfEltID.Clear(); - for (SMDS_MapIteratorOfExtendedMap it(myElements); it.More(); it.Next()) { - myListOfEltID.Append(it.Key()->GetID()); - } - myListOfEltIDIsUpdate = Standard_True; - } - return myListOfEltID; + if (!myListOfEltIDIsUpdate) + { + myListOfEltID.clear(); + set::iterator it=myElements.begin(); + for (; it!=myElements.end(); it++) + { + myListOfEltID.push_back((*it)->GetID()); + } + myListOfEltIDIsUpdate = true; + } + return myListOfEltID; } //======================================================================= //function : GetIDNodes //purpose : //======================================================================= -const TColStd_ListOfInteger& SMESHDS_SubMesh::GetIDNodes() +const vector & SMESHDS_SubMesh::GetIDNodes() { - if (!myListOfNodeIDIsUpdate) { - myListOfNodeID.Clear(); - for (SMDS_MapIteratorOfExtendedMap it(myNodes); it.More(); it.Next()) { - myListOfNodeID.Append(it.Key()->GetID()); - } - myListOfNodeIDIsUpdate = Standard_True; - } - return myListOfNodeID; + if (!myListOfNodeIDIsUpdate) + { + myListOfNodeID.clear(); + set::iterator it=myNodes.begin(); + for (; it!=myNodes.end(); it++) + { + myListOfNodeID.push_back((*it)->GetID()); + } + myListOfNodeIDIsUpdate = true; + } + return myListOfNodeID; } diff --git a/src/SMESHDS/SMESHDS_SubMesh.hxx b/src/SMESHDS/SMESHDS_SubMesh.hxx index a872c9c74..53802ecb4 100644 --- a/src/SMESHDS/SMESHDS_SubMesh.hxx +++ b/src/SMESHDS/SMESHDS_SubMesh.hxx @@ -27,123 +27,34 @@ #ifndef _SMESHDS_SubMesh_HeaderFile #define _SMESHDS_SubMesh_HeaderFile -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Handle_SMESHDS_SubMesh_HeaderFile -#include "Handle_SMESHDS_SubMesh.hxx" -#endif - -#ifndef _Handle_SMDS_Mesh_HeaderFile -#include "Handle_SMDS_Mesh.hxx" -#endif -#ifndef _SMDS_MapOfMeshElement_HeaderFile -#include "SMDS_MapOfMeshElement.hxx" -#endif -#ifndef _Standard_Boolean_HeaderFile -#include -#endif -#ifndef _TColStd_ListOfInteger_HeaderFile -#include -#endif -#ifndef _MMgt_TShared_HeaderFile -#include -#endif -#ifndef _Handle_SMDS_MeshElement_HeaderFile -#include "Handle_SMDS_MeshElement.hxx" -#endif -#ifndef _Handle_SMDS_MeshNode_HeaderFile -#include "Handle_SMDS_MeshNode.hxx" -#endif -#ifndef _Standard_Integer_HeaderFile -#include -#endif -class SMDS_Mesh; -class SMDS_MeshElement; -class SMDS_MeshNode; -class SMDS_MapOfMeshElement; -class TColStd_ListOfInteger; - - -class SMESHDS_SubMesh : public MMgt_TShared { - -public: - - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // -Standard_EXPORT SMESHDS_SubMesh(const Handle(SMDS_Mesh)& M); -Standard_EXPORT void AddElement(const Handle(SMDS_MeshElement)& ME) ; -Standard_EXPORT void RemoveElement(const Handle(SMDS_MeshElement)& ME) ; -Standard_EXPORT void AddNode(const Handle(SMDS_MeshNode)& ME) ; -Standard_EXPORT void RemoveNode(const Handle(SMDS_MeshNode)& ME) ; -Standard_EXPORT Standard_Integer NbElements() ; -Standard_EXPORT const SMDS_MapOfMeshElement& GetElements() ; -Standard_EXPORT const TColStd_ListOfInteger& GetIDElements() ; -Standard_EXPORT Standard_Integer NbNodes() ; -Standard_EXPORT const SMDS_MapOfMeshElement& GetNodes() ; -Standard_EXPORT const TColStd_ListOfInteger& GetIDNodes() ; -Standard_EXPORT ~SMESHDS_SubMesh(); - - - - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& SMESHDS_SubMesh_Type_(); - Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // -Handle_SMDS_Mesh myMesh; -SMDS_MapOfMeshElement myElements; -SMDS_MapOfMeshElement myNodes; -Standard_Boolean myListOfEltIDIsUpdate; -TColStd_ListOfInteger myListOfEltID; -Standard_Boolean myListOfNodeIDIsUpdate; -TColStd_ListOfInteger myListOfNodeID; - - +#include "SMDS_Mesh.hxx" +#include +#include + +using namespace std; + +class SMESHDS_SubMesh +{ + public: + SMESHDS_SubMesh(const SMDS_Mesh * M); + void AddElement(const SMDS_MeshElement * ME); + void RemoveElement(const SMDS_MeshElement * ME); + void AddNode(const SMDS_MeshNode * ME); + void RemoveNode(const SMDS_MeshNode * ME); + int NbElements() const; + const set & GetElements(); + const vector & GetIDElements(); + int NbNodes() const; + const set & GetNodes() const; + const vector & GetIDNodes(); + ~SMESHDS_SubMesh(); + private: + const SMDS_Mesh * myMesh; + set myElements; + set myNodes; + bool myListOfEltIDIsUpdate; + vector myListOfEltID; + bool myListOfNodeIDIsUpdate; + vector myListOfNodeID; }; - - - - - -// other inline functions and methods (like "C++: function call" methods) -// - - #endif -- 2.39.2