+ fix rendering problems for FEM elements
This commit is contained in:
parent
1c79de55ed
commit
2dc1890fd2
|
@ -72,12 +72,9 @@ ViewProviderFemConstraint::ViewProviderFemConstraint()
|
|||
pTextColor = new SoBaseColor();
|
||||
pTextColor->ref();
|
||||
|
||||
pMaterials = new SoMaterial();
|
||||
pMaterials = new SoBaseColor();
|
||||
pMaterials->ref();
|
||||
pMaterials->diffuseColor.setValue(1.0f, 0.0f, 0.2f);
|
||||
pMaterials->transparency.setValue(0.1f);
|
||||
//pMaterials->ambientColor.setValue(0.8f, 0.8f, 0.8f);
|
||||
//pMaterials->shininess.setValue(1.0);
|
||||
pMaterials->rgb.setValue(1.0f, 0.0f, 0.2f);
|
||||
|
||||
pShapeSep = new SoSeparator();
|
||||
pShapeSep->ref();
|
||||
|
@ -157,7 +154,7 @@ void ViewProviderFemConstraint::onChanged(const App::Property* prop)
|
|||
}
|
||||
else if (prop == &FaceColor) {
|
||||
const App::Color& c = FaceColor.getValue();
|
||||
pMaterials->diffuseColor.setValue(c.r,c.g,c.b);
|
||||
pMaterials->rgb.setValue(c.r,c.g,c.b);
|
||||
}
|
||||
else if (prop == &FontSize) {
|
||||
pFont->size = FontSize.getValue();
|
||||
|
|
|
@ -102,7 +102,7 @@ private:
|
|||
SoFontStyle * pFont;
|
||||
SoText2 * pLabel;
|
||||
SoBaseColor * pTextColor;
|
||||
SoMaterial * pMaterials;
|
||||
SoBaseColor * pMaterials;
|
||||
|
||||
protected:
|
||||
SoSeparator * pShapeSep;
|
||||
|
|
|
@ -107,24 +107,22 @@ bool ViewProviderFemConstraintFixed::setEdit(int ModNum)
|
|||
|
||||
#define HEIGHT 4
|
||||
#define WIDTH (1.5*HEIGHT)
|
||||
#define USE_MULTIPLE_COPY
|
||||
|
||||
void ViewProviderFemConstraintFixed::updateData(const App::Property* prop)
|
||||
{
|
||||
// Gets called whenever a property of the attached object changes
|
||||
Fem::ConstraintFixed* pcConstraint = static_cast<Fem::ConstraintFixed*>(this->getObject());
|
||||
|
||||
/*
|
||||
// This has a HUGE performance penalty as opposed to separate nodes for every symbol
|
||||
// The problem seems to be SoCone
|
||||
#ifdef USE_MULTIPLE_COPY
|
||||
if (pShapeSep->getNumChildren() == 0) {
|
||||
// Set up the nodes
|
||||
SoMultipleCopy* cp = new SoMultipleCopy();
|
||||
cp->ref();
|
||||
cp->matrix.setNum(0);
|
||||
cp->addChild((SoNode*)createFixed(HEIGHT, WIDTH));
|
||||
pShapeSep->addChild(cp);
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
|
||||
if (strcmp(prop->getName(),"Points") == 0) {
|
||||
const std::vector<Base::Vector3d>& points = pcConstraint->Points.getValues();
|
||||
|
@ -133,32 +131,36 @@ void ViewProviderFemConstraintFixed::updateData(const App::Property* prop)
|
|||
return;
|
||||
std::vector<Base::Vector3d>::const_iterator n = normals.begin();
|
||||
|
||||
// Note: Points and Normals are always updated together
|
||||
pShapeSep->removeAllChildren();
|
||||
|
||||
/*
|
||||
#ifdef USE_MULTIPLE_COPY
|
||||
SoMultipleCopy* 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));
|
||||
cp->matrix.set1Value(idx, m);
|
||||
idx++
|
||||
*/
|
||||
matrices[idx] = m;
|
||||
idx++;
|
||||
#else
|
||||
SoSeparator* sep = new SoSeparator();
|
||||
createPlacement(sep, base, rot);
|
||||
createFixed(sep, HEIGHT, WIDTH);
|
||||
pShapeSep->addChild(sep);
|
||||
|
||||
#endif
|
||||
n++;
|
||||
}
|
||||
#ifdef USE_MULTIPLE_COPY
|
||||
cp->matrix.finishEditing();
|
||||
#endif
|
||||
}
|
||||
|
||||
ViewProviderFemConstraint::updateData(prop);
|
||||
|
|
|
@ -106,15 +106,14 @@ bool ViewProviderFemConstraintForce::setEdit(int ModNum)
|
|||
|
||||
#define ARROWLENGTH 9
|
||||
#define ARROWHEADRADIUS (ARROWLENGTH/3)
|
||||
#define USE_MULTIPLE_COPY
|
||||
|
||||
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
|
||||
#ifdef USE_MULTIPLE_COPY
|
||||
if (pShapeSep->getNumChildren() == 0) {
|
||||
// Set up the nodes
|
||||
SoMultipleCopy* cp = new SoMultipleCopy();
|
||||
|
@ -123,12 +122,20 @@ void ViewProviderFemConstraintForce::updateData(const App::Property* prop)
|
|||
cp->addChild((SoNode*)createArrow(ARROWLENGTH, ARROWHEADRADIUS));
|
||||
pShapeSep->addChild(cp);
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
|
||||
if (strcmp(prop->getName(),"Points") == 0) {
|
||||
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();
|
||||
int idx = 0;
|
||||
#else
|
||||
// Redraw all arrows
|
||||
pShapeSep->removeAllChildren();
|
||||
|
||||
#endif
|
||||
// This should always point outside of the solid
|
||||
Base::Vector3d normal = pcConstraint->NormalDirection.getValue();
|
||||
|
||||
|
@ -140,29 +147,27 @@ void ViewProviderFemConstraintForce::updateData(const App::Property* prop)
|
|||
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;
|
||||
/*
|
||||
#ifdef USE_MULTIPLE_COPY
|
||||
SbMatrix m;
|
||||
m.setTransform(base, rot, SbVec3f(1,1,1));
|
||||
cp->matrix.set1Value(idx, m);
|
||||
matrices[idx] = m;
|
||||
idx++;
|
||||
*/
|
||||
#else
|
||||
SoSeparator* sep = new SoSeparator();
|
||||
createPlacement(sep, base, rot);
|
||||
createArrow(sep, ARROWLENGTH, ARROWHEADRADIUS);
|
||||
pShapeSep->addChild(sep);
|
||||
#endif
|
||||
}
|
||||
} else if (strcmp(prop->getName(),"DirectionVector") == 0) { // Note: "Reversed" also triggers "DirectionVector"
|
||||
#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();
|
||||
|
@ -174,26 +179,31 @@ void ViewProviderFemConstraintForce::updateData(const App::Property* prop)
|
|||
|
||||
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 * ARROWLENGTH;
|
||||
/*
|
||||
#ifdef USE_MULTIPLE_COPY
|
||||
SbMatrix m;
|
||||
m.setTransform(base, rot, SbVec3f(1,1,1));
|
||||
cp->matrix.set1Value(idx, m);*/
|
||||
|
||||
matrices[idx] = m;
|
||||
#else
|
||||
SoSeparator* sep = static_cast<SoSeparator*>(pShapeSep->getChild(idx));
|
||||
updatePlacement(sep, 0, base, rot);
|
||||
updateArrow(sep, 2, ARROWLENGTH, ARROWHEADRADIUS);
|
||||
#endif
|
||||
idx++;
|
||||
}
|
||||
#ifdef USE_MULTIPLE_COPY
|
||||
cp->matrix.finishEditing();
|
||||
#endif
|
||||
}
|
||||
|
||||
ViewProviderFemConstraint::updateData(prop);
|
||||
|
|
Loading…
Reference in New Issue
Block a user