void ViewProviderFemConstraintForce::updateData(const App::Property* prop)
{
    // Gets called whenever a property of the attached object changes
    Fem::ConstraintForce* pcConstraint = static_cast<Fem::ConstraintForce*>(this->getObject());

    /*
    // This has a HUGE performance penalty as opposed to separate nodes for every symbol
    // The problem seems to be SoCone
    if (pShapeSep->getNumChildren() == 0) {
        // Set up the nodes
        SoMultipleCopy* cp = new SoMultipleCopy();
        cp->ref();
        cp->matrix.setNum(0);
        cp->addChild((SoNode*)createArrow(ARROWLENGTH, ARROWHEADRADIUS));
        pShapeSep->addChild(cp);
    }
    */

    if (strcmp(prop->getName(),"Points") == 0) {
        // Redraw all arrows
        pShapeSep->removeAllChildren();

        // This should always point outside of the solid
        Base::Vector3d normal = pcConstraint->NormalDirection.getValue();

        // Get default direction (on first call to method)
        Base::Vector3d forceDirection = pcConstraint->DirectionVector.getValue();
        if (forceDirection.Length() < Precision::Confusion())
            forceDirection = normal;

        SbVec3f dir(forceDirection.x, forceDirection.y, forceDirection.z);
        SbRotation rot(SbVec3f(0,1,0), dir);

        const std::vector<Base::Vector3d>& points = pcConstraint->Points.getValues();

        /*
        SoMultipleCopy* cp = static_cast<SoMultipleCopy*>(pShapeSep->getChild(0));
        cp->matrix.setNum(points.size());
        int idx = 0;*/

        for (std::vector<Base::Vector3d>::const_iterator p = points.begin(); p != points.end(); p++) {
            SbVec3f base(p->x, p->y, p->z);
            if (forceDirection.GetAngle(normal) < M_PI_2) // Move arrow so it doesn't disappear inside the solid
                base = base + dir * ARROWLENGTH;
            /*
            SbMatrix m;
            m.setTransform(base, rot, SbVec3f(1,1,1));
            cp->matrix.set1Value(idx, m);
            idx++;
            */
            SoSeparator* sep = new SoSeparator();
            createPlacement(sep, base, rot);
            createArrow(sep, ARROWLENGTH, ARROWHEADRADIUS);
            pShapeSep->addChild(sep);
        }
    } else if (strcmp(prop->getName(),"DirectionVector") == 0) { // Note: "Reversed" also triggers "DirectionVector"
        // Re-orient all arrows
        Base::Vector3d normal = pcConstraint->NormalDirection.getValue();
        Base::Vector3d forceDirection = pcConstraint->DirectionVector.getValue();
        if (forceDirection.Length() < Precision::Confusion())
            forceDirection = normal;

        SbVec3f dir(forceDirection.x, forceDirection.y, forceDirection.z);
        SbRotation rot(SbVec3f(0,1,0), dir);

        const std::vector<Base::Vector3d>& points = pcConstraint->Points.getValues();

        /*
        SoMultipleCopy* cp = static_cast<SoMultipleCopy*>(pShapeSep->getChild(0));
        cp->matrix.setNum(points.size());
        */
        int idx = 0;

        for (std::vector<Base::Vector3d>::const_iterator p = points.begin(); p != points.end(); p++) {
            SbVec3f base(p->x, p->y, p->z);
            if (forceDirection.GetAngle(normal) < M_PI_2)
                base = base + dir * ARROWLENGTH;
            /*
            SbMatrix m;
            m.setTransform(base, rot, SbVec3f(1,1,1));
            cp->matrix.set1Value(idx, m);*/

            SoSeparator* sep = static_cast<SoSeparator*>(pShapeSep->getChild(idx));
            updatePlacement(sep, 0, base, rot);
            updateArrow(sep, 2, ARROWLENGTH, ARROWHEADRADIUS);
            idx++;
        }
    }

    ViewProviderFemConstraint::updateData(prop);
}
void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* prop)
{
    // Gets called whenever a property of the attached object changes
    Fem::ConstraintFluidBoundary* pcConstraint = static_cast<Fem::ConstraintFluidBoundary*>(this->getObject());
    float scaledwidth = WIDTH * pcConstraint->Scale.getValue(); //OvG: Calculate scaled values once only
    float scaledheight = HEIGHT * pcConstraint->Scale.getValue();

    float scaledheadradius = ARROWHEADRADIUS * pcConstraint->Scale.getValue(); //OvG: Calculate scaled values once only
    float scaledlength = ARROWLENGTH * pcConstraint->Scale.getValue();

    std::string boundaryType = pcConstraint->BoundaryType.getValueAsString();
    if (strcmp(prop->getName(),"BoundaryType") == 0)
    {
        if (boundaryType == "wall")
        {
            FaceColor.setValue(0.0,1.0,1.0);
        }
        else if (boundaryType == "interface")
        {
            FaceColor.setValue(0.0,1.0,0.0);
        }
        else if (boundaryType == "freestream")
        {
            FaceColor.setValue(1.0,1.0,0.0);
        }
        else if(boundaryType == "inlet")
        {
            FaceColor.setValue(1.0,0.0,0.0);
        }
        else //(boundaryType == "outlet")
        {
            FaceColor.setValue(0.0,0.0,1.0);
        }
    }
        
    if (boundaryType == "inlet" || boundaryType == "outlet"){
#ifdef USE_MULTIPLE_COPY
        //OvG: need access to cp for scaling
        SoMultipleCopy* cp = new SoMultipleCopy();
        if (pShapeSep->getNumChildren() == 0) {
            // Set up the nodes
            cp->matrix.setNum(0);
            cp->addChild((SoNode*)createArrow(scaledlength , scaledheadradius)); //OvG: Scaling
            pShapeSep->addChild(cp);
        }
#endif

        if (strcmp(prop->getName(),"Points") == 0) {
            const std::vector<Base::Vector3d>& points = pcConstraint->Points.getValues();

#ifdef USE_MULTIPLE_COPY
            cp = static_cast<SoMultipleCopy*>(pShapeSep->getChild(0));
            cp->matrix.setNum(points.size());
            SbMatrix* matrices = cp->matrix.startEditing();
            int idx = 0;
#else
            // Redraw all arrows
            pShapeSep->removeAllChildren();
#endif
            // This should always point outside of the solid
            Base::Vector3d normal = pcConstraint->NormalDirection.getValue();

            // Get default direction (on first call to method)
            Base::Vector3d forceDirection = pcConstraint->DirectionVector.getValue();
            if (forceDirection.Length() < Precision::Confusion())
                forceDirection = normal;

            SbVec3f dir(forceDirection.x, forceDirection.y, forceDirection.z);
            SbRotation rot(SbVec3f(0,1,0), dir);

            for (std::vector<Base::Vector3d>::const_iterator p = points.begin(); p != points.end(); p++) {
                SbVec3f base(p->x, p->y, p->z);
                if (forceDirection.GetAngle(normal) < M_PI_2) // Move arrow so it doesn't disappear inside the solid
                    base = base + dir * scaledlength; //OvG: Scaling
#ifdef USE_MULTIPLE_COPY
                SbMatrix m;
                m.setTransform(base, rot, SbVec3f(1,1,1));
                matrices[idx] = m;
                idx++;
#else
                SoSeparator* sep = new SoSeparator();
                createPlacement(sep, base, rot);
                createArrow(sep, scaledlength, scaledheadradius); //OvG: Scaling
                pShapeSep->addChild(sep);
#endif
            }
#ifdef USE_MULTIPLE_COPY
            cp->matrix.finishEditing();
#endif
        }
        else if (strcmp(prop->getName(),"DirectionVector") == 0) { // Note: "Reversed" also triggers "DirectionVector"
            // Re-orient all arrows
            Base::Vector3d normal = pcConstraint->NormalDirection.getValue();
            Base::Vector3d forceDirection = pcConstraint->DirectionVector.getValue();
            if (forceDirection.Length() < Precision::Confusion())
                forceDirection = normal;

            SbVec3f dir(forceDirection.x, forceDirection.y, forceDirection.z);
            SbRotation rot(SbVec3f(0,1,0), dir);

            const std::vector<Base::Vector3d>& points = pcConstraint->Points.getValues();

#ifdef USE_MULTIPLE_COPY
            SoMultipleCopy* cp = static_cast<SoMultipleCopy*>(pShapeSep->getChild(0));
            cp->matrix.setNum(points.size());
            SbMatrix* matrices = cp->matrix.startEditing();
#endif
            int idx = 0;

            for (std::vector<Base::Vector3d>::const_iterator p = points.begin(); p != points.end(); p++) {
                SbVec3f base(p->x, p->y, p->z);
                if (forceDirection.GetAngle(normal) < M_PI_2)
                    base = base + dir * scaledlength; //OvG: Scaling
#ifdef USE_MULTIPLE_COPY
                SbMatrix m;
                m.setTransform(base, rot, SbVec3f(1,1,1));
                matrices[idx] = m;
#else
                SoSeparator* sep = static_cast<SoSeparator*>(pShapeSep->getChild(idx));
                updatePlacement(sep, 0, base, rot);
                updateArrow(sep, 2, scaledlength, scaledheadradius); //OvG: Scaling
#endif
                idx++;
            }
#ifdef USE_MULTIPLE_COPY
            cp->matrix.finishEditing();
#endif
        }
    }
    else{// not inlet or outlet boundary type

#ifdef USE_MULTIPLE_COPY
        //OvG: always need access to cp for scaling
        SoMultipleCopy* cp = new SoMultipleCopy();
        if (pShapeSep->getNumChildren() == 0) {
            // Set up the nodes
            cp->matrix.setNum(0);
            cp->addChild((SoNode*)createFixed(scaledheight, scaledwidth)); //OvG: Scaling
            pShapeSep->addChild(cp);
        }
#endif

        if (strcmp(prop->getName(),"Points") == 0) {
            const std::vector<Base::Vector3d>& points = pcConstraint->Points.getValues();
            const std::vector<Base::Vector3d>& normals = pcConstraint->Normals.getValues();
            if (points.size() != normals.size())
                return;
            std::vector<Base::Vector3d>::const_iterator n = normals.begin();

#ifdef USE_MULTIPLE_COPY
            cp = static_cast<SoMultipleCopy*>(pShapeSep->getChild(0));
            cp->matrix.setNum(points.size());
            SbMatrix* matrices = cp->matrix.startEditing();
            int idx = 0;
#else
            // Note: Points and Normals are always updated together
            pShapeSep->removeAllChildren();
#endif

            for (std::vector<Base::Vector3d>::const_iterator p = points.begin(); p != points.end(); p++) {
                SbVec3f base(p->x, p->y, p->z);
                SbVec3f dir(n->x, n->y, n->z);
                SbRotation rot(SbVec3f(0,-1,0), dir);
#ifdef USE_MULTIPLE_COPY
                SbMatrix m;
                m.setTransform(base, rot, SbVec3f(1,1,1));
                matrices[idx] = m;
                idx++;
#else
                SoSeparator* sep = new SoSeparator();
                createPlacement(sep, base, rot);
                createFixed(sep, scaledheight, scaledwidth); //OvG: Scaling
                pShapeSep->addChild(sep);
#endif
                n++;
            }
#ifdef USE_MULTIPLE_COPY
            cp->matrix.finishEditing();
#endif
        }
    }

    ViewProviderFemConstraint::updateData(prop);
}