Ejemplo n.º 1
0
void ViewProviderLine::attach ( App::DocumentObject *obj ) {
    ViewProviderOriginFeature::attach ( obj );

    static const float size = ViewProviderOrigin::defaultSize ();

    static const SbVec3f verts[2] = { SbVec3f(size, 0, 0),   SbVec3f ( -size, 0, 0 ) };

    // indexes used to create the edges
    static const int32_t lines[4] = { 0, 1, -1 };

    SoSeparator *sep = getOriginFeatureRoot ();

    SoCoordinate3 *pCoords = new SoCoordinate3 ();
    pCoords->point.setNum (2);
    pCoords->point.setValues ( 0, 2, verts );
    sep->addChild ( pCoords );

    SoIndexedLineSet *pLines  = new SoIndexedLineSet ();
    pLines->ref();
    pLines->coordIndex.setNum(3);
    pLines->coordIndex.setValues(0, 3, lines);
    sep->addChild ( pLines );

    SoTranslation *textTranslation = new SoTranslation ();
    textTranslation->ref ();
    textTranslation->translation.setValue ( SbVec3f ( -size * 49. / 50., size / 30., 0 ) );
    sep->addChild ( textTranslation );

    sep->addChild ( getLabel () );
}
void ViewProviderFemConstraint::createPlacement(SoSeparator* sep, const SbVec3f &base, const SbRotation &r)
{
    SoTranslation* trans = new SoTranslation();
    trans->ref();
    trans->translation.setValue(base);
    sep->addChild(trans);
    SoRotation* rot = new SoRotation();
    rot->ref();
    rot->rotation.setValue(r);
    sep->addChild(rot);
}
void ViewProviderFemConstraint::createCone(SoSeparator* sep, const double height, const double radius)
{
    // Adjust cone so that the tip is on base
    SoTranslation* trans = new SoTranslation();
    trans->ref();
    trans->translation.setValue(SbVec3f(0,-height/2,0));
    sep->addChild(trans);
    SoCone* cone = new SoCone();
    cone->ref();
    cone->height.setValue(height);
    cone->bottomRadius.setValue(radius);
    sep->addChild(cone);
}
Ejemplo n.º 4
0
void SoColorShape::compute() {
   enableNotify(false);
   // alles schoen auf nichts zurücksetzen
   if (_vertexPropArray) { delete[] _vertexPropArray; _vertexPropArray = 0; }
   if (_sizeCoordinate3) { delete[] _sizeCoordinate3; _sizeCoordinate3 = 0; }

   if (_vertexSet)   {
      for (int index = 0; index < (_extentX * _extentY * _extentZ); index++) 
         _vertexSet[index].clear();
      delete[] _vertexSet;     
      _vertexSet = 0; 
   }
   if (_triangleSet) { 
      for (int index = 0; index < (_extentX * _extentY * _extentZ); index++) 
         _triangleSet[index].clear(); 
      delete[] _triangleSet; 
      _triangleSet = 0; 
   }
   if (_edgeSet)     { 
      for (int index = 0; index < (_extentX * _extentY * _extentZ); index++) 
         _edgeSet[index].clear();     
      delete[] _edgeSet;     
      _edgeSet = 0; 
   }
   removeAllChildren();

   if (input.getValue() != 0) {
      // Bounding Box bestimmen
      SoComputeBoundingBox* bbact = new SoComputeBoundingBox;
      SoTranslation *min = new SoTranslation, *max = new SoTranslation;
      min->ref(); max->ref();
      bbact->ref();
      bbact->node = input.getValue();
      min->translation.connectFrom(&bbact->min);
      max->translation.connectFrom(&bbact->max);
      SbBox3f bBox(min->translation.getValue(), max->translation.getValue());

      min->unref(), max->unref();
      bbact->unref();

      // Eingang hat sich geändert
      if (!bBox.isEmpty()) {
         // Array fuer _edgeSet und _triangleSet set-Instanzen initialisieren
         float xSize, ySize, zSize;
         bBox.getSize(xSize, ySize, zSize);
         _offSet = bBox.getMin();

         _extentX = xSize / (float) HASH_PARTITION + 1; 
         _extentY = ySize / (float) HASH_PARTITION + 1; 
         _extentZ = zSize / (float) HASH_PARTITION + 1;

         _vertexSet =   new std::set<Vertex*, ltVertex>[_extentX * _extentY * _extentZ];
         _edgeSet =     new std::set<Edge*,   ltEdge  >[_extentX * _extentY * _extentZ];
         _triangleSet = new std::set<Triangle*        >[_extentX * _extentY * _extentZ];

         _vertexPropArray = new SoVertexProperty*[_extentX * _extentY * _extentZ];
         int index = 0;
         for (index = 0; index < (_extentX * _extentY * _extentZ); index++)
            _vertexPropArray[index] = 0;

         _sizeCoordinate3 = new int[_extentX * _extentY * _extentZ];
         for (index = 0; index < (_extentX * _extentY * _extentZ); index++)
            _sizeCoordinate3[index] = -1;

         // Dreiecke aufsammeln
         _myAction->apply(input.getValue());

         // SoIndexedTriangleStripSet erstellen
         generateITSS();
      }
   }
   enableNotify(true);
   touch();
}