casts clean (#11548)
* remove unecessary casts clean unused code revert example py code * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -2540,25 +2540,25 @@ void FemMesh::Restore(Base::XMLReader& reader)
|
||||
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[0][0] = reader.getAttributeAsFloat("a11");
|
||||
_Mtrx[0][1] = reader.getAttributeAsFloat("a12");
|
||||
_Mtrx[0][2] = reader.getAttributeAsFloat("a13");
|
||||
_Mtrx[0][3] = 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[1][0] = reader.getAttributeAsFloat("a21");
|
||||
_Mtrx[1][1] = reader.getAttributeAsFloat("a22");
|
||||
_Mtrx[1][2] = reader.getAttributeAsFloat("a23");
|
||||
_Mtrx[1][3] = 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[2][0] = reader.getAttributeAsFloat("a31");
|
||||
_Mtrx[2][1] = reader.getAttributeAsFloat("a32");
|
||||
_Mtrx[2][2] = reader.getAttributeAsFloat("a33");
|
||||
_Mtrx[2][3] = 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");
|
||||
_Mtrx[3][0] = reader.getAttributeAsFloat("a41");
|
||||
_Mtrx[3][1] = reader.getAttributeAsFloat("a42");
|
||||
_Mtrx[3][2] = reader.getAttributeAsFloat("a43");
|
||||
_Mtrx[3][3] = reader.getAttributeAsFloat("a44");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2707,25 +2707,7 @@ struct Fem::FemMesh::FemMeshInfo FemMesh::getInfo() const
|
||||
|
||||
return rtrn;
|
||||
}
|
||||
// for (unsigned int i = 0; i < all_elements.size(); i++)
|
||||
// {
|
||||
// // an consistent data structure is only possible
|
||||
// // if the elements are added in the right order
|
||||
// // thus the order is very important
|
||||
// meshds->AddVolumeWithID(
|
||||
// meshds->FindNode(all_elements[i][0]),
|
||||
// meshds->FindNode(all_elements[i][2]),
|
||||
// meshds->FindNode(all_elements[i][1]),
|
||||
// meshds->FindNode(all_elements[i][3]),
|
||||
// meshds->FindNode(all_elements[i][6]),
|
||||
// meshds->FindNode(all_elements[i][5]),
|
||||
// meshds->FindNode(all_elements[i][4]),
|
||||
// meshds->FindNode(all_elements[i][9]),
|
||||
// meshds->FindNode(all_elements[i][7]),
|
||||
// meshds->FindNode(all_elements[i][8]),
|
||||
// element_id[i]
|
||||
// );
|
||||
// }
|
||||
|
||||
|
||||
Base::Quantity FemMesh::getVolume() const
|
||||
{
|
||||
|
||||
@@ -260,9 +260,9 @@ PyObject* MeshPy::write(PyObject* args, PyObject* kwds)
|
||||
Py::Sequence list(List);
|
||||
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
|
||||
Py::Tuple t(*it);
|
||||
float r = (float)Py::Float(t.getItem(0));
|
||||
float g = (float)Py::Float(t.getItem(1));
|
||||
float b = (float)Py::Float(t.getItem(2));
|
||||
float r = Py::Float(t.getItem(0));
|
||||
float g = Py::Float(t.getItem(1));
|
||||
float b = Py::Float(t.getItem(2));
|
||||
mat.diffuseColor.emplace_back(r, g, b);
|
||||
}
|
||||
|
||||
@@ -313,9 +313,9 @@ PyObject* MeshPy::write(PyObject* args, PyObject* kwds)
|
||||
Py::Sequence list(List);
|
||||
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
|
||||
Py::Tuple t(*it);
|
||||
float r = (float)Py::Float(t.getItem(0));
|
||||
float g = (float)Py::Float(t.getItem(1));
|
||||
float b = (float)Py::Float(t.getItem(2));
|
||||
float r = Py::Float(t.getItem(0));
|
||||
float g = Py::Float(t.getItem(1));
|
||||
float b = Py::Float(t.getItem(2));
|
||||
mat->diffuseColor.emplace_back(r, g, b);
|
||||
}
|
||||
|
||||
@@ -416,12 +416,12 @@ PyObject* MeshPy::crossSections(PyObject* args)
|
||||
else if (p1.isTuple() && p2.isTuple()) {
|
||||
Py::Tuple b(p1);
|
||||
Py::Tuple n(p2);
|
||||
float bx = (float)Py::Float(b.getItem(0));
|
||||
float by = (float)Py::Float(b.getItem(1));
|
||||
float bz = (float)Py::Float(b.getItem(2));
|
||||
float nx = (float)Py::Float(n.getItem(0));
|
||||
float ny = (float)Py::Float(n.getItem(1));
|
||||
float nz = (float)Py::Float(n.getItem(2));
|
||||
float bx = Py::Float(b.getItem(0));
|
||||
float by = Py::Float(b.getItem(1));
|
||||
float bz = Py::Float(b.getItem(2));
|
||||
float nx = Py::Float(n.getItem(0));
|
||||
float ny = Py::Float(n.getItem(1));
|
||||
float nz = Py::Float(n.getItem(2));
|
||||
|
||||
MeshObject::TPlane plane;
|
||||
plane.first.Set(bx, by, bz);
|
||||
@@ -769,9 +769,9 @@ PyObject* MeshPy::addFacets(PyObject* args)
|
||||
// 9 consecutive floats expected
|
||||
int index = 0;
|
||||
for (auto& point : facet._aclPoints) {
|
||||
point.x = (float)(double)Py::Float(seq[index++]);
|
||||
point.y = (float)(double)Py::Float(seq[index++]);
|
||||
point.z = (float)(double)Py::Float(seq[index++]);
|
||||
point.x = Py::Float(seq[index++]);
|
||||
point.y = Py::Float(seq[index++]);
|
||||
point.z = Py::Float(seq[index++]);
|
||||
}
|
||||
facet.CalcNormal();
|
||||
facets.push_back(facet);
|
||||
@@ -2184,10 +2184,10 @@ PyObject* MeshPy::getSegmentsByCurvature(PyObject* args)
|
||||
std::vector<MeshCore::MeshSurfaceSegmentPtr> segm;
|
||||
for (Py::Sequence::iterator it = func.begin(); it != func.end(); ++it) {
|
||||
Py::Tuple t(*it);
|
||||
float c1 = (float)Py::Float(t[0]);
|
||||
float c2 = (float)Py::Float(t[1]);
|
||||
float tol1 = (float)Py::Float(t[2]);
|
||||
float tol2 = (float)Py::Float(t[3]);
|
||||
float c1 = Py::Float(t[0]);
|
||||
float c2 = Py::Float(t[1]);
|
||||
float tol1 = Py::Float(t[2]);
|
||||
float tol2 = Py::Float(t[3]);
|
||||
int num = (int)Py::Long(t[4]);
|
||||
segm.emplace_back(
|
||||
std::make_shared<MeshCore::MeshCurvatureFreeformSegment>(meshCurv.GetCurvature(),
|
||||
|
||||
@@ -359,7 +359,7 @@ void PointsGrid::CalculateGridLength(unsigned long ulCtGrid, unsigned long ulMax
|
||||
}
|
||||
|
||||
double fVol = fVolElem * float(ulCtGrid);
|
||||
double fGridLen = float(pow((float)fVol, (float)1.0f / 3.0f));
|
||||
double fGridLen = float(pow((float)fVol, 1.0f / 3.0f));
|
||||
|
||||
if (fGridLen > 0) {
|
||||
_ulCtGridsX =
|
||||
@@ -444,7 +444,7 @@ void PointsGrid::CalculateGridLength(int iCtGridPerAxis)
|
||||
fVolumenGrid = fVolumen / (float)iMaxGrids;
|
||||
}
|
||||
|
||||
double fLengthGrid = float(pow((float)fVolumenGrid, (float)1.0f / 3.0f));
|
||||
double fLengthGrid = float(pow((float)fVolumenGrid, 1.0f / 3.0f));
|
||||
|
||||
_ulCtGridsX = std::max<unsigned long>((unsigned long)(fLenghtX / fLengthGrid), 1);
|
||||
_ulCtGridsY = std::max<unsigned long>((unsigned long)(fLenghtY / fLengthGrid), 1);
|
||||
@@ -531,7 +531,6 @@ void PointsGrid::SearchNearestFromPoint(const Base::Vector3d& rclPt,
|
||||
if (clBB.IsInBox(rclPt)) { // Point lies within
|
||||
unsigned long ulX, ulY, ulZ;
|
||||
Position(rclPt, ulX, ulY, ulZ);
|
||||
// int nX = ulX, nY = ulY, nZ = ulZ;
|
||||
unsigned long ulLevel = 0;
|
||||
while (raclInd.empty()) {
|
||||
GetHull(ulX, ulY, ulZ, ulLevel++, raclInd);
|
||||
|
||||
@@ -102,13 +102,13 @@ void PropertyGreyValueList::setPyObject(PyObject* value)
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
|
||||
values[i] = (float)PyFloat_AsDouble(item);
|
||||
values[i] = PyFloat_AsDouble(item);
|
||||
}
|
||||
|
||||
setValues(values);
|
||||
}
|
||||
else if (PyFloat_Check(value)) {
|
||||
setValue((float)PyFloat_AsDouble(value));
|
||||
setValue(PyFloat_AsDouble(value));
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be float or list of float, not ");
|
||||
|
||||
@@ -232,9 +232,9 @@ private:
|
||||
for (Py::Sequence::iterator it = l.begin(); it != l.end(); ++it) {
|
||||
Py::Tuple t(*it);
|
||||
pts.emplace_back(
|
||||
(float)Py::Float(t.getItem(0)),
|
||||
(float)Py::Float(t.getItem(1)),
|
||||
(float)Py::Float(t.getItem(2))
|
||||
Py::Float(t.getItem(0)),
|
||||
Py::Float(t.getItem(1)),
|
||||
Py::Float(t.getItem(2))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -381,35 +381,29 @@ Mesh.show(m)
|
||||
|
||||
return Py::asObject(new Mesh::MeshPy(mesh));
|
||||
}
|
||||
/*
|
||||
/*
|
||||
import ReverseEngineering as Reen
|
||||
import Points
|
||||
import Mesh
|
||||
import random
|
||||
import math
|
||||
|
||||
r=random.Random()
|
||||
|
||||
p=Points.Points()
|
||||
pts=[]
|
||||
for i in range(21):
|
||||
for j in range(21):
|
||||
pts.append(App.Vector(i,j,r.random()))
|
||||
|
||||
p.addPoints(pts)
|
||||
m=Reen.viewTriangulation(p,21,21)
|
||||
Mesh.show(m)
|
||||
|
||||
def boxmueller():
|
||||
r1,r2=random.random(),random.random()
|
||||
return math.sqrt(-2*math.log(r1))*math.cos(2*math.pi*r2)
|
||||
|
||||
p=Points.Points()
|
||||
pts=[]
|
||||
for i in range(21):
|
||||
for j in range(21):
|
||||
pts.append(App.Vector(i,j,r.gauss(5,0.05)))
|
||||
|
||||
p.addPoints(pts)
|
||||
m=Reen.viewTriangulation(p,21,21)
|
||||
Mesh.show(m)
|
||||
@@ -503,20 +497,17 @@ Mesh.show(m)
|
||||
|
||||
return Py::asObject(new Mesh::MeshPy(mesh));
|
||||
}
|
||||
/*
|
||||
/*
|
||||
import ReverseEngineering as Reen
|
||||
import Points
|
||||
import Mesh
|
||||
import random
|
||||
|
||||
r=random.Random()
|
||||
|
||||
p=Points.Points()
|
||||
pts=[]
|
||||
for i in range(21):
|
||||
for j in range(21):
|
||||
pts.append(App.Vector(i,j,r.gauss(5,0.05)))
|
||||
|
||||
p.addPoints(pts)
|
||||
m=Reen.marchingCubesHoppe(Points=p)
|
||||
Mesh.show(m)
|
||||
@@ -738,41 +729,33 @@ Mesh.show(m)
|
||||
}
|
||||
#endif
|
||||
#if defined(HAVE_PCL_SAMPLE_CONSENSUS)
|
||||
/*
|
||||
/*
|
||||
import ReverseEngineering as reen
|
||||
import Points
|
||||
import Part
|
||||
|
||||
p = App.ActiveDocument.Points.Points
|
||||
data = p.Points
|
||||
n = reen.normalEstimation(p, 10)
|
||||
|
||||
model = reen.sampleConsensus(SacModel="Plane", Points=p)
|
||||
indices = model["Model"]
|
||||
param = model["Parameters"]
|
||||
|
||||
plane = Part.Plane()
|
||||
plane.Axis = param[0:3]
|
||||
plane.Position = -plane.Axis * param[3]
|
||||
|
||||
np = Points.Points()
|
||||
np.addPoints([data[i] for i in indices])
|
||||
Points.show(np)
|
||||
|
||||
# sort in descending order
|
||||
indices = list(indices)
|
||||
indices.sort(reverse=True)
|
||||
|
||||
# remove points of segment
|
||||
for i in indices:
|
||||
del data[i]
|
||||
del n[i]
|
||||
|
||||
p = Points.Points()
|
||||
p.addPoints(data)
|
||||
model = reen.sampleConsensus(SacModel="Cylinder", Points=p, Normals=n)
|
||||
indices = model["Model"]
|
||||
|
||||
np = Points.Points()
|
||||
np.addPoints([data[i] for i in indices])
|
||||
Points.show(np)
|
||||
|
||||
Reference in New Issue
Block a user