void convert(size_t start, size_t end) const
    {
      float rotMat[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } };
      FOrientArrayType om(9, 0.0f);
      FOrientTransformsType::ax2om(FOrientArrayType(axis[0], axis[1], axis[2], angle), om);
      om.toGMatrix(rotMat);

      float ea1 = 0, ea2 = 0, ea3 = 0;
      float g[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } , { 0.0f, 0.0f, 0.0f } };
      float gNew[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } };
      for (size_t i = start; i < end; i++)
      {
        ea1 = m_CellEulerAngles[3 * i + 0];
        ea2 = m_CellEulerAngles[3 * i + 1];
        ea3 = m_CellEulerAngles[3 * i + 2];
        FOrientArrayType om(9);
        FOrientTransformsType::eu2om(FOrientArrayType(ea1, ea2, ea3), om);
        om.toGMatrix(g);

        MatrixMath::Multiply3x3with3x3(g, rotMat, gNew);
        MatrixMath::Normalize3x3(gNew);
        // Because we are going to simply wrap the m_CellEulerAngles array, the new
        // Euler angles will be directly written to the m_CellEulerAngles array
        // at the proper spot
        FOrientArrayType eu( m_CellEulerAngles + (3 * i), 3);
        FOrientTransformsType::om2eu(FOrientArrayType(gNew), eu);
      }
    }
Esempio n. 2
0
void OutputPatch_Test::dump()
{
    QByteArray uni(513, char(0));
    uni[0] = 100;
    uni[169] = 50;
    uni[511] = 25;

    OutputMap om(m_doc, 4);
    OutputPatch* op = new OutputPatch(this);

    OutputPluginStub* stub = static_cast<OutputPluginStub*>
                                (m_doc->ioPluginCache()->plugins().at(0));
    QVERIFY(stub != NULL);

    op->set(stub, 0);
    QVERIFY(stub->m_universe[0] == (char) 0);
    QVERIFY(stub->m_universe[169] == (char) 0);
    QVERIFY(stub->m_universe[511] == (char) 0);

    op->dump(uni);
    QVERIFY(stub->m_universe[0] == (char) 100);
    QVERIFY(stub->m_universe[169] == (char) 50);
    QVERIFY(stub->m_universe[511] == (char) 25);

    delete op;
}
Esempio n. 3
0
  // Get sub-matrix: TEST A
  const BlockMatrix BlockMatrix::subMatrix( const unsigned int atRow, const unsigned int atColumn,
      const unsigned int getRows, const unsigned int getColumns ) const
  {
    //create matrix
    BlockMatrix om( atRow, atColumn, getRows, getColumns );
    om.clear();

    const unsigned int atRowSize = atRow + getRows;
    const unsigned int atColSize = atColumn + getColumns;

    if ( atRow >= RowStart && atRowSize <= RowStart + Rows &&
         atColumn >= ColumnStart && atColSize <= ColumnStart + Columns ) {

      for ( unsigned int i = atRow; i < atRowSize; ++i ) {
        const int iTempStart  = i - om.RowStart;
        const int iThisStart  = i -    RowStart;

        for ( unsigned int j = atColumn; j < atColSize; ++j ) {
          om.MyArray.at( iTempStart + ( j - om.ColumnStart ) * om.Rows ) =
            MyArray[iThisStart + ( j - ColumnStart ) * Rows];
        }
      }
    }
    return om;
  }
Esempio n. 4
0
void BitObject::drawOutline(Image<T_or_RGB>& img, 
                            const T_or_RGB& color,
                            float opacity)
{
  ASSERT(isValid());
  ASSERT(img.initialized());
  float op2 = 1.0F - opacity;

  Dims d = img.getDims();
  Image<byte> mask = getObjectMask();

  // rescale if needed
  if (d != itsImageDims)
    mask = rescaleNI(mask, d.w(), d.h());

  // object-shaped drawing
  int thick = 1;
  Image<byte> om(mask);
  om = contour2D(om);       // compute binary contour image
  const int w = img.getWidth();
  const int h = img.getHeight();
  Point2D<int> ppp;
  for (ppp.j = 0; ppp.j < h; ppp.j ++)
    for (ppp.i = 0; ppp.i < w; ppp.i ++)
      if (om.getVal(ppp.i, ppp.j))  // got a contour point -> draw here
        drawDisk(img, ppp, thick, T_or_RGB(img.getVal(ppp) * op2 + color * opacity));  // small disk for each point

} // end drawOutline
Esempio n. 5
0
VolumeList* Synth2DReader::read(const std::string &fileName) throw (tgt::FileException, std::bad_alloc) {
    RawVolumeReader rawReader(getProgressBar());

    FILE* fin = fopen(fileName.c_str(), "rb");
    char buf[4096];
    fread(buf, 4096, 1, fin);
    fclose(fin);

    Synth2DVolumeHeader* header = (Synth2DVolumeHeader *)buf;
    if ((header->magic[0] != 'V') || (header->magic[1] != 'O') || (header->magic[2] != 'L') || (header->magic[3] != 'U') || (header->version != 4)
            || (header->bytesPerChannel != 1) || (header->numChannels != 1 && header->numChannels != 3 && header->numChannels != 4))
        throw tgt::CorruptedFileException("error while reading data", fileName);

    std::string om("I");
    if(header->numChannels == 3)
        om = std::string("RGB");
    else if(header->numChannels == 4)
        om = std::string("RGBA");

    ivec3 dims(header->volSize);
    rawReader.setReadHints(dims,                     // dimensions of the volume
                           ivec3(1, 1, 1),           // thickness of one slice
                           om,                       // intensity, rgb or rgba image
                           "UCHAR",                  // one unsigned char per voxel
                           1,                        // number of time frames
                           4096);                    // header skip

    VolumeList* volumeList = rawReader.read(fileName);

    return volumeList;
}
Esempio n. 6
0
void
EditorInputCenter::set_object() {
  if (hovered_object && hovered_object->do_save()) {
    std::unique_ptr<Menu> om(new ObjectMenu(hovered_object));
    Editor::current()->deactivate_request = true;
    MenuManager::instance().push_menu(move(om));
    return;
  }
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
int32_t GroupMicroTextureRegions::getSeed(int32_t newFid)
{
  setErrorCondition(0);

  int32_t numfeatures = static_cast<int32_t>(m_FeaturePhasesPtr.lock()->getNumberOfTuples());

  float c1[3] = { 0.0f, 0.0f, 0.0f };
  uint32_t phase1 = 0;
  QuatF* avgQuats = reinterpret_cast<QuatF*>(m_AvgQuats);
  float caxis[3] = { 0.0f, 0.0f, 1.0f };
  QuatF q1 = QuaternionMathF::New();
  float g1[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } };
  float g1t[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } };

  SIMPL_RANDOMNG_NEW()
  int32_t seed = -1;
  int32_t randfeature = 0;

  // Precalculate some constants
  int32_t totalFMinus1 = numfeatures - 1;

  size_t counter = 0;
  randfeature = int32_t(float(rg.genrand_res53()) * float(totalFMinus1));
  while (seed == -1 && counter < numfeatures)
  {
    if (randfeature > totalFMinus1) { randfeature = randfeature - numfeatures; }
    if (m_FeatureParentIds[randfeature] == -1) { seed = randfeature; }
    randfeature++;
    counter++;
  }
  if (seed >= 0)
  {
    m_FeatureParentIds[seed] = newFid;
    QVector<size_t> tDims(1, newFid + 1);
    getDataContainerArray()->getDataContainer(m_FeatureIdsArrayPath.getDataContainerName())->getAttributeMatrix(getNewCellFeatureAttributeMatrixName())->resizeAttributeArrays(tDims);
    updateFeatureInstancePointers();

    if (m_UseRunningAverage == true)
    {
      QuaternionMathF::Copy(avgQuats[seed], q1);
      phase1 = m_CrystalStructures[m_FeaturePhases[seed]];
      FOrientArrayType om(9);
      FOrientTransformsType::qu2om(FOrientArrayType(q1), om);
      om.toGMatrix(g1);
      // transpose the g matrix so when caxis is multiplied by it
      // it will give the sample direction that the caxis is along
      MatrixMath::Transpose3x3(g1, g1t);
      MatrixMath::Multiply3x3with3x1(g1t, caxis, c1);
      // normalize so that the dot product can be taken below without
      // dividing by the magnitudes (they would be 1)
      MatrixMath::Normalize3x1(c1);
      MatrixMath::Copy3x1(c1, avgCaxes);
      MatrixMath::Multiply3x1withConstant(avgCaxes, m_Volumes[seed]);
    }
  }
  return seed;
}
bool IdentifyLiaisonTunnel::initNetwok()
{
    ObjectIdMap om( dg );
    if( !BuildNetwork( dg, om ) ) return false;
    FilterBlockEdges( dg, om, ef );
    if( !AddVirtualSTNode( dg, om, sn, tn ) ) return false;

    // 关联分支属性数据
    InitEdgeDatas( dg, om, datas );

    return true;
}
Esempio n. 9
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void OrientationMath::MultiplyQuaternionVector(QuatF& inQuat, float* inVec, float* outVec)
{
  float g[3][3];
  float gInv[3][3];

  FOrientArrayType om(9, 0.0f);
  FOrientTransformsType::qu2om(FOrientArrayType(inQuat), om);
  om.toGMatrix(g);

  MatrixMath::Invert3x3(g, gInv);
  MatrixMath::Multiply3x3with3x1(gInv, inVec, outVec);
}
Esempio n. 10
0
int main()
{
    Liste l1=Exemple1();
    Liste l2=Exemple2();
    printf("Liste1 de 7 elements :\n");
    afficherliste(l1);
    printf("Liste2 de 6 elements :\n");
    afficherliste(l2);


    Arbin a1=la(l1);
    Arbin a2=la(l2);
    printf("Affichage de l'arbre1\n");
    afficherArbre(a1);
    printf("Affichage de l'arbre2\n");
    afficherArbre(a2);
    printf("\n");

    Liste l3=al(a1);
    printf("al sur arbre1 :\n");
    afficherliste(l3);

    Arbin u0=union0(a1,a2);
    Arbin u1=union1(a1,a2);

    printf("Affichage de union0 :\n");
    afficherArbre(u0);

    printf("Affichage de union1 :\n");
    afficherArbre(u1);

    printf("Oter le minimum de l'arbre1\n");
    Arbin o=om(a1);
    afficherArbre(o);

    Arbin i=ins(a1,42);
    printf("Insertion de 42 dans l'arbre1\n");
    afficherArbre(i);

    freeListe(l1);
    freeListe(l2);
    freeListe(l3);

    freeArbre(a1);
    freeArbre(a2);
    freeArbre(u0);
    freeArbre(u1);
    freeArbre(o);
    freeArbre(i);


    return 0;
}
Esempio n. 11
0
bool FindWindStation::initNetwok()
{
    ObjectIdMap om( dg );
    if( !BuildNetwork( dg, om ) ) return false;
    if( !AddVirtualSTNode( dg, om, sn, tn ) ) return false;
    FilterBlockEdges( dg, om, ef );

    // 关联分支属性数据
    InitEdgeDatas( dg, om, datas );

    return true;
}
Esempio n. 12
0
TEST_F(ThreeIndexTestGF,Operators)
{
    namespace g=alps::gf;

    for (g::matsubara_index om=g::matsubara_index(0); om<gf.mesh1().extent(); ++om) {
        for (g::momentum_index ii=g::momentum_index(0); ii<gf.mesh2().extent(); ++ii) {
            for (g::index sig=g::index(0); sig<gf.mesh3().extent(); ++sig) {
                std::complex<double> v1(1+om()+ii(), 1+sig());
                std::complex<double> v2=1./v1;
                gf(om,ii,sig)=v1;
                gf2(om,ii,sig)=v2;
            }
        }
    }


    gf_type g_plus=gf+gf2;
    gf_type g_minus=gf-gf2;

    const double tol=1E-8;
                    
    for (g::matsubara_index om=g::matsubara_index(0); om<gf.mesh1().extent(); ++om) {
        for (g::momentum_index ii=g::momentum_index(0); ii<gf.mesh2().extent(); ++ii) {
            for (g::index sig=g::index(0); sig<gf.mesh3().extent(); ++sig) {

                std::complex<double> v1(1+om()+ii(), 1+sig());
                std::complex<double> v2=1./v1;
                
                std::complex<double> r1=v1+v2;
                std::complex<double> r2=v1-v2;
                
                ASSERT_NEAR(r1.real(),g_plus(om,ii,sig).real(),tol);
                ASSERT_NEAR(r1.imag(),g_plus(om,ii,sig).imag(),tol);

                ASSERT_NEAR(r2.real(),g_minus(om,ii,sig).real(),tol);
                ASSERT_NEAR(r2.imag(),g_minus(om,ii,sig).imag(),tol);
            }
        }
    }
}
Esempio n. 13
0
int main(int argc, char ** argv)
{
  ros::init(argc,argv,"object_manager");
  ros::NodeHandle nh;

  ObjectManager om(argc,argv);

  ROS_INFO("Object Manager initialized");
  om.spin();
  ROS_INFO("Done");

  return 0;
}
Esempio n. 14
0
void InputOutputMap_Test::pluginOutputs()
{
    InputOutputMap om(m_doc, 4);

    IOPluginStub* stub = static_cast<IOPluginStub*>
                                (m_doc->ioPluginCache()->plugins().at(0));
    QVERIFY(stub != NULL);

    QStringList ls(om.pluginOutputs(stub->name()));
    QVERIFY(ls == stub->outputs());

    QVERIFY(om.pluginOutputs("Foobar").isEmpty() == true);
}
Esempio n. 15
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
bool CAxisSegmentFeatures::determineGrouping(int64_t referencepoint, int64_t neighborpoint, int32_t gnum)
{
  bool group = false;
  float w = std::numeric_limits<float>::max();
  QuatF q1 = QuaternionMathF::New();
  QuatF q2 = QuaternionMathF::New();
  QuatF* quats = reinterpret_cast<QuatF*>(m_Quats);
  float g1[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } };
  float g2[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } };
  float g1t[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } };
  float g2t[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } };
  float caxis[3] = {0.0f, 0.0f, 1.0f};
  float c1[3] = { 0.0f, 0.0f, 0.0f };
  float c2[3] = { 0.0f, 0.0f, 0.0f };

  if (m_FeatureIds[neighborpoint] == 0 && (m_UseGoodVoxels == false || m_GoodVoxels[neighborpoint] == true))
  {
    QuaternionMathF::Copy(quats[referencepoint], q1);
    QuaternionMathF::Copy(quats[neighborpoint], q2);

    if (m_CellPhases[referencepoint] == m_CellPhases[neighborpoint])
    {
      FOrientArrayType om(9);
      FOrientTransformsType::qu2om(FOrientArrayType(q1), om);
      om.toGMatrix(g1);
      FOrientTransformsType::qu2om(FOrientArrayType(q2), om);
      om.toGMatrix(g2);

      // transpose the g matricies so when caxis is multiplied by it
      // it will give the sample direction that the caxis is along
      MatrixMath::Transpose3x3(g1, g1t);
      MatrixMath::Transpose3x3(g2, g2t);
      MatrixMath::Multiply3x3with3x1(g1t, caxis, c1);
      MatrixMath::Multiply3x3with3x1(g2t, caxis, c2);

      // normalize so that the dot product can be taken below without
      // dividing by the magnitudes (they would be 1)
      MatrixMath::Normalize3x1(c1);
      MatrixMath::Normalize3x1(c2);

      w = ((c1[0] * c2[0]) + (c1[1] * c2[1]) + (c1[2] * c2[2]));
      w = acosf(w);
      if (w <= misoTolerance || (SIMPLib::Constants::k_Pi - w) <= misoTolerance)
      {
        group = true;
        m_FeatureIds[neighborpoint] = gnum;
      }
    }
  }
  return group;
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void FindBasalLoadingFactor::execute()
{
    setErrorCondition(0);
    dataCheck();
    if(getErrorCondition() < 0) {
        return;
    }

    size_t totalFeatures = m_BasalLoadingFactorPtr.lock()->getNumberOfTuples();

    //int ss = 0;
    QuatF q1;
    QuatF* avgQuats = reinterpret_cast<QuatF*>(m_AvgQuats);

    float sampleLoading[3];
    //typedef DataArray<unsigned int> XTalType;

    float w;
    float g1[3][3];
    float g1t[3][3];
    float caxis[3] = {0, 0, 1};
    float c1[3];

    sampleLoading[0] = m_LoadingDirection.x;
    sampleLoading[1] = m_LoadingDirection.y;
    sampleLoading[2] = m_LoadingDirection.z;
    MatrixMath::Normalize3x1(sampleLoading);

    for (size_t i = 1; i < totalFeatures; i++)
    {
        QuaternionMathF::Copy(avgQuats[i], q1);
        FOrientArrayType om(9);
        FOrientTransformsType::qu2om(FOrientArrayType(q1), om);
        om.toGMatrix(g1);
        //transpose the g matricies so when caxis is multiplied by it
        //it will give the sample direction that the caxis is along
        MatrixMath::Transpose3x3(g1, g1t);
        MatrixMath::Multiply3x3with3x1(g1t, caxis, c1);
        //normalize so that the magnitude is 1
        MatrixMath::Normalize3x1(c1);
        if(c1[2] < 0) {
            MatrixMath::Multiply3x1withConstant(c1, -1);
        }
        w = GeometryMath::CosThetaBetweenVectors(c1, sampleLoading);
        w = acos(w);
        w *= SIMPLib::Constants::k_180OverPi;
        m_BasalLoadingFactor[i] = w;
    }

    notifyStatusMessage(getHumanLabel(), "FindBasalLoadingFactor Completed");
}
//------------------------------------------------------------------------------
void CheckDuplicates( const vector< string > & input,
                      const string & infmt,
                      const CWinMaskUtil::CIdSet * ids,
                      const CWinMaskUtil::CIdSet * exclude_ids )
{
    typedef vector< string >::const_iterator input_iterator;

    dup_lookup_table table;
    CRef<CObjectManager> om(CObjectManager::GetInstance());

    for( input_iterator i( input.begin() ); i != input.end(); ++i )
    {
        Uint4 seqnum( 0 );

        for(CWinMaskUtil::CInputBioseq_CI bs_iter(*i, infmt); bs_iter; ++bs_iter)
        {
            CBioseq_Handle bsh = *bs_iter;

            if( CWinMaskUtil::consider( bsh, ids, exclude_ids ) )
            {
                TSeqPos data_len = bsh.GetBioseqLength();
                if( data_len < MIN_SEQ_LENGTH )
                    continue;

                string id;
                sequence::GetId(bsh, sequence::eGetId_Best)
                    .GetSeqId()->GetLabel(&id);
                data_len -= SAMPLE_SKIP;
                tracker track( table, id );

                string index;
                CSeqVector data =
                    bsh.GetSeqVector(CBioseq_Handle::eCoding_Iupac);
                for( TSeqPos i = 0;  i < data_len;  ++i )
                {
                    index.erase();
                    data.GetSeqData(i, i + SAMPLE_LENGTH, index);
                    const dup_lookup_table::sample * sample( table[index] );

                    if( sample != 0 )
                        track( index, seqnum, i, sample->begin(), sample->end() );
                }

                table.add_seq_info( id, data );
                ++seqnum;
            }
        }
    }
}
Esempio n. 18
0
void VCLabel_Test::saveXML()
{
    QLCFixtureDefCache fdc;
    Doc doc(this, fdc);
    OutputMap om(this, 4);
    InputMap im(this, 4);
    MasterTimer mt(this, &om);
    QWidget w;

    VCLabel label(&w, &doc, &om, &im, &mt);
    label.setCaption("Simo Kuassimo");

    QDomDocument xmldoc;
    QDomElement root = xmldoc.createElement("TestRoot");
    xmldoc.appendChild(root);

    QVERIFY(label.saveXML(&xmldoc, &root) == true);

    QDomNode node = root.firstChild();
    QVERIFY(node.nextSibling().isNull() == true);
    QCOMPARE(node.toElement().tagName(), QString("Label"));
    QCOMPARE(node.toElement().attribute("Caption"), QString("Simo Kuassimo"));
    QVERIFY(node.firstChild().isNull() == false);

    int appearance = 0, windowstate = 0;

    node = node.firstChild();
    while (node.isNull() == false)
    {
        QDomElement tag = node.toElement();
        if (tag.tagName() == QString("Appearance"))
        {
            appearance++;
        }
        else if (tag.tagName() == QString("WindowState"))
        {
            windowstate++;
        }
        else
        {
            qDebug() << xmldoc.toString();
            QFAIL("Unexpected tag in XML output!");
        }
        node = node.nextSibling();
    }

    QCOMPARE(appearance, 1);
    QCOMPARE(windowstate, 1);
}
Esempio n. 19
0
void VCLabel_Test::initial()
{
    QLCFixtureDefCache fdc;
    Doc doc(this, fdc);
    OutputMap om(this, 4);
    InputMap im(this, 4);
    MasterTimer mt(this, &om);
    QWidget w;

    VCLabel label(&w, &doc, &om, &im, &mt);
    QCOMPARE(label.objectName(), QString("VCLabel"));
    QCOMPARE(label.frameStyle(), 0);
    QCOMPARE(label.caption(), tr("Label"));
    QCOMPARE(label.size(), QSize(100, 30));
}
Esempio n. 20
0
void Window::_setupObjectManager()
{
    if( !glewGetContext( ))
        return;

    _releaseObjectManager();

    const Window* sharedWindow = getSharedContextWindow();
    if( sharedWindow && sharedWindow != this )
        _objectManager = sharedWindow->_objectManager;
    else
    {
        util::ObjectManager om( glewGetContext( ));
        _objectManager = om;
    }
}
Esempio n. 21
0
        void generate(size_t start, size_t end) const
        {
          float g[3][3];
          float gTranpose[3][3];
          float direction[3] = {0.0, 0.0, 0.0};

          // Geneate all the Coordinates
          for(size_t i = start; i < end; ++i)
          {
            FOrientArrayType eu(m_Eulers->getPointer(i * 3), 3);
            FOrientArrayType om(9, 0.0);
            OrientationTransforms<FOrientArrayType, float>::eu2om(eu, om);
            om.toGMatrix(g);
            MatrixMath::Transpose3x3(g, gTranpose);

            // -----------------------------------------------------------------------------
            // 001 Family
            direction[0] = 0.0;
            direction[1] = 0.0;
            direction[2] = 1.0;
            MatrixMath::Multiply3x3with3x1(gTranpose, direction, m_xyz001->getPointer(i * 6));
            MatrixMath::Copy3x1(m_xyz001->getPointer(i * 6), m_xyz001->getPointer(i * 6 + 3));
            MatrixMath::Multiply3x1withConstant(m_xyz001->getPointer(i * 6 + 3), -1);


            // -----------------------------------------------------------------------------
            // 011 Family
            direction[0] = 1.0;
            direction[1] = 0.0;
            direction[2] = 0.0;
            MatrixMath::Multiply3x3with3x1(gTranpose, direction, m_xyz011->getPointer(i * 6));
            MatrixMath::Copy3x1(m_xyz011->getPointer(i * 6), m_xyz011->getPointer(i * 6 + 3));
            MatrixMath::Multiply3x1withConstant(m_xyz011->getPointer(i * 6 + 3), -1);


            // -----------------------------------------------------------------------------
            // 111 Family
            direction[0] = 0.0;
            direction[1] = 1.0;
            direction[2] = 0;
            MatrixMath::Multiply3x3with3x1(gTranpose, direction, m_xyz111->getPointer(i * 6));
            MatrixMath::Copy3x1(m_xyz111->getPointer(i * 6), m_xyz111->getPointer(i * 6 + 3));
            MatrixMath::Multiply3x1withConstant(m_xyz111->getPointer(i * 6 + 3), -1);
          }

        }
Esempio n. 22
0
    void checkPoints(size_t start, size_t end) const
    {
      float radius = 0.0f;
      FloatArrayType::Pointer llPtr = FloatArrayType::CreateArray(3, "_INTERNAL_USE_ONLY_Lower_Left");
      FloatArrayType::Pointer urPtr = FloatArrayType::CreateArray(3, "_INTERNAL_USE_ONLY_Upper_Right");
      FloatArrayType::Pointer ll_rotPtr = FloatArrayType::CreateArray(3, "_INTERNAL_USE_ONLY_Lower_Left_Rotated");
      FloatArrayType::Pointer ur_rotPtr = FloatArrayType::CreateArray(3, "_INTERNAL_USE_ONLY_Upper_Right_Rotated");
      float* ll = llPtr->getPointer(0);
      float* ur = urPtr->getPointer(0);
      float* ll_rot = ll_rotPtr->getPointer(0);
      float* ur_rot = ur_rotPtr->getPointer(0);
      float* point = NULL;
      char code = ' ';
      float g[3][3] = { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } };

      for (size_t iter = start; iter < end; iter++)
      {
        Int32Int32DynamicListArray::ElementList& faceIds = m_FaceIds->getElementList(iter);

        FOrientArrayType om(9, 0.0);
        FOrientTransformsType::qu2om(FOrientArrayType(m_AvgQuats[iter]), om);
        om.toGMatrix(g);

        // find bounding box for current feature
        GeometryMath::FindBoundingBoxOfFaces(m_Faces, faceIds, ll, ur);
        GeometryMath::FindBoundingBoxOfRotatedFaces(m_Faces, faceIds, g, ll_rot, ur_rot);
        GeometryMath::FindDistanceBetweenPoints(ll, ur, radius);

        generatePoints(iter, m_Points, m_InFeature, m_AvgQuats, m_LatticeConstants, m_Basis, ll_rot, ur_rot);

        // check points in vertex array to see if they are in the bounding box of the feature
        int64_t numPoints = m_Points[iter]->getNumberOfVertices();
        VertexGeom::Pointer vertArray = m_Points[iter];
        BoolArrayType::Pointer boolArray = m_InFeature[iter];
        for (int64_t i = 0; i < numPoints; i++)
        {
          point = vertArray->getVertexPointer(i);
          if (boolArray->getValue(i) == false)
          {
            code = GeometryMath::PointInPolyhedron(m_Faces, faceIds, m_FaceBBs, point, ll, ur, radius);
            if (code == 'i' || code == 'V' || code == 'E' || code == 'F') { m_InFeature[start]->setValue(i, true); }
          }
        }
      }
    }
Esempio n. 23
0
  ::std::ostream&
  operator<< (::std::ostream& o, const Navigation& i)
  {
    {
      ::xsd::cxx::tree::std_ostream_map< char >& om (
        ::xsd::cxx::tree::std_ostream_map_instance< 0, char > ());

      for (Navigation::EventConstIterator
           b (i.event ().begin ()), e (i.event ().end ());
           b != e; ++b)
      {
        o << ::std::endl << "event: ";
        om.insert (o, *b);
      }
    }

    return o;
  }
Esempio n. 24
0
void VCLabel_Test::loadXML()
{
    QLCFixtureDefCache fdc;
    Doc doc(this, fdc);
    OutputMap om(this, 4);
    InputMap im(this, 4);
    MasterTimer mt(this, &om);
    QWidget w;

    QDomDocument xmldoc;
    QDomElement root = xmldoc.createElement("Label");
    xmldoc.appendChild(root);

    QDomElement wstate = xmldoc.createElement("WindowState");
    wstate.setAttribute("Width", "42");
    wstate.setAttribute("Height", "69");
    wstate.setAttribute("X", "3");
    wstate.setAttribute("Y", "4");
    wstate.setAttribute("Visible", "True");
    root.appendChild(wstate);

    QDomElement appearance = xmldoc.createElement("Appearance");
    QFont f(w.font());
    f.setPointSize(f.pointSize() + 3);
    QDomElement font = xmldoc.createElement("Font");
    QDomText fontText = xmldoc.createTextNode(f.toString());
    font.appendChild(fontText);
    appearance.appendChild(font);
    root.appendChild(appearance);

    QDomElement foobar = xmldoc.createElement("Foobar");
    root.appendChild(foobar);

    VCLabel label(&w, &doc, &om, &im, &mt);
    QVERIFY(label.loadXML(&root) == true);
    QCOMPARE(label.geometry().width(), 42);
    QCOMPARE(label.geometry().height(), 69);
    QCOMPARE(label.geometry().x(), 3);
    QCOMPARE(label.geometry().y(), 4);
    QCOMPARE(label.font(), f);

    root.setTagName("Lable");
    QVERIFY(label.loadXML(&root) == false);
}
Esempio n. 25
0
void VCLabel_Test::paintEvent()
{
    QLCFixtureDefCache fdc;
    Doc doc(this, fdc);
    OutputMap om(this, 4);
    InputMap im(this, 4);
    MasterTimer mt(this, &om);
    QMdiArea w;

    QPaintEvent ev(QRect(0, 0, 5, 5));

    // Checking the result of a paint event would have to compare individual pixels, which
    // I'm not gonna do. Just call all branches to try to find any crashes and that's it...
    VCLabel label(&w, &doc, &om, &im, &mt);
    label.paintEvent(&ev);

    label.m_mode = Doc::Operate;
    label.paintEvent(&ev);
}
Esempio n. 26
0
void InputOutputMap_Test::outputPluginStatus()
{
    InputOutputMap om(m_doc, 4);

    QVERIFY(om.outputPluginStatus("Foo", QLCIOPlugin::invalidLine()).contains("Nothing selected"));
    QVERIFY(om.outputPluginStatus("Bar", 0).contains("Nothing selected"));
    QVERIFY(om.outputPluginStatus("Baz", 1).contains("Nothing selected"));
    QVERIFY(om.outputPluginStatus("Xyzzy", 2).contains("Nothing selected"));
    QVERIFY(om.outputPluginStatus("AYBABTU", 3).contains("Nothing selected"));

    IOPluginStub* stub = static_cast<IOPluginStub*>
                                (m_doc->ioPluginCache()->plugins().at(0));
    QVERIFY(stub != NULL);

    QVERIFY(om.outputPluginStatus(stub->name(), 4) == stub->outputInfo(QLCIOPlugin::invalidLine()));
    QVERIFY(om.outputPluginStatus(stub->name(), 0) == stub->outputInfo(0));
    QVERIFY(om.outputPluginStatus(stub->name(), 1) == stub->outputInfo(1));
    QVERIFY(om.outputPluginStatus(stub->name(), 2) == stub->outputInfo(2));
}
Esempio n. 27
0
void
StaticPersistence<D, CT, OT, E, Cmp>::
initialize(const Filtration& filtration)
{ 
    order_.assign(filtration.size(), OrderElement());
    rLog(rlPersistence, "Initializing persistence");

    OffsetMap<typename Filtration::Index, iterator>                         om(filtration.begin(), begin());
    for (typename Filtration::Index cur = filtration.begin(); cur != filtration.end(); ++cur)
    {
        Cycle z;   
        BOOST_FOREACH(const typename Filtration::Simplex& s, std::make_pair(cur->boundary_begin(), cur->boundary_end()))
            z.push_back(index(om[filtration.find(s)]));
        z.sort(ocmp_); 

        iterator ocur = om[cur];
        swap_cycle(ocur, z);
        set_pair(ocur,   ocur);
    }
}
Esempio n. 28
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void OrientationMath::ChangeAxisReferenceFrame(QuatF& q, float& n1, float& n2, float& n3)
{
  float g[3][3];
  float n[3];
  float nNew[3];

  n[0] = n1;
  n[1] = n2;
  n[2] = n3;

  FOrientArrayType om(9, 0.0f);
  FOrientTransformsType::qu2om(FOrientArrayType(q), om);
  om.toGMatrix(g);

  MatrixMath::Multiply3x3with3x1(g, n, nNew);
  MatrixMath::Normalize3x1(nNew);
  n1 = nNew[0];
  n2 = nNew[1];
  n3 = nNew[2];
}
Esempio n. 29
0
void VCLabel_Test::copy()
{
    QLCFixtureDefCache fdc;
    Doc doc(this, fdc);
    OutputMap om(this, 4);
    InputMap im(this, 4);
    MasterTimer mt(this, &om);
    QWidget w;

    VCFrame parent(&w, &doc, &om, &im, &mt);
    VCLabel label(&parent, &doc, &om, &im, &mt);
    label.setCaption("Foobar");
    VCLabel* label2 = qobject_cast<VCLabel*> (label.createCopy(&parent));
    QVERIFY(label2 != NULL && label2 != &label);
    QCOMPARE(label2->objectName(), QString("VCLabel"));
    QCOMPARE(label2->parentWidget(), &parent);
    QCOMPARE(label2->caption(), QString("Foobar"));

    QVERIFY(label.copyFrom(NULL) == false);
}
/**\internal
 **\brief Get a FASTA formatted id string (the first available) from the 
 **       CSeq_entry structure.
 **
 **\param entry sequence description structure
 **\return the first id string corresponding to entry
 **/
static const string GetIdString( const CSeq_entry & entry )
{
    CRef<CObjectManager> om(CObjectManager::GetInstance());
    const CBioseq & seq = entry.GetSeq();
    CRef<CScope> scope(new CScope(*om));
    CSeq_entry_Handle seh = scope->AddTopLevelSeqEntry( 
        const_cast< CSeq_entry & >( entry ) );
    return CWinMaskSeqTitle::GetId( seh, seq );
/*
    list< CRef< CSeq_id > > idlist = seq.GetId();

    if( idlist.empty() ) 
        return "???";
    else
    {
        CNcbiOstrstream os;
        (*idlist.begin())->WriteAsFasta( os );
        return CNcbiOstrstreamToString(os);
    }
*/
}