Skip to content

Commit

Permalink
add patch for SMDS (#53)
Browse files Browse the repository at this point in the history
* add patch for SMDS

* enable tests for mac

* Remove semicolon
  • Loading branch information
looooo authored Oct 6, 2021
1 parent 36faf9f commit df461bd
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 8 deletions.
11 changes: 3 additions & 8 deletions ci/conda/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ ninja install
cd ..
cd tests
./test_Catch
if [[ ${HOST} =~ .*apple.* ]]
then
echo "Skipping SMESH tests on OSX until they are fixed..."
else
./test_StdMeshers
./test_NETGENPlugin
./test_MEFISTO2
fi
./test_StdMeshers
./test_NETGENPlugin
./test_MEFISTO2
93 changes: 93 additions & 0 deletions patch/SMESH_SMDS.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
diff --git a/src/SMDS/SMDS_ElementFactory.cxx b/src/SMDS/SMDS_ElementFactory.cxx
index c3ab97c..5430921 100644
--- a/src/SMDS/SMDS_ElementFactory.cxx
+++ b/src/SMDS/SMDS_ElementFactory.cxx
@@ -524,9 +524,9 @@ SMDS_ElementChunk::SMDS_ElementChunk( SMDS_ElementFactory* factory, smIdType id0
if ( !myFactory )
return;
if ( myFactory->myIsNodal )
- myElements = new SMDS_MeshNode[ theChunkSize ];
+ myNodeElements.resize(theChunkSize);
else
- myElements = new SMDS_MeshCell[ theChunkSize ];
+ myCellElements.resize(theChunkSize);

myUsedRanges.mySet.reserve(2);
mySubIDRanges.mySet.insert( _ShapeIDRange( 0, 0 ));
@@ -542,7 +542,7 @@ SMDS_ElementChunk::SMDS_ElementChunk( SMDS_ElementFactory* factory, smIdType id0

SMDS_ElementChunk::~SMDS_ElementChunk()
{
- delete [] myElements;
+ // delete [] myElements;
myFactory->myChunksWithUnused.erase( this );
}

diff --git a/src/SMDS/SMDS_ElementFactory.hxx b/src/SMDS/SMDS_ElementFactory.hxx
index dcc00a3..cb216fd 100644
--- a/src/SMDS/SMDS_ElementFactory.hxx
+++ b/src/SMDS/SMDS_ElementFactory.hxx
@@ -26,6 +26,7 @@
#define _SMDS_ElementFactory_HeaderFile

#include "SMDS_MeshCell.hxx"
+#include "SMDS_MeshNode.hxx"
#include "SMDS_Position.hxx"

#include <Utils_SALOME_Exception.hxx>
@@ -371,7 +372,10 @@ typedef double TParam;
class SMDS_ElementChunk
{
SMDS_ElementFactory* myFactory; // holder of this chunk
- SMDS_MeshElement* myElements; // array of elements
+ // SMDS_MeshElement* myElements; // array of elements
+ std::vector<SMDS_MeshNode> myNodeElements; // array of node elements
+ std::vector<SMDS_MeshCell> myCellElements; // array of cell elements
+
smIdType my1stID; // ID of myElements[0]
TBitSet myMarkedSet; // mark some elements
TUsedRangeSet myUsedRanges; // ranges of used/unused elements
@@ -387,10 +391,25 @@ public:
~SMDS_ElementChunk();

//! Return an element by an index [0,ChunkSize()]
- SMDS_MeshElement* Element(int index) { return & myElements[index]; }
+ // SMDS_MeshElement* Element(int index) { return & myElements[index]; }
+ SMDS_MeshElement* Element(int index)
+ {
+ if (!myNodeElements.empty())
+ return &myNodeElements[index];
+ else
+ return &myCellElements[index];
+ }

//! Return an element by an index [0,ChunkSize()]
- const SMDS_MeshElement* Element(int index) const { return & myElements[index]; }
+ // const SMDS_MeshElement* Element(int index) const { return & myElements[index]; }
+ const SMDS_MeshElement* Element(int index) const
+ {
+ if (!myNodeElements.empty())
+ return &myNodeElements[index];
+ else
+ return &myCellElements[index];
+ }
+

//! Return ID of the first non-used element
smIdType GetUnusedID() const;
@@ -405,7 +424,14 @@ public:
static bool IsUsed( const _UsedRange& r ) { return r.myValue; }

//! Return index of an element in the chunk
- int Index( const SMDS_MeshElement* e ) const { return (int)( e - myElements ); }
+ // int Index( const SMDS_MeshElement* e ) const { return (int)( e - myElements ); }
+ int Index( const SMDS_MeshElement* e ) const
+ {
+ if (!myNodeElements.empty())
+ return (int)( static_cast<const SMDS_MeshNode*>(e) - myNodeElements.data() );
+ else
+ return (int)( static_cast<const SMDS_MeshCell*>(e) - myCellElements.data() );
+ }

//! Return ID of the 1st element in the chunk
smIdType Get1stID() const { return my1stID; }
6 changes: 6 additions & 0 deletions prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ def prepare_smesh():
if not success:
raise RuntimeError('Failed to apply mefisto patch.')

# Patch sources
pset = patch.fromfile('patch/SMESH_SMDS.patch')
success = pset.apply(strip=0, root='src/SMESH')
if not success:
raise RuntimeError('Failed to apply SMESH_SMDS patch.')

# Copy MeshVSLink sources
shutil.copytree('extra/MeshVSLink',
'src/SMESH/src/MeshVSLink', dirs_exist_ok=True)
Expand Down

0 comments on commit df461bd

Please sign in to comment.