remake the position handling on the C++ side
This commit is contained in:
parent
125b2f3543
commit
cd19d8155c
|
@ -163,7 +163,6 @@ protected:
|
|||
return Base::Vector3f((float)tmp.x,(float)tmp.y,(float)tmp.z);
|
||||
}
|
||||
|
||||
//Base::Matrix4D _Mtrx;
|
||||
};
|
||||
|
||||
} //namespace App
|
||||
|
|
|
@ -71,6 +71,7 @@ Py::Object ComplexGeoDataPy::getMatrix(void) const
|
|||
return Py::Matrix(getComplexGeoDataPtr()->getTransform());
|
||||
}
|
||||
|
||||
// FIXME would be better to call it setTransform() as in all other interfaces...
|
||||
void ComplexGeoDataPy::setMatrix(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
|
|
|
@ -125,6 +125,8 @@ void FemMesh::copyMeshData(const FemMesh& mesh)
|
|||
//int numPris = info.NbPrisms();
|
||||
//int numHedr = info.NbPolyhedrons();
|
||||
|
||||
_Mtrx = mesh._Mtrx;
|
||||
|
||||
SMESHDS_Mesh* meshds = this->myMesh->GetMeshDS();
|
||||
meshds->ClearMesh();
|
||||
|
||||
|
@ -415,6 +417,8 @@ void FemMesh::readNastran(const std::string &Filename)
|
|||
Base::TimeInfo Start;
|
||||
Base::Console().Log("Start: FemMesh::readNastran() =================================\n");
|
||||
|
||||
_Mtrx = Base::Matrix4D();
|
||||
|
||||
std::ifstream inputfile;
|
||||
inputfile.open(Filename.c_str());
|
||||
inputfile.seekg(std::ifstream::beg);
|
||||
|
@ -575,6 +579,7 @@ void FemMesh::readNastran(const std::string &Filename)
|
|||
void FemMesh::read(const char *FileName)
|
||||
{
|
||||
Base::FileInfo File(FileName);
|
||||
_Mtrx = Base::Matrix4D();
|
||||
|
||||
// checking on the file
|
||||
if (!File.isReadable())
|
||||
|
@ -604,7 +609,7 @@ void FemMesh::read(const char *FileName)
|
|||
}
|
||||
}
|
||||
|
||||
void FemMesh::writeABAQUS(const std::string &Filename, Base::Placement* placement) const
|
||||
void FemMesh::writeABAQUS(const std::string &Filename) const
|
||||
{
|
||||
std::ofstream anABAQUS_Output;
|
||||
anABAQUS_Output.open(Filename.c_str());
|
||||
|
@ -612,29 +617,16 @@ void FemMesh::writeABAQUS(const std::string &Filename, Base::Placement* placemen
|
|||
|
||||
//Extract Nodes and Elements of the current SMESH datastructure
|
||||
SMDS_NodeIteratorPtr aNodeIter = myMesh->GetMeshDS()->nodesIterator();
|
||||
if (placement)
|
||||
{
|
||||
Base::Vector3d current_node;
|
||||
Base::Matrix4D matrix = placement->toMatrix();
|
||||
for (;aNodeIter->more();) {
|
||||
const SMDS_MeshNode* aNode = aNodeIter->next();
|
||||
current_node.Set(aNode->X(),aNode->Y(),aNode->Z());
|
||||
current_node = matrix * current_node;
|
||||
anABAQUS_Output << aNode->GetID() << ","
|
||||
<< current_node.x << ","
|
||||
<< current_node.y << ","
|
||||
<< current_node.z << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (;aNodeIter->more();) {
|
||||
const SMDS_MeshNode* aNode = aNodeIter->next();
|
||||
anABAQUS_Output << aNode->GetID() << ","
|
||||
<< aNode->X() << ","
|
||||
<< aNode->Y() << ","
|
||||
<< aNode->Z() << std::endl;
|
||||
}
|
||||
|
||||
Base::Vector3d current_node;
|
||||
for (;aNodeIter->more();) {
|
||||
const SMDS_MeshNode* aNode = aNodeIter->next();
|
||||
current_node.Set(aNode->X(),aNode->Y(),aNode->Z());
|
||||
current_node = _Mtrx * current_node;
|
||||
anABAQUS_Output << aNode->GetID() << ","
|
||||
<< current_node.x << ","
|
||||
<< current_node.y << ","
|
||||
<< current_node.z << std::endl;
|
||||
}
|
||||
|
||||
anABAQUS_Output << "*Element, TYPE=C3D10, ELSET=Eall" << std::endl;
|
||||
|
@ -725,10 +717,49 @@ unsigned int FemMesh::getMemSize (void) const
|
|||
|
||||
void FemMesh::Save (Base::Writer &writer) const
|
||||
{
|
||||
//See SaveDocFile(), RestoreDocFile()
|
||||
writer.Stream() << writer.ind() << "<FemMesh file=\"" ;
|
||||
writer.Stream() << writer.addFile("FemMesh.unv", this) << "\"";
|
||||
writer.Stream() << " a11=\"" << _Mtrx[0][0] << "\" a12=\"" << _Mtrx[0][1] << "\" a13=\"" << _Mtrx[0][2] << "\" a14=\"" << _Mtrx[0][3] << "\"";
|
||||
writer.Stream() << " a21=\"" << _Mtrx[1][0] << "\" a22=\"" << _Mtrx[1][1] << "\" a23=\"" << _Mtrx[1][2] << "\" a24=\"" << _Mtrx[1][3] << "\"";
|
||||
writer.Stream() << " a31=\"" << _Mtrx[2][0] << "\" a32=\"" << _Mtrx[2][1] << "\" a33=\"" << _Mtrx[2][2] << "\" a34=\"" << _Mtrx[2][3] << "\"";
|
||||
writer.Stream() << " a41=\"" << _Mtrx[3][0] << "\" a42=\"" << _Mtrx[3][1] << "\" a43=\"" << _Mtrx[3][2] << "\" a44=\"" << _Mtrx[3][3] << "\"";
|
||||
writer.Stream() << "/>" << std::endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void FemMesh::Restore(Base::XMLReader &reader)
|
||||
{
|
||||
|
||||
reader.readElement("FemMesh");
|
||||
std::string file (reader.getAttribute("file") );
|
||||
|
||||
if (!file.empty()) {
|
||||
// initate a file read
|
||||
reader.addFile(file.c_str(),this);
|
||||
}
|
||||
if( reader.hasAttribute("a11")){
|
||||
_Mtrx[0][0] = (float)reader.getAttributeAsFloat("a11");
|
||||
_Mtrx[0][1] = (float)reader.getAttributeAsFloat("a12");
|
||||
_Mtrx[0][2] = (float)reader.getAttributeAsFloat("a13");
|
||||
_Mtrx[0][3] = (float)reader.getAttributeAsFloat("a14");
|
||||
|
||||
_Mtrx[1][0] = (float)reader.getAttributeAsFloat("a21");
|
||||
_Mtrx[1][1] = (float)reader.getAttributeAsFloat("a22");
|
||||
_Mtrx[1][2] = (float)reader.getAttributeAsFloat("a23");
|
||||
_Mtrx[1][3] = (float)reader.getAttributeAsFloat("a24");
|
||||
|
||||
_Mtrx[2][0] = (float)reader.getAttributeAsFloat("a31");
|
||||
_Mtrx[2][1] = (float)reader.getAttributeAsFloat("a32");
|
||||
_Mtrx[2][2] = (float)reader.getAttributeAsFloat("a33");
|
||||
_Mtrx[2][3] = (float)reader.getAttributeAsFloat("a34");
|
||||
|
||||
_Mtrx[3][0] = (float)reader.getAttributeAsFloat("a41");
|
||||
_Mtrx[3][1] = (float)reader.getAttributeAsFloat("a42");
|
||||
_Mtrx[3][2] = (float)reader.getAttributeAsFloat("a43");
|
||||
_Mtrx[3][3] = (float)reader.getAttributeAsFloat("a44");
|
||||
}
|
||||
}
|
||||
|
||||
void FemMesh::SaveDocFile (Base::Writer &writer) const
|
||||
|
@ -795,12 +826,12 @@ void FemMesh::transformGeometry(const Base::Matrix4D& rclTrf)
|
|||
void FemMesh::setTransform(const Base::Matrix4D& rclTrf)
|
||||
{
|
||||
// Placement handling, no geometric transformation
|
||||
_Mtrx = rclTrf;
|
||||
}
|
||||
|
||||
Base::Matrix4D FemMesh::getTransform(void) const
|
||||
{
|
||||
Base::Matrix4D mtrx;
|
||||
return mtrx;
|
||||
return _Mtrx;
|
||||
}
|
||||
|
||||
Base::BoundBox3d FemMesh::getBoundBox(void) const
|
||||
|
@ -812,7 +843,10 @@ Base::BoundBox3d FemMesh::getBoundBox(void) const
|
|||
SMDS_NodeIteratorPtr aNodeIter = data->nodesIterator();
|
||||
for (;aNodeIter->more();) {
|
||||
const SMDS_MeshNode* aNode = aNodeIter->next();
|
||||
box.Add(Base::Vector3d(aNode->X(),aNode->Y(),aNode->Z()));
|
||||
Base::Vector3d vec(aNode->X(),aNode->Y(),aNode->Z());
|
||||
// Apply the matrix to hold the BoundBox in absolute space.
|
||||
vec = _Mtrx * vec;
|
||||
box.Add(vec);
|
||||
}
|
||||
|
||||
return box;
|
||||
|
|
|
@ -107,7 +107,7 @@ public:
|
|||
/// import from files
|
||||
void read(const char *FileName);
|
||||
void write(const char *FileName) const;
|
||||
void writeABAQUS(const std::string &Filename, Base::Placement* = 0) const;
|
||||
void writeABAQUS(const std::string &Filename) const;
|
||||
|
||||
private:
|
||||
void copyMeshData(const FemMesh&);
|
||||
|
|
|
@ -138,23 +138,12 @@ unsigned int PropertyFemMesh::getMemSize (void) const
|
|||
|
||||
void PropertyFemMesh::Save (Base::Writer &writer) const
|
||||
{
|
||||
if (!writer.isForceXML()) {
|
||||
//See SaveDocFile(), RestoreDocFile()
|
||||
writer.Stream() << writer.ind() << "<FemMesh file=\""
|
||||
<< writer.addFile("FemMesh.unv", this)
|
||||
<< "\"/>" << std::endl;
|
||||
}
|
||||
_FemMesh->Save(writer);
|
||||
}
|
||||
|
||||
void PropertyFemMesh::Restore(Base::XMLReader &reader)
|
||||
{
|
||||
reader.readElement("FemMesh");
|
||||
std::string file (reader.getAttribute("file") );
|
||||
|
||||
if (!file.empty()) {
|
||||
// initate a file read
|
||||
reader.addFile(file.c_str(),this);
|
||||
}
|
||||
_FemMesh->Restore(reader);
|
||||
}
|
||||
|
||||
void PropertyFemMesh::SaveDocFile (Base::Writer &writer) const
|
||||
|
|
|
@ -400,17 +400,11 @@ PyObject* FemMeshPy::write(PyObject *args)
|
|||
PyObject* FemMeshPy::writeABAQUS(PyObject *args)
|
||||
{
|
||||
char* filename;
|
||||
PyObject* plm=0;
|
||||
if (!PyArg_ParseTuple(args, "s|O!", &filename, &(Base::PlacementPy::Type),&plm))
|
||||
if (!PyArg_ParseTuple(args, "s", &filename))
|
||||
return 0;
|
||||
|
||||
try {
|
||||
Base::Placement* placement = 0;
|
||||
if (plm) {
|
||||
placement = static_cast<Base::PlacementPy*>(plm)->getPlacementPtr();
|
||||
}
|
||||
|
||||
getFemMeshPtr()->writeABAQUS(filename, placement);
|
||||
getFemMeshPtr()->writeABAQUS(filename);
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
PyErr_SetString(PyExc_Exception, e.what());
|
||||
|
|
Loading…
Reference in New Issue
Block a user