Standard_Boolean ShHealOper_FillHoles::Fill(const TopTools_SequenceOfShape& theFillShapes)
{
  myDone = Standard_False;
  myErrorStatus = ShHealOper_NotError;
  if(myInitShape.IsNull()) {
    myErrorStatus = ShHealOper_InvalidParameters;
    return myDone;
  }
  if(!theFillShapes.Length()) {
    return myDone;
  }

  Handle(TopTools_HSequenceOfShape) aSeqWires = new TopTools_HSequenceOfShape;
  if(!prepareWires(theFillShapes,aSeqWires)) {
    myErrorStatus = ShHealOper_InvalidParameters;
    return myDone;
  }

  myResultShape = myInitShape;
  Standard_Integer i =1;
  for( ; i <= aSeqWires->Length(); i++) {
    TopoDS_Wire aWire = TopoDS::Wire(aSeqWires->Value(i));
    Handle(TColGeom2d_HArray1OfCurve) aCurves2d;
    Handle(TColStd_HArray1OfInteger) aOrders;
    Handle(TColStd_HArray1OfInteger) aSenses;
    Handle(Geom_Surface) aSurf = buildSurface(aWire,aCurves2d,aOrders,aSenses);
    if(aSurf.IsNull())
      myErrorStatus = ShHealOper_ErrorExecution;
    else 
      myDone = (addFace(aSurf,aWire,aCurves2d,aOrders,aSenses) || myDone);
  }
  if(myDone)
    myResultShape = myContext->Apply(myResultShape);
  return myDone;
}
Example #2
0
void TestWindow::updateSurfaces() {
    auto now = usecTimestampNow();
    // Fetch any new textures
    for (size_t x = 0; x < DIVISIONS_X; ++x) {
        for (size_t y = 0; y < DIVISIONS_Y; ++y) {
            auto& qmlInfo = _surfaces[x][y];
            if (!qmlInfo.surface) {
                if (now < _createStopTime && randFloat() > 0.99f) {
                    buildSurface(qmlInfo, x == 0 && y == 0);
                } else {
                    continue;
                }
            }

            if (now > qmlInfo.lifetime) {
                destroySurface(qmlInfo);
                continue;
            }

            auto& surface = qmlInfo.surface;
            auto& currentTexture = qmlInfo.texture;

            TextureAndFence newTextureAndFence;
            if (surface->fetchTexture(newTextureAndFence)) {
                if (currentTexture != 0) {
                    auto readFence = _glf.glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
                    glFlush();
                    _discardLamdba(currentTexture, readFence);
                }
                currentTexture = newTextureAndFence.first;
                _glf.glWaitSync((GLsync)newTextureAndFence.second, 0, GL_TIMEOUT_IGNORED);
            }
        }
    }
}
SelectionVOI::SelectionVOI( Anatomy *pSourceAnatomy, const float threshold, const ThresholdingOperationType opType )
    : SelectionObject( Vector( 0.0f, 0.0f, 0.0f ), Vector( 0.0f, 0.0f, 0.0f ) ),
      m_voiSize( 0 ),
      m_generationThreshold( threshold ),
      m_thresType( opType ),
      m_pIsoSurface( NULL ),
      m_sourceAnatIndex( pSourceAnatomy->getDatasetIndex() )
{   
    wxString mystring(wxT("[VOI] - ") + pSourceAnatomy->getName());
    m_name          = mystring;
    m_objectType    = VOI_TYPE;
    
    buildSurface( pSourceAnatomy );
    
    setColor( wxColour( 240, 30, 30 ) );
}
Example #4
0
//-----------------------------------------------------------------------------
// create vertex and index buffers
void Wreck::createSpine(
  int sideSteps,
  int outSteps)
{
  mgBezier outSpline;
  outSpline.addVertex(mgPoint3(  0.0, 10.0,   9.5),    mgPoint3(  0.0,    10.0+10,   9.5-3));
  outSpline.addVertex(mgPoint3( 10.0, 40.0,   0.0),    mgPoint3( 10.0-10, 40.0,      0.0));
  outSpline.addVertex(mgPoint3( 30.0, 10.0,   0.0),    mgPoint3( 30.0-10, 10.0,      0.0));
  outSpline.addVertex(mgPoint3( 60.0, 10.0,   0.0),    mgPoint3( 60.0,    10.0,      0.0));
  outSpline.addVertex(mgPoint3(180.0, 10.0,   0.0),    mgPoint3(180.0,    10.0,      0.0));
  outSpline.addVertex(mgPoint3(180.0, 10.0,   0.0),    mgPoint3(180.0-10, 10.0,      0.0));
  outSpline.addVertex(mgPoint3(210.0, 30.0,   5.0),    mgPoint3(210.0-10, 30.0,      5.0));
  outSpline.addVertex(mgPoint3(240.0, 30.0,   5.0),    mgPoint3(240.0-10, 30.0,      5.0));
  outSpline.addVertex(mgPoint3(235.0, 17.5,  17.0),    mgPoint3(235.0,    17.5+5,   17.0-5));

  mgBezier sideSpline;
  double left = 150*PI/180.0;
  double lx = 10*cos(left);  
  double ly = 10*sin(left);

  double right = 30*PI/180.0;
  double rx = 10*cos(right);
  double ry = 10*sin(right);

  sideSpline.addVertex(mgPoint3(0.0,    0.0,    0.0),       mgPoint3(0.0-1,   0.0+1,    0.0));
  sideSpline.addVertex(mgPoint3(lx+2,   ly+1,   0.0),       mgPoint3(lx+2,    ly+1-2,   0.0));
  sideSpline.addVertex(mgPoint3(0.0,    10.0,   0.0),       mgPoint3(0-2.5,   10,       0.0));
  sideSpline.addVertex(mgPoint3(rx-2,   ry+1,   0.0),       mgPoint3(rx-2,    ry+1+2,   0.0));
  sideSpline.addVertex(mgPoint3(0.0,    0.0,    0.0),       mgPoint3(0.0+1,   0.0+1,    0.0));

  for (int i = 0; i < 3; i++)
  {
    mgMatrix4 rotate;
    rotate.rotateZDeg(i*120);
    buildSurface(sideSpline, 0.1, sideSteps, outSpline, 1.0, outSteps, rotate, false, 0);
  }
}
SelectionVOI::SelectionVOI( const wxXmlNode selObjNode, const wxString &rootPath )
: SelectionObject( selObjNode ),
  m_voiSize( 0 ),
  m_generationThreshold( 0.0f ),
  m_thresType( THRESHOLD_INVALID ),
  m_pIsoSurface( NULL ),
  m_sourceAnatIndex( 0 )
{
    m_objectType = VOI_TYPE;
    
    wxXmlNode *pChildNode = selObjNode.GetChildren();
    
    while( pChildNode != NULL )
    {
        wxString nodeName = pChildNode->GetName();
        wxString propVal;
        
        if( nodeName == wxT("voi_properties") )
        {
            double temp;
            pChildNode->GetAttribute( wxT("gen_threshold"), &propVal );
            propVal.ToDouble(&temp);
            m_generationThreshold = temp;
            
            pChildNode->GetAttribute( wxT("thres_op_type"), &propVal );
            m_thresType = Helper::getThresholdingTypeFromString( propVal );
            
            wxXmlNode *pAnatNode = pChildNode->GetChildren();
            if( pAnatNode->GetName() == wxT("generation_anatomy") )
            {
                wxString anatPath = pAnatNode->GetNodeContent();

                // Get full path, since this is how it is stored in the dataset.
                wxFileName fullAnatPath( rootPath + wxFileName::GetPathSeparator() + anatPath );
                               
                // Find the anatomy related to this file.
                vector< Anatomy* > anats = DatasetManager::getInstance()->getAnatomies();
                for( vector< Anatomy* >::iterator anatIt( anats.begin() ); anatIt != anats.end(); ++anatIt )
                {
                    if( (*anatIt)->getPath() == fullAnatPath.GetFullPath() )
                    {
                        m_sourceAnatIndex = (*anatIt)->getDatasetIndex();
                        break;
                    }
                }
                
                if( !m_sourceAnatIndex.isOk() )
                {
                    wxString err( wxT("Anatomy: ") );
                    err << anatPath << wxT(" does not exist when creating VOI called: ") << getName() << wxT(".");
                    throw  err;
                }
                
                Anatomy *pCurAnat = dynamic_cast< Anatomy* >( DatasetManager::getInstance()->getDataset( m_sourceAnatIndex ) );
                buildSurface( pCurAnat );
            }
        }
        
        pChildNode = pChildNode->GetNext();
    }
}