Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
FreeCAD
FreeCAD
Commits
1b345c19
Commit
1b345c19
authored
Dec 29, 2012
by
wmayer
Browse files
Use PyObject_IsTrue to check argument
parent
0efd86fb
Changes
15
Hide whitespace changes
Inline
Side-by-side
src/App/DocumentPyImp.cpp
View file @
1b345c19
...
...
@@ -187,7 +187,9 @@ PyObject* DocumentPy::copyObject(PyObject *args)
return
NULL
;
// NULL triggers exception
DocumentObjectPy
*
docObj
=
static_cast
<
DocumentObjectPy
*>
(
obj
);
DocumentObject
*
copy
=
getDocumentPtr
()
->
copyObject
(
docObj
->
getDocumentObjectPtr
(),
rec
==
Py_True
,
keep
==
Py_True
);
DocumentObject
*
copy
=
getDocumentPtr
()
->
copyObject
(
docObj
->
getDocumentObjectPtr
(),
PyObject_IsTrue
(
rec
)
?
true
:
false
,
PyObject_IsTrue
(
keep
)
?
true
:
false
);
if
(
copy
)
{
return
copy
->
getPyObject
();
}
...
...
@@ -204,7 +206,7 @@ PyObject* DocumentPy::moveObject(PyObject *args)
return
NULL
;
// NULL triggers exception
DocumentObjectPy
*
docObj
=
static_cast
<
DocumentObjectPy
*>
(
obj
);
DocumentObject
*
move
=
getDocumentPtr
()
->
moveObject
(
docObj
->
getDocumentObjectPtr
(),
rec
==
Py_Tru
e
);
DocumentObject
*
move
=
getDocumentPtr
()
->
moveObject
(
docObj
->
getDocumentObjectPtr
(),
PyObject_IsTrue
(
rec
)
?
true
:
fals
e
);
if
(
move
)
{
return
move
->
getPyObject
();
}
...
...
src/App/FeaturePythonPyImp.cpp
View file @
1b345c19
...
...
@@ -51,7 +51,8 @@ PyObject* FeaturePythonPy::addProperty(PyObject *args)
return
NULL
;
// NULL triggers exception
Property
*
prop
=
0
;
prop
=
getFeaturePythonPtr
()
->
addDynamicProperty
(
sType
,
sName
,
sGroup
,
sDoc
,
attr
,
ro
==
Py_True
,
hd
==
Py_True
);
prop
=
getFeaturePythonPtr
()
->
addDynamicProperty
(
sType
,
sName
,
sGroup
,
sDoc
,
attr
,
PyObject_IsTrue
(
ro
)
?
true
:
false
,
PyObject_IsTrue
(
hd
)
?
true
:
false
);
if
(
!
prop
)
{
std
::
stringstream
str
;
...
...
src/App/PropertyStandard.cpp
View file @
1b345c19
...
...
@@ -1347,7 +1347,7 @@ PyObject *PropertyBool::getPyObject(void)
void
PropertyBool
::
setPyObject
(
PyObject
*
value
)
{
if
(
PyBool_Check
(
value
))
setValue
(
value
==
Py_True
);
setValue
(
PyObject_IsTrue
(
value
)
!=
0
);
else
if
(
PyInt_Check
(
value
))
setValue
(
PyInt_AsLong
(
value
)
!=
0
);
else
{
...
...
src/Gui/View3DPy.cpp
View file @
1b345c19
...
...
@@ -474,7 +474,7 @@ Py::Object View3DInventorPy::setCameraOrientation(const Py::Tuple& args)
float
q1
=
(
float
)
Py
::
Float
(
tuple
[
1
]);
float
q2
=
(
float
)
Py
::
Float
(
tuple
[
2
]);
float
q3
=
(
float
)
Py
::
Float
(
tuple
[
3
]);
_view
->
getViewer
()
->
setCameraOrientation
(
SbRotation
(
q0
,
q1
,
q2
,
q3
),
m
==
Py_
True
);
_view
->
getViewer
()
->
setCameraOrientation
(
SbRotation
(
q0
,
q1
,
q2
,
q3
),
PyObject_Is
True
(
m
)
);
}
catch
(
const
Base
::
Exception
&
e
)
{
throw
Py
::
Exception
(
e
.
what
());
...
...
src/Gui/ViewProviderPythonFeaturePyImp.cpp
View file @
1b345c19
...
...
@@ -73,7 +73,8 @@ PyObject* ViewProviderPythonFeaturePy::addProperty(PyObject *args)
return
NULL
;
// NULL triggers exception
App
::
Property
*
prop
=
0
;
prop
=
getViewProviderPythonFeaturePtr
()
->
addDynamicProperty
(
sType
,
sName
,
sGroup
,
sDoc
,
attr
,
ro
==
Py_True
,
hd
==
Py_True
);
prop
=
getViewProviderPythonFeaturePtr
()
->
addDynamicProperty
(
sType
,
sName
,
sGroup
,
sDoc
,
attr
,
PyObject_IsTrue
(
ro
)
?
true
:
false
,
PyObject_IsTrue
(
hd
)
?
true
:
false
);
if
(
!
prop
)
{
std
::
stringstream
str
;
...
...
src/Mod/Mesh/App/FeaturePythonPyImp.cpp
View file @
1b345c19
...
...
@@ -49,7 +49,8 @@ PyObject* FeaturePythonPy::addProperty(PyObject *args)
return
NULL
;
// NULL triggers exception
App
::
Property
*
prop
=
0
;
prop
=
getFeaturePtr
()
->
addDynamicProperty
(
sType
,
sName
,
sGroup
,
sDoc
,
attr
,
ro
==
Py_True
,
hd
==
Py_True
);
prop
=
getFeaturePtr
()
->
addDynamicProperty
(
sType
,
sName
,
sGroup
,
sDoc
,
attr
,
PyObject_IsTrue
(
ro
)
?
true
:
false
,
PyObject_IsTrue
(
hd
)
?
true
:
false
);
if
(
!
prop
)
{
std
::
stringstream
str
;
...
...
src/Mod/Mesh/App/MeshPyImp.cpp
View file @
1b345c19
...
...
@@ -278,7 +278,7 @@ PyObject* MeshPy::crossSections(PyObject *args)
}
std
::
vector
<
MeshObject
::
TPolylines
>
sections
;
getMeshObjectPtr
()
->
crossSections
(
csPlanes
,
sections
,
min_eps
,
(
poly
==
Py_True
)
);
getMeshObjectPtr
()
->
crossSections
(
csPlanes
,
sections
,
min_eps
,
PyObject_IsTrue
(
poly
)
?
true
:
false
);
// convert to Python objects
Py
::
List
crossSections
;
...
...
src/Mod/Part/App/AppPartPy.cpp
View file @
1b345c19
...
...
@@ -1166,8 +1166,8 @@ static PyObject * makeLoft(PyObject *self, PyObject *args)
}
TopoShape
myShape
;
Standard_Boolean
anIsSolid
=
(
psolid
==
Py_True
)
?
Standard_True
:
Standard_False
;
Standard_Boolean
anIsRuled
=
(
pruled
==
Py_True
)
?
Standard_True
:
Standard_False
;
Standard_Boolean
anIsSolid
=
PyObject_IsTrue
(
psolid
)
?
Standard_True
:
Standard_False
;
Standard_Boolean
anIsRuled
=
PyObject_IsTrue
(
pruled
)
?
Standard_True
:
Standard_False
;
TopoDS_Shape
aResult
=
myShape
.
makeLoft
(
profiles
,
anIsSolid
,
anIsRuled
);
return
new
TopoShapePy
(
new
TopoShape
(
aResult
));
}
...
...
src/Mod/Part/App/BRepOffsetAPI_MakePipeShellPyImp.cpp
View file @
1b345c19
...
...
@@ -73,7 +73,7 @@ PyObject* BRepOffsetAPI_MakePipeShellPy::setFrenetMode(PyObject *args)
PyObject
*
obj
;
if
(
!
PyArg_ParseTuple
(
args
,
"O!"
,
&
PyBool_Type
,
&
obj
))
return
0
;
this
->
getBRepOffsetAPI_MakePipeShellPtr
()
->
SetMode
(
obj
==
Py_Tru
e
);
this
->
getBRepOffsetAPI_MakePipeShellPtr
()
->
SetMode
(
PyObject_IsTrue
(
obj
)
?
Standard_True
:
Standard_Fals
e
);
Py_Return
;
}
...
...
@@ -121,7 +121,7 @@ PyObject* BRepOffsetAPI_MakePipeShellPy::setAuxiliarySpine(PyObject *args)
PyErr_SetString
(
PyExc_TypeError
,
"spine is not a wire"
);
return
0
;
}
this
->
getBRepOffsetAPI_MakePipeShellPtr
()
->
SetMode
(
TopoDS
::
Wire
(
s
),
curv
==
Py_True
,
keep
==
Py_True
);
this
->
getBRepOffsetAPI_MakePipeShellPtr
()
->
SetMode
(
TopoDS
::
Wire
(
s
),
PyObject_IsTrue
(
curv
),
PyObject_IsTrue
(
keep
)
);
Py_Return
;
}
...
...
@@ -133,7 +133,7 @@ PyObject* BRepOffsetAPI_MakePipeShellPy::add(PyObject *args)
,
&
PyBool_Type
,
&
keep
))
return
0
;
const
TopoDS_Shape
&
s
=
static_cast
<
Part
::
TopoShapePy
*>
(
prof
)
->
getTopoShapePtr
()
->
_Shape
;
this
->
getBRepOffsetAPI_MakePipeShellPtr
()
->
Add
(
s
,
curv
==
Py_True
,
keep
==
Py_True
);
this
->
getBRepOffsetAPI_MakePipeShellPtr
()
->
Add
(
s
,
PyObject_IsTrue
(
curv
),
PyObject_IsTrue
(
keep
)
);
Py_Return
;
}
...
...
src/Mod/Part/App/BSplineCurvePyImp.cpp
View file @
1b345c19
...
...
@@ -183,7 +183,7 @@ PyObject* BSplineCurvePy::insertKnot(PyObject * args)
try
{
Handle_Geom_BSplineCurve
curve
=
Handle_Geom_BSplineCurve
::
DownCast
(
getGeometryPtr
()
->
handle
());
curve
->
InsertKnot
(
U
,
M
,
tol
,
(
add
==
Py_True
));
curve
->
InsertKnot
(
U
,
M
,
tol
,
PyObject_IsTrue
(
add
));
}
catch
(
Standard_Failure
)
{
Handle_Standard_Failure
e
=
Standard_Failure
::
Caught
();
...
...
@@ -223,7 +223,7 @@ PyObject* BSplineCurvePy::insertKnots(PyObject * args)
Handle_Geom_BSplineCurve
curve
=
Handle_Geom_BSplineCurve
::
DownCast
(
getGeometryPtr
()
->
handle
());
curve
->
InsertKnots
(
k
,
m
,
tol
,
(
add
==
Py_True
));
curve
->
InsertKnots
(
k
,
m
,
tol
,
PyObject_IsTrue
(
add
));
Py_Return
;
}
catch
(
Standard_Failure
)
{
...
...
@@ -755,7 +755,7 @@ PyObject* BSplineCurvePy::interpolate(PyObject *args)
Standard_Failure
::
Raise
(
"not enough points given"
);
}
GeomAPI_Interpolate
aBSplineInterpolation
(
interpolationPoints
,
(
closed
==
Py_True
),
tol3d
);
GeomAPI_Interpolate
aBSplineInterpolation
(
interpolationPoints
,
PyObject_IsTrue
(
closed
),
tol3d
);
if
(
t1
&&
t2
)
{
Base
::
Vector3d
v1
=
Py
::
Vector
(
t1
,
false
).
toVector
();
Base
::
Vector3d
v2
=
Py
::
Vector
(
t1
,
false
).
toVector
();
...
...
@@ -811,7 +811,7 @@ PyObject* BSplineCurvePy::buildFromPoles(PyObject *args)
mults
.
SetValue
(
1
,
degree
+
1
);
mults
.
SetValue
(
knots
.
Length
(),
degree
+
1
);
Handle_Geom_BSplineCurve
spline
=
new
Geom_BSplineCurve
(
poles
,
knots
,
mults
,
degree
,
(
closed
==
Py_True
));
Handle_Geom_BSplineCurve
spline
=
new
Geom_BSplineCurve
(
poles
,
knots
,
mults
,
degree
,
PyObject_IsTrue
(
closed
));
if
(
!
spline
.
IsNull
())
{
this
->
getGeomBSplineCurvePtr
()
->
setHandle
(
spline
);
Py_Return
;
...
...
src/Mod/Part/App/BSplineSurfacePyImp.cpp
View file @
1b345c19
...
...
@@ -293,7 +293,7 @@ PyObject* BSplineSurfacePy::insertUKnot(PyObject *args)
try
{
Handle_Geom_BSplineSurface
surf
=
Handle_Geom_BSplineSurface
::
DownCast
(
getGeometryPtr
()
->
handle
());
surf
->
InsertUKnot
(
U
,
M
,
tol
,
(
add
==
Py_True
));
surf
->
InsertUKnot
(
U
,
M
,
tol
,
PyObject_IsTrue
(
add
));
}
catch
(
Standard_Failure
)
{
Handle_Standard_Failure
e
=
Standard_Failure
::
Caught
();
...
...
@@ -333,7 +333,7 @@ PyObject* BSplineSurfacePy::insertUKnots(PyObject *args)
Handle_Geom_BSplineSurface
surf
=
Handle_Geom_BSplineSurface
::
DownCast
(
getGeometryPtr
()
->
handle
());
surf
->
InsertUKnots
(
k
,
m
,
tol
,
(
add
==
Py_True
));
surf
->
InsertUKnots
(
k
,
m
,
tol
,
PyObject_IsTrue
(
add
));
Py_Return
;
}
catch
(
Standard_Failure
)
{
...
...
@@ -356,7 +356,7 @@ PyObject* BSplineSurfacePy::insertVKnot(PyObject *args)
try
{
Handle_Geom_BSplineSurface
surf
=
Handle_Geom_BSplineSurface
::
DownCast
(
getGeometryPtr
()
->
handle
());
surf
->
InsertVKnot
(
V
,
M
,
tol
,
(
add
==
Py_True
));
surf
->
InsertVKnot
(
V
,
M
,
tol
,
PyObject_IsTrue
(
add
));
}
catch
(
Standard_Failure
)
{
Handle_Standard_Failure
e
=
Standard_Failure
::
Caught
();
...
...
@@ -396,7 +396,7 @@ PyObject* BSplineSurfacePy::insertVKnots(PyObject *args)
Handle_Geom_BSplineSurface
surf
=
Handle_Geom_BSplineSurface
::
DownCast
(
getGeometryPtr
()
->
handle
());
surf
->
InsertVKnots
(
k
,
m
,
tol
,
(
add
==
Py_True
));
surf
->
InsertVKnots
(
k
,
m
,
tol
,
PyObject_IsTrue
(
add
));
Py_Return
;
}
catch
(
Standard_Failure
)
{
...
...
src/Mod/Part/App/FeaturePythonPyImp.cpp
View file @
1b345c19
...
...
@@ -47,7 +47,8 @@ PyObject* FeaturePythonPy::addProperty(PyObject *args)
return
NULL
;
// NULL triggers exception
App
::
Property
*
prop
=
0
;
prop
=
getFeaturePythonPtr
()
->
addDynamicProperty
(
sType
,
sName
,
sGroup
,
sDoc
,
attr
,
ro
==
Py_True
,
hd
==
Py_True
);
prop
=
getFeaturePythonPtr
()
->
addDynamicProperty
(
sType
,
sName
,
sGroup
,
sDoc
,
attr
,
PyObject_IsTrue
(
ro
)
?
true
:
false
,
PyObject_IsTrue
(
hd
)
?
true
:
false
);
if
(
!
prop
)
{
std
::
stringstream
str
;
...
...
src/Mod/Part/App/RectangularTrimmedSurfacePyImp.cpp
View file @
1b345c19
...
...
@@ -59,7 +59,7 @@ int RectangularTrimmedSurfacePy::PyInit(PyObject* args, PyObject* /*kwd*/)
getGeomTrimmedSurfacePtr
()
->
setHandle
(
new
Geom_RectangularTrimmedSurface
(
Handle_Geom_Surface
::
DownCast
(
static_cast
<
GeometrySurfacePy
*>
(
surf
)
->
getGeomSurfacePtr
()
->
handle
()),
u1
,
u2
,
v1
,
v2
,
(
usense
==
Py_
True
),
(
vsense
==
Py_True
)
u1
,
u2
,
v1
,
v2
,
PyObject_IsTrue
(
usense
),
PyObject_Is
True
(
vsense
)
));
return
0
;
}
...
...
@@ -69,8 +69,8 @@ int RectangularTrimmedSurfacePy::PyInit(PyObject* args, PyObject* /*kwd*/)
PyObject
*
utrim
=
0
,
*
sense
=
Py_True
;
if
(
PyArg_ParseTuple
(
args
,
"O!ddO!|O!"
,
&
(
Part
::
GeometrySurfacePy
::
Type
),
&
surf
,
&
param1
,
&
param2
,
&
PyBool_Type
,
&
utrim
,
&
PyBool_Type
,
&
sense
))
{
Standard_Boolean
UTrim
=
(
utrim
==
Py_True
);
Standard_Boolean
Sense
=
(
sense
==
Py_Tru
e
);
Standard_Boolean
UTrim
=
PyObject_IsTrue
(
utrim
);
Standard_Boolean
Sense
=
PyObject_IsTrue
(
sens
e
);
getGeomTrimmedSurfacePtr
()
->
setHandle
(
new
Geom_RectangularTrimmedSurface
(
Handle_Geom_Surface
::
DownCast
(
static_cast
<
GeometrySurfacePy
*>
(
surf
)
->
getGeomSurfacePtr
()
->
handle
()),
...
...
src/Mod/Part/App/TopoShapeCompoundPyImp.cpp
View file @
1b345c19
...
...
@@ -122,7 +122,7 @@ PyObject* TopoShapeCompoundPy::connectEdgesToWires(PyObject *args)
for
(
TopExp_Explorer
xp
(
s
,
TopAbs_EDGE
);
xp
.
More
();
xp
.
Next
())
hEdges
->
Append
(
xp
.
Current
());
ShapeAnalysis_FreeBounds
::
ConnectEdgesToWires
(
hEdges
,
tol
,
(
shared
==
Py_True
),
hWires
);
ShapeAnalysis_FreeBounds
::
ConnectEdgesToWires
(
hEdges
,
tol
,
PyObject_IsTrue
(
shared
),
hWires
);
TopoDS_Compound
comp
;
BRep_Builder
builder
;
...
...
src/Mod/Part/App/TopoShapePyImp.cpp
View file @
1b345c19
...
...
@@ -1046,7 +1046,7 @@ PyObject* TopoShapePy::makeThickness(PyObject *args)
}
TopoDS_Shape
shape
=
this
->
getTopoShapePtr
()
->
makeThickSolid
(
facesToRemove
,
offset
,
tolerance
,
(
inter
==
Py_
True
),
(
self_inter
==
Py_True
)
,
offsetMode
,
join
);
PyObject_IsTrue
(
inter
)
?
true
:
false
,
PyObject_Is
True
(
self_inter
)
?
true
:
false
,
offsetMode
,
join
);
return
new
TopoShapeSolidPy
(
new
TopoShape
(
shape
));
}
catch
(
Standard_Failure
)
{
...
...
@@ -1073,7 +1073,9 @@ PyObject* TopoShapePy::makeOffsetShape(PyObject *args)
try
{
TopoDS_Shape
shape
=
this
->
getTopoShapePtr
()
->
makeOffsetShape
(
offset
,
tolerance
,
(
inter
==
Py_True
),
(
self_inter
==
Py_True
),
offsetMode
,
join
,
(
fill
==
Py_True
));
PyObject_IsTrue
(
inter
)
?
true
:
false
,
PyObject_IsTrue
(
self_inter
)
?
true
:
false
,
offsetMode
,
join
,
PyObject_IsTrue
(
fill
)
?
true
:
false
);
return
new
TopoShapePy
(
new
TopoShape
(
shape
));
}
catch
(
Standard_Failure
)
{
...
...
@@ -1324,7 +1326,7 @@ PyObject* TopoShapePy::isInside(PyObject *args)
gp_Pnt
vertex
=
gp_Pnt
(
pnt
.
x
,
pnt
.
y
,
pnt
.
z
);
solidClassifier
.
Perform
(
vertex
,
tolerance
);
Standard_Boolean
test
=
(
solidClassifier
.
State
()
==
stateIn
);
if
(
(
checkFace
==
Py_Tru
e
)
&&
(
solidClassifier
.
IsOnAFace
())
)
if
(
PyObject_IsTrue
(
checkFac
e
)
&&
(
solidClassifier
.
IsOnAFace
()))
test
=
Standard_True
;
return
Py_BuildValue
(
"O"
,
(
test
?
Py_True
:
Py_False
));
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment