take care of segments in mesh on export
This commit is contained in:
parent
adffaf7533
commit
435cc3786d
|
@ -59,6 +59,16 @@ using namespace MeshCore;
|
|||
namespace Mesh {
|
||||
class Module : public Py::ExtensionModule<Module>
|
||||
{
|
||||
struct add_offset {
|
||||
unsigned long i;
|
||||
add_offset(unsigned long i) : i(i)
|
||||
{
|
||||
}
|
||||
void operator()(unsigned long& v)
|
||||
{
|
||||
v += i;
|
||||
}
|
||||
};
|
||||
public:
|
||||
Module() : Py::ExtensionModule<Module>("Mesh")
|
||||
{
|
||||
|
@ -307,13 +317,36 @@ private:
|
|||
else
|
||||
global_mesh.addMesh(kernel);
|
||||
|
||||
// now create a segment for the added mesh
|
||||
std::vector<unsigned long> indices;
|
||||
indices.resize(global_mesh.countFacets() - countFacets);
|
||||
std::generate(indices.begin(), indices.end(), Base::iotaGen<unsigned long>(countFacets));
|
||||
Segment segm(&global_mesh, indices, true);
|
||||
segm.setName(obj->Label.getValue());
|
||||
global_mesh.addSegment(segm);
|
||||
// if the mesh already has persistent segments then use them instead
|
||||
unsigned long numSegm = mesh.countSegments();
|
||||
unsigned long canSave = 0;
|
||||
for (unsigned long i=0; i<numSegm; i++) {
|
||||
if (mesh.getSegment(i).isSaved())
|
||||
canSave++;
|
||||
}
|
||||
|
||||
if (canSave > 0) {
|
||||
for (unsigned long i=0; i<numSegm; i++) {
|
||||
const Segment& segm = mesh.getSegment(i);
|
||||
if (segm.isSaved()) {
|
||||
std::vector<unsigned long> indices = segm.getIndices();
|
||||
std::for_each(indices.begin(), indices.end(), add_offset(countFacets));
|
||||
Segment new_segm(&global_mesh, indices, true);
|
||||
new_segm.setName(segm.getName());
|
||||
global_mesh.addSegment(new_segm);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
// now create a segment for the added mesh
|
||||
std::vector<unsigned long> indices;
|
||||
indices.resize(global_mesh.countFacets() - countFacets);
|
||||
std::generate(indices.begin(), indices.end(), Base::iotaGen<unsigned long>(countFacets));
|
||||
Segment segm(&global_mesh, indices, true);
|
||||
segm.setName(obj->Label.getValue());
|
||||
global_mesh.addSegment(segm);
|
||||
}
|
||||
}
|
||||
else if (obj->getTypeId().isDerivedFrom(partId)) {
|
||||
App::Property* shape = obj->getPropertyByName("Shape");
|
||||
|
|
|
@ -1619,6 +1619,7 @@ void MeshObject::addSegment(const Segment& s)
|
|||
addSegment(s.getIndices());
|
||||
this->_segments.back().setName(s.getName());
|
||||
this->_segments.back().save(s.isSaved());
|
||||
this->_segments.back()._modifykernel = s._modifykernel;
|
||||
}
|
||||
|
||||
void MeshObject::addSegment(const std::vector<unsigned long>& inds)
|
||||
|
|
Loading…
Reference in New Issue
Block a user