本文整理汇总了C++中base::VectorPy类的典型用法代码示例。如果您正苦于以下问题:C++ VectorPy类的具体用法?C++ VectorPy怎么用?C++ VectorPy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VectorPy类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: splitFacet
PyObject* MeshPy::splitFacet(PyObject *args)
{
unsigned long facet;
PyObject* vertex1;
PyObject* vertex2;
if (!PyArg_ParseTuple(args, "kO!O!", &facet, &Base::VectorPy::Type, &vertex1,
&Base::VectorPy::Type, &vertex2))
return NULL;
Base::VectorPy *pcObject = static_cast<Base::VectorPy*>(vertex1);
Base::Vector3d* val = pcObject->getVectorPtr();
Base::Vector3f v1((float)val->x,(float)val->y,(float)val->z);
pcObject = static_cast<Base::VectorPy*>(vertex2);
val = pcObject->getVectorPtr();
Base::Vector3f v2((float)val->x,(float)val->y,(float)val->z);
const MeshCore::MeshKernel& kernel = getMeshObjectPtr()->getKernel();
PY_TRY {
if (facet < 0 || facet >= kernel.CountFacets()) {
PyErr_SetString(PyExc_IndexError, "Facet index out of range");
return NULL;
}
getMeshObjectPtr()->splitFacet(facet, v1, v2);
} PY_CATCH;
Py_Return;
}
开发者ID:msocorcim,项目名称:FreeCAD,代码行数:29,代码来源:MeshPyImp.cpp
示例2: transform
PyObject* MatrixPy::transform(PyObject * args)
{
Base::Vector3d vec;
Matrix4D mat;
PyObject *pcVecObj,*pcMatObj;
if (PyArg_ParseTuple(args, "O!O!: a transform point (Vector) and a transform matrix (Matrix) is needed",
&(Base::VectorPy::Type), &pcVecObj, &(MatrixPy::Type), &pcMatObj) ) { // convert args: Python->C
Base::VectorPy *pcObject = static_cast<Base::VectorPy*>(pcVecObj);
Base::Vector3d* val = pcObject->getVectorPtr();
vec.Set(val->x,val->y,val->z);
mat = *(static_cast<MatrixPy*>(pcMatObj)->getMatrixPtr());
// clears the error from the first PyArg_ParseTuple()6
PyErr_Clear();
}
else
return NULL; // NULL triggers exception
PY_TRY {
getMatrixPtr()->transform(vec,mat);
}
PY_CATCH;
Py_Return;
}
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:25,代码来源:MatrixPyImp.cpp
示例3: splitEdge
PyObject* MeshPy::splitEdge(PyObject *args)
{
unsigned long facet, neighbour;
PyObject* vertex;
if (!PyArg_ParseTuple(args, "kkO!", &facet, &neighbour, &Base::VectorPy::Type, &vertex))
return NULL;
Base::VectorPy *pcObject = static_cast<Base::VectorPy*>(vertex);
Base::Vector3d* val = pcObject->getVectorPtr();
Base::Vector3f v((float)val->x,(float)val->y,(float)val->z);
const MeshCore::MeshKernel& kernel = getMeshObjectPtr()->getKernel();
PY_TRY {
if (facet < 0 || facet >= kernel.CountFacets()) {
PyErr_SetString(PyExc_IndexError, "Facet index out of range");
return NULL;
}
if (neighbour < 0 || neighbour >= kernel.CountFacets()) {
PyErr_SetString(PyExc_IndexError, "Facet index out of range");
return NULL;
}
const MeshCore::MeshFacet& rclF = kernel.GetFacets()[facet];
if (rclF._aulNeighbours[0] != neighbour && rclF._aulNeighbours[1] != neighbour &&
rclF._aulNeighbours[2] != neighbour) {
PyErr_SetString(PyExc_IndexError, "No adjacent facets");
return NULL;
}
getMeshObjectPtr()->splitEdge(facet, neighbour, v);
} PY_CATCH;
Py_Return;
}
开发者ID:msocorcim,项目名称:FreeCAD,代码行数:34,代码来源:MeshPyImp.cpp
示例4: setPyObject
void PropertyNormalList::setPyObject(PyObject *value)
{
if (PyList_Check(value)) {
Py_ssize_t nSize = PyList_Size(value);
std::vector<Base::Vector3f> values;
values.resize(nSize);
for (Py_ssize_t i=0; i<nSize;++i) {
PyObject* item = PyList_GetItem(value, i);
App::PropertyVector val;
val.setPyObject( item );
values[i] = Base::convertTo<Base::Vector3f>(val.getValue());
}
setValues(values);
}
else if (PyObject_TypeCheck(value, &(Base::VectorPy::Type))) {
Base::VectorPy *pcObject = static_cast<Base::VectorPy*>(value);
Base::Vector3d* val = pcObject->getVectorPtr();
setValue(Base::convertTo<Base::Vector3f>(*val));
}
else if (PyTuple_Check(value) && PyTuple_Size(value) == 3) {
App::PropertyVector val;
val.setPyObject( value );
setValue(Base::convertTo<Base::Vector3f>(val.getValue()));
}
else {
std::string error = std::string("type must be 'Vector' or list of 'Vector', not ");
error += value->ob_type->tp_name;
throw Py::TypeError(error);
}
}
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:32,代码来源:MeshProperties.cpp
示例5: scale
PyObject* MatrixPy::scale(PyObject * args)
{
double x,y,z;
Base::Vector3d vec;
PyObject *pcVecObj;
if (PyArg_ParseTuple(args, "ddd", &x,&y,&z)) { // convert args: Python->C
vec.x = x;
vec.y = y;
vec.z = z;
}
else if (PyArg_ParseTuple(args, "O!:three floats or a vector is needed",
&PyTuple_Type, &pcVecObj)) {
vec = getVectorFromTuple<double>(pcVecObj);
// clears the error from the first PyArg_ParseTuple()6
PyErr_Clear();
}
else if (PyArg_ParseTuple(args, "O!:three floats or a vector is needed", &(Base::VectorPy::Type), &pcVecObj)) {
// convert args: Python->C
Base::VectorPy *pcObject = static_cast<Base::VectorPy*>(pcVecObj);
Base::Vector3d* val = pcObject->getVectorPtr();
vec.Set(val->x,val->y,val->z);
// clears the error from the first PyArg_ParseTuple()6
PyErr_Clear();
}
else
return NULL;
PY_TRY {
getMatrixPtr()->scale(vec);
}
PY_CATCH;
Py_Return;
}
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:35,代码来源:MatrixPyImp.cpp
示例6: getVector
Py::Object MeshPointPy::getVector(void) const
{
MeshPointPy::PointerType ptr = reinterpret_cast<MeshPointPy::PointerType>(_pcTwinPointer);
Base::VectorPy* vec = new Base::VectorPy(*ptr);
vec->setConst();
return Py::Object(vec,true);
}
开发者ID:PrLayton,项目名称:SeriousFractal,代码行数:8,代码来源:MeshPointPyImp.cpp
示例7: setPyObject
void PropertyVector::setPyObject(PyObject *value)
{
if (PyObject_TypeCheck(value, &(Base::VectorPy::Type))) {
Base::VectorPy *pcObject = static_cast<Base::VectorPy*>(value);
Base::Vector3d* val = pcObject->getVectorPtr();
setValue(*val);
}
else if (PyTuple_Check(value)&&PyTuple_Size(value)==3) {
PyObject* item;
Base::Vector3d cVec;
// x
item = PyTuple_GetItem(value,0);
if (PyFloat_Check(item))
cVec.x = PyFloat_AsDouble(item);
#if PY_MAJOR_VERSION < 3
else if (PyInt_Check(item))
cVec.x = (double)PyInt_AsLong(item);
#else
else if (PyLong_Check(item))
cVec.x = (double)PyLong_AsLong(item);
#endif
else
throw Base::TypeError("Not allowed type used in tuple (float expected)...");
// y
item = PyTuple_GetItem(value,1);
if (PyFloat_Check(item))
cVec.y = PyFloat_AsDouble(item);
#if PY_MAJOR_VERSION < 3
else if (PyInt_Check(item))
cVec.y = (double)PyInt_AsLong(item);
#else
else if (PyLong_Check(item))
cVec.y = (double)PyLong_AsLong(item);
#endif
else
throw Base::TypeError("Not allowed type used in tuple (float expected)...");
// z
item = PyTuple_GetItem(value,2);
if (PyFloat_Check(item))
cVec.z = PyFloat_AsDouble(item);
#if PY_MAJOR_VERSION < 3
else if (PyInt_Check(item))
cVec.z = (double)PyInt_AsLong(item);
#else
else if (PyLong_Check(item))
cVec.z = (double)PyLong_AsLong(item);
#endif
else
throw Base::TypeError("Not allowed type used in tuple (float expected)...");
setValue( cVec );
}
else {
std::string error = std::string("type must be 'Vector' or tuple of three floats, not ");
error += value->ob_type->tp_name;
throw Base::TypeError(error);
}
}
开发者ID:crobarcro,项目名称:FreeCAD,代码行数:57,代码来源:PropertyGeo.cpp
示例8: getNormal
Py::Object MeshPointPy::getNormal(void) const
{
if (!getMeshPointPtr()->isBound())
PyErr_SetString(Base::BaseExceptionFreeCADError, "This object is not bounded to a mesh, so no topological operation is possible!");
Base::Vector3d* v = new Base::Vector3d(getMeshPointPtr()->Mesh->getPointNormal(getMeshPointPtr()->Index));
Base::VectorPy* normal = new Base::VectorPy(v);
normal->setConst();
return Py::Object(normal,true);
}
开发者ID:PrLayton,项目名称:SeriousFractal,代码行数:10,代码来源:MeshPointPyImp.cpp
示例9: list
static PyObject *
calculateEigenTransform(PyObject *self, PyObject *args)
{
PyObject *input;
if (!PyArg_ParseTuple(args, "O",&input))
return NULL;
if(! PySequence_Check(input) ){
PyErr_SetString(Base::BaseExceptionFreeCADError, "Input have to be a sequence of Base.Vector()");
return NULL;
}
PY_TRY {
MeshCore::MeshKernel aMesh;
MeshCore::MeshPointArray vertices;
vertices.clear();
MeshCore::MeshFacetArray faces;
faces.clear();
MeshCore::MeshPoint current_node;
Py::Sequence list(input);
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
PyObject* value = (*it).ptr();
if (PyObject_TypeCheck(value, &(Base::VectorPy::Type))) {
Base::VectorPy *pcObject = static_cast<Base::VectorPy*>(value);
Base::Vector3d* val = pcObject->getVectorPtr();
current_node.Set(float(val->x),float(val->y),float(val->z));
vertices.push_back(current_node);
}
}
MeshCore::MeshFacet aFacet;
aFacet._aulPoints[0] = 0;aFacet._aulPoints[1] = 1;aFacet._aulPoints[2] = 2;
faces.push_back(aFacet);
//Fill the Kernel with the temp smesh structure and delete the current containers
aMesh.Adopt(vertices,faces);
MeshCore::MeshEigensystem pca(aMesh);
pca.Evaluate();
Base::Matrix4D Trafo = pca.Transform();
return new Base::PlacementPy(new Base::Placement(Trafo) );
} PY_CATCH;
Py_Return;
}
开发者ID:5263,项目名称:FreeCAD,代码行数:49,代码来源:AppMeshPy.cpp
示例10: snapVertex
PyObject* MeshPy::snapVertex(PyObject *args)
{
unsigned long facet;
PyObject* vertex;
if (!PyArg_ParseTuple(args, "kO!", &facet, &Base::VectorPy::Type, &vertex))
return NULL;
Base::VectorPy *pcObject = static_cast<Base::VectorPy*>(vertex);
Base::Vector3d* val = pcObject->getVectorPtr();
Base::Vector3f v((float)val->x,(float)val->y,(float)val->z);
PY_TRY {
if (facet < 0 || facet >= getMeshObjectPtr()->countFacets()) {
PyErr_SetString(PyExc_IndexError, "Facet index out of range");
return NULL;
}
getMeshObjectPtr()->snapVertex(facet, v);
} PY_CATCH;
Py_Return;
}
开发者ID:msocorcim,项目名称:FreeCAD,代码行数:22,代码来源:MeshPyImp.cpp
示例11: isInside
PyObject* BoundBoxPy::isInside(PyObject *args)
{
PyObject *object;
Py::Boolean retVal;
if (!PyArg_ParseTuple(args,"O", &object))
return 0;
if (PyObject_TypeCheck(object, &(Base::VectorPy::Type))) {
Base::VectorPy *vec = static_cast<Base::VectorPy*>(object);
retVal = getBoundBoxPtr()->IsInBox(*vec->getVectorPtr());
}
else if (PyObject_TypeCheck(object, &(Base::BoundBoxPy::Type))) {
Base::BoundBoxPy *box = static_cast<Base::BoundBoxPy*>(object);
retVal = getBoundBoxPtr()->IsInBox(*box->getBoundBoxPtr());
}
else {
PyErr_SetString(PyExc_TypeError, "Either a Vector or BoundBox object expected");
return 0;
}
return Py::new_reference_to(retVal);
}
开发者ID:Koelie2,项目名称:freecad,代码行数:22,代码来源:BoundBoxPyImp.cpp
注:本文中的base::VectorPy类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论