Surface: apply clang format
This commit is contained in:
@@ -22,17 +22,17 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <BRepAdaptor_Surface.hxx>
|
||||
# include <BRepBuilderAPI_MakeFace.hxx>
|
||||
# include <BRepLProp_SLProps.hxx>
|
||||
# include <Geom_BSplineSurface.hxx>
|
||||
# include <GeomAPI_PointsToBSplineSurface.hxx>
|
||||
# include <gp_Pnt.hxx>
|
||||
# include <Precision.hxx>
|
||||
# include <Standard_Version.hxx>
|
||||
# include <TColgp_Array2OfPnt.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <TopoDS_Face.hxx>
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <BRepLProp_SLProps.hxx>
|
||||
#include <GeomAPI_PointsToBSplineSurface.hxx>
|
||||
#include <Geom_BSplineSurface.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <Standard_Version.hxx>
|
||||
#include <TColgp_Array2OfPnt.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#endif
|
||||
|
||||
#include <Base/Tools.h>
|
||||
@@ -49,7 +49,7 @@ PROPERTY_SOURCE(Surface::Extend, Part::Spline)
|
||||
|
||||
Extend::Extend()
|
||||
{
|
||||
ADD_PROPERTY(Face,(nullptr));
|
||||
ADD_PROPERTY(Face, (nullptr));
|
||||
Face.setScope(App::LinkScope::Global);
|
||||
ADD_PROPERTY(Tolerance, (0.1));
|
||||
Tolerance.setConstraints(&ToleranceRange);
|
||||
@@ -74,32 +74,40 @@ Extend::Extend()
|
||||
|
||||
short Extend::mustExecute() const
|
||||
{
|
||||
if (Face.isTouched())
|
||||
if (Face.isTouched()) {
|
||||
return 1;
|
||||
if (ExtendUNeg.isTouched())
|
||||
}
|
||||
if (ExtendUNeg.isTouched()) {
|
||||
return 1;
|
||||
if (ExtendUPos.isTouched())
|
||||
return 1;
|
||||
if (ExtendVNeg.isTouched())
|
||||
}
|
||||
if (ExtendUPos.isTouched()) {
|
||||
return 1;
|
||||
if (ExtendVPos.isTouched())
|
||||
return 1;
|
||||
}
|
||||
if (ExtendVNeg.isTouched()) {
|
||||
return 1;
|
||||
}
|
||||
if (ExtendVPos.isTouched()) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *Extend::execute()
|
||||
App::DocumentObjectExecReturn* Extend::execute()
|
||||
{
|
||||
App::DocumentObject* part = Face.getValue();
|
||||
if (!part || !part->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
if (!part || !part->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
return new App::DocumentObjectExecReturn("No shape linked.");
|
||||
}
|
||||
const auto& faces = Face.getSubValues();
|
||||
if (faces.size() != 1)
|
||||
if (faces.size() != 1) {
|
||||
return new App::DocumentObjectExecReturn("Not exactly one sub-shape linked.");
|
||||
}
|
||||
|
||||
TopoDS_Shape shape = static_cast<Part::Feature*>(part)
|
||||
->Shape.getShape().getSubShape(faces[0].c_str());
|
||||
if (shape.IsNull() || shape.ShapeType() != TopAbs_FACE)
|
||||
TopoDS_Shape shape =
|
||||
static_cast<Part::Feature*>(part)->Shape.getShape().getSubShape(faces[0].c_str());
|
||||
if (shape.IsNull() || shape.ShapeType() != TopAbs_FACE) {
|
||||
return new App::DocumentObjectExecReturn("Sub-shape is not a face.");
|
||||
}
|
||||
|
||||
const TopoDS_Face& face = TopoDS::Face(shape);
|
||||
BRepAdaptor_Surface adapt(face);
|
||||
@@ -110,23 +118,23 @@ App::DocumentObjectExecReturn *Extend::execute()
|
||||
|
||||
double ur = u2 - u1;
|
||||
double vr = v2 - v1;
|
||||
double eu1 = u1 - ur*ExtendUNeg.getValue();
|
||||
double eu2 = u2 + ur*ExtendUPos.getValue();
|
||||
double ev1 = v1 - vr*ExtendVNeg.getValue();
|
||||
double ev2 = v2 + vr*ExtendVPos.getValue();
|
||||
double eu1 = u1 - ur * ExtendUNeg.getValue();
|
||||
double eu2 = u2 + ur * ExtendUPos.getValue();
|
||||
double ev1 = v1 - vr * ExtendVNeg.getValue();
|
||||
double ev2 = v2 + vr * ExtendVPos.getValue();
|
||||
double eur = eu2 - eu1;
|
||||
double evr = ev2 - ev1;
|
||||
|
||||
long numU = SampleU.getValue();
|
||||
long numV = SampleV.getValue();
|
||||
TColgp_Array2OfPnt approxPoints(1, numU, 1, numV);
|
||||
for (long u=0; u<numU; u++) {
|
||||
double uu = eu1 + u * eur / (numU-1);
|
||||
for (long v=0; v<numV; v++) {
|
||||
double vv = ev1 + v * evr / (numV-1);
|
||||
BRepLProp_SLProps prop(adapt,uu,vv,0,Precision::Confusion());
|
||||
for (long u = 0; u < numU; u++) {
|
||||
double uu = eu1 + u * eur / (numU - 1);
|
||||
for (long v = 0; v < numV; v++) {
|
||||
double vv = ev1 + v * evr / (numV - 1);
|
||||
BRepLProp_SLProps prop(adapt, uu, vv, 0, Precision::Confusion());
|
||||
const gp_Pnt& pnt = prop.Value();
|
||||
approxPoints(u+1, v+1) = pnt;
|
||||
approxPoints(u + 1, v + 1) = pnt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,30 +158,25 @@ App::DocumentObjectExecReturn *Extend::execute()
|
||||
void Extend::onChanged(const App::Property* prop)
|
||||
{
|
||||
// using a mutex and lock to protect a recursive calling when setting the new values
|
||||
if (lockOnChangeMutex)
|
||||
if (lockOnChangeMutex) {
|
||||
return;
|
||||
}
|
||||
Base::StateLocker lock(lockOnChangeMutex);
|
||||
|
||||
if (ExtendUSymetric.getValue())
|
||||
{
|
||||
if (prop == &ExtendUNeg || prop == &ExtendUPos)
|
||||
{
|
||||
if (ExtendUSymetric.getValue()) {
|
||||
if (prop == &ExtendUNeg || prop == &ExtendUPos) {
|
||||
auto changedValue = dynamic_cast<const App::PropertyFloat*>(prop);
|
||||
if (changedValue)
|
||||
{
|
||||
if (changedValue) {
|
||||
ExtendUNeg.setValue(changedValue->getValue());
|
||||
ExtendUPos.setValue(changedValue->getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ExtendVSymetric.getValue())
|
||||
{
|
||||
if (prop == &ExtendVNeg || prop == &ExtendVPos)
|
||||
{
|
||||
if (ExtendVSymetric.getValue()) {
|
||||
if (prop == &ExtendVNeg || prop == &ExtendVPos) {
|
||||
auto changedValue = dynamic_cast<const App::PropertyFloat*>(prop);
|
||||
if (changedValue)
|
||||
{
|
||||
if (changedValue) {
|
||||
ExtendVNeg.setValue(changedValue->getValue());
|
||||
ExtendVPos.setValue(changedValue->getValue());
|
||||
}
|
||||
@@ -182,18 +185,20 @@ void Extend::onChanged(const App::Property* prop)
|
||||
Part::Spline::onChanged(prop);
|
||||
}
|
||||
|
||||
void Extend::handleChangedPropertyName(Base::XMLReader &reader,
|
||||
const char * TypeName,
|
||||
const char *PropName)
|
||||
void Extend::handleChangedPropertyName(Base::XMLReader& reader,
|
||||
const char* TypeName,
|
||||
const char* PropName)
|
||||
{
|
||||
Base::Type type = Base::Type::fromName(TypeName);
|
||||
if (App::PropertyFloatConstraint::getClassTypeId() == type && strcmp(PropName, "ExtendU") == 0) {
|
||||
if (App::PropertyFloatConstraint::getClassTypeId() == type
|
||||
&& strcmp(PropName, "ExtendU") == 0) {
|
||||
App::PropertyFloatConstraint v;
|
||||
v.Restore(reader);
|
||||
ExtendUNeg.setValue(v.getValue());
|
||||
ExtendUPos.setValue(v.getValue());
|
||||
}
|
||||
else if (App::PropertyFloatConstraint::getClassTypeId() == type && strcmp(PropName, "ExtendV") == 0) {
|
||||
else if (App::PropertyFloatConstraint::getClassTypeId() == type
|
||||
&& strcmp(PropName, "ExtendV") == 0) {
|
||||
App::PropertyFloatConstraint v;
|
||||
v.Restore(reader);
|
||||
ExtendVNeg.setValue(v.getValue());
|
||||
|
||||
Reference in New Issue
Block a user