Ejemplo n.º 1
0
void ImpExpDxfWrite::setOptions(void)
{
    ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(getOptionSource().c_str());
    optionMaxLength = hGrp->GetFloat("maxsegmentlength",5.0);
    optionExpPoints  = hGrp->GetBool("ExportPoints",false);
    m_version = hGrp->GetInt("DxfVersionOut",14);
    optionPolyLine  = hGrp->GetBool("DiscretizeEllipses",false);
    m_polyOverride = hGrp->GetBool("DiscretizeEllipses",false);
    setDataDir(App::Application::getResourceDir() + "Mod/Import/DxfPlate/");
}
Ejemplo n.º 2
0
bool ViewProviderPartExt::loadParameter()
{
    bool changed = false;
    ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
        ("User parameter:BaseApp/Preferences/Mod/Part");
    float deviation = hGrp->GetFloat("MeshDeviation",0.2);
    bool novertexnormals = hGrp->GetBool("NoPerVertexNormals",false);
    bool qualitynormals = hGrp->GetBool("QualityNormals",false);

    if (Deviation.getValue() != deviation) {
        Deviation.setValue(deviation);
        changed = true;
    }
    if (this->noPerVertexNormals != novertexnormals) {
        this->noPerVertexNormals = novertexnormals;
        changed = true;
    }
    if (this->qualityNormals != qualitynormals) {
        this->qualityNormals = qualitynormals;
        changed = true;
    }

    return changed;
}
void ViewProviderInspection::updateData(const App::Property* prop)
{
    // set to the expected size
    if (prop->getTypeId() == App::PropertyLink::getClassTypeId()) {
        App::GeoFeature* object = static_cast<const App::PropertyLink*>(prop)->getValue<App::GeoFeature*>();
        if (object) {
            float accuracy=0;
            Base::Type meshId  = Base::Type::fromName("Mesh::Feature");
            Base::Type shapeId = Base::Type::fromName("Part::Feature");
            Base::Type pointId = Base::Type::fromName("Points::Feature");
            Base::Type propId  = App::PropertyComplexGeoData::getClassTypeId();

            // set the Distance property to the correct size to sync size of material node with number
            // of vertices/points of the referenced geometry
            const Data::ComplexGeoData* data = 0;
            if (object->getTypeId().isDerivedFrom(meshId)) {
                App::Property* prop = object->getPropertyByName("Mesh");
                if (prop && prop->getTypeId().isDerivedFrom(propId)) {
                    data = static_cast<App::PropertyComplexGeoData*>(prop)->getComplexData();
                }
            }
            else if (object->getTypeId().isDerivedFrom(shapeId)) {
                App::Property* prop = object->getPropertyByName("Shape");
                if (prop && prop->getTypeId().isDerivedFrom(propId)) {
                    data = static_cast<App::PropertyComplexGeoData*>(prop)->getComplexData();
                    ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
                        ("User parameter:BaseApp/Preferences/Mod/Part");
                    float deviation = hGrp->GetFloat("MeshDeviation",0.2);

                    Base::BoundBox3d bbox = data->getBoundBox();
                    accuracy = (float)((bbox.LengthX() + bbox.LengthY() + bbox.LengthZ())/300.0 * deviation);
                }
            }
            else if (object->getTypeId().isDerivedFrom(pointId)) {
                App::Property* prop = object->getPropertyByName("Points");
                if (prop && prop->getTypeId().isDerivedFrom(propId)) {
                    data = static_cast<App::PropertyComplexGeoData*>(prop)->getComplexData();
                }
            }

            if (data) {
                this->pcLinkRoot->removeAllChildren();
                std::vector<Base::Vector3d> points;
                std::vector<Data::ComplexGeoData::Facet> faces;
                data->getFaces(points, faces, accuracy);

                this->pcLinkRoot->addChild(this->pcCoords);
                this->pcCoords->point.setNum(points.size());
                SbVec3f* pts = this->pcCoords->point.startEditing();
                for (size_t i=0; i < points.size(); i++) {
                    const Base::Vector3d& p = points[i];
                    pts[i].setValue((float)p.x,(float)p.y,(float)p.z);
                }
                this->pcCoords->point.finishEditing();

                if (!faces.empty()) {
                    SoIndexedFaceSet* face = new SoIndexedFaceSet();
                    this->pcLinkRoot->addChild(face);
                    face->coordIndex.setNum(4*faces.size());
                    int32_t* indices = face->coordIndex.startEditing();
                    unsigned long j=0;
                    std::vector<Data::ComplexGeoData::Facet>::iterator it;
                    for (it = faces.begin(); it != faces.end(); ++it,j++) {
                        indices[4*j+0] = it->I1;
                        indices[4*j+1] = it->I2;
                        indices[4*j+2] = it->I3;
                        indices[4*j+3] = SO_END_FACE_INDEX;
                    }
                    face->coordIndex.finishEditing();
                }
                else {
                    this->pcLinkRoot->addChild(this->pcPointStyle);
                    this->pcLinkRoot->addChild(new SoPointSet());
                }
            }
        }
    }
    else if (prop->getTypeId() == Inspection::PropertyDistanceList::getClassTypeId()) {
        // force an update of the Inventor data nodes
        if (this->pcObject) {
            App::Property* link = this->pcObject->getPropertyByName("Actual");
            if (link) updateData(link);
        }
        setDistances();
    }
    else if (prop->getTypeId() == App::PropertyFloat::getClassTypeId()) {
        if (strcmp(prop->getName(), "SearchRadius") == 0) {
            float fSearchRadius = ((App::PropertyFloat*)prop)->getValue();
            this->search_radius = fSearchRadius;
            pcColorBar->setRange( -fSearchRadius, fSearchRadius, 4 );
            pcColorBar->Notify(0);
        }
    }
}