Пример #1
0
void Convex::FacetToSegmentsGorizon(FacetList *FL, SegmentList *SL)
{
    Facet       *pF;
    Segment     S;
    SegmentList SN;

    if ( FL->GetFirst(&pF) )
    {
        // з кожної грані створюємо три ребра
        do {
            S.Init(pF->A, pF->B);
            SN.Add(S);
            S.Init(pF->A, pF->C);
            SN.Add(S);
            S.Init(pF->C, pF->B);
            SN.Add(S);
        } while (FL->GetNext(&pF));
   
        // В список ребер горизонту включаємо лише зовнішні ребра видимої області
        while(!SN.IsEmpty())
        {
            SN.Remove(&S);
            if (SN.FindAndRemoveAll(S)==0)
            {
                SL->Add(S);

                #ifdef CONVEX_DEBUG
                    printf( "Add to horizon : ");
                    S.PrintPoints();
                #endif            
            };
        };
    
    };
}
ISegment*           URLType::ToSegment      (const std::vector<IBaseUrl *>& baseurls) const
{
    Segment *seg = new Segment();
    
    if(seg->Init(baseurls, this->sourceURL, this->range, this->type))
        return seg;

    delete(seg);

    return NULL;
}
ISegment*           BaseUrl::ToMediaSegment     (const std::vector<IBaseUrl *>& baseurls) const
{
    Segment *seg = new Segment();

    if(seg->Init(baseurls, this->url, this->byteRange, dash::metrics::MediaSegment))
        return seg;

    delete(seg);

    return NULL;
}
Пример #4
0
void Convex::DelVertexDoubles(PointList *PL)
{
    PointList PP;
    Point P, L;
    Segment S;
    SegmentList SN;

    if ( PL->GetFirst(&P) )
    {
        do {
            PP.Add(P);
        } while (PL->GetNext(&P));
    };
    
    if ( PL->GetFirst(&L) )
    {
        do {
            if ( PP.GetFirst(&P) )
            {
                do {
                    S.Init(P, L); 
                    SN.Add(S);
                } while (PP.GetNext(&P));
            };  
        } while (PL->GetNext(&L));
    }; 

    if ( PL->GetFirst(&P) )
    {
        do {
            if ( SN.GetFirst(&S) )
            {
                do {
                    if (S.Into(P))
                        PL->FindAndRemoveAll(P);
                } while (SN.GetNext(&S));
            };  
        } while (PL->GetNext(&P));
    };
}
Пример #5
0
int Convex::CreateSimplex(FacetList* HullFaces, PointList *AllPoints)
{
    Point   PCurr, PCurr2, PMinX, PMinY, PMinZ, PMaxX, PMaxY, PMaxZ;
    Segment S;
    Facet   F, *pF;
    int     go, go2;

    AllPoints->GetFirst(&PCurr);
    PMinX.Init(PCurr);    PMinY.Init(PCurr);    PMinZ.Init(PCurr);
    PMaxX.Init(PCurr);    PMaxY.Init(PCurr);    PMaxZ.Init(PCurr);

    while( AllPoints->GetNext(&PCurr) )            // 1) find the minimum and maximum point to each direction
    {
        if (PCurr.GetX()<PMinX.GetX())
            PMinX.Init(PCurr);
        if (PCurr.GetY()<PMinY.GetY())
            PMinY.Init(PCurr);
        if (PCurr.GetZ()<PMinZ.GetZ())
            PMinZ.Init(PCurr);
        if (PCurr.GetX()>PMaxX.GetX())
            PMaxX.Init(PCurr);
        if (PCurr.GetY()>PMaxY.GetY())
            PMaxY.Init(PCurr);
        if (PCurr.GetZ()>PMaxZ.GetZ())
            PMaxZ.Init(PCurr);
    };

    if ( PMinX.IsMatch(PMaxX) || PMinY.IsMatch(PMaxY) || PMinZ.IsMatch(PMaxZ) )
    {
        printf( "Points are coplanars !\n" );
        return 0;                                   // 2) all points are coplanars
    };

    S.Init(PMaxX, PMinX);                           // 3) check to colinear
    AllPoints->GetFirst(&PCurr);
    go = go2 = 1;
    while ( go & go2 )
    {
        if (S.Square(PCurr)>0)
            go = 0;
        else
            go2 = AllPoints->GetNext(&PCurr);
    }
    if (go) {
        printf( "Points are colinears !\n" );
        return 0;   // all points are colinears
    };
                                                    
    F.Init(PMaxX, PMinX, PCurr);                     // 4) check to coplanar
    AllPoints->GetFirst(&PCurr2);
    go = go2 = 1;
    while ( go && go2 )
    {
        if (F.DistanceToPoint(PCurr2)>0)
            go = 0;
        else
            go2 = AllPoints->GetNext(&PCurr2);
    }
    if (go)
    {
        printf( "Points are coplanars !!\n" );
        return 0;                                   // all points are coplanar
    };
/*
    AllPoints->GetFirst(&PCurr);
    AllPoints->GetNext(&PCurr2);
    AllPoints->GetNext(&PMaxX);
    AllPoints->GetNext(&PMinX);
*/
    // Now we have four points : PMaxX, PMinX, PCurr, PCurr2
    pF = new Facet; 
    pF->CreateOrientatedFace( PCurr, PCurr2, PMaxX, PMinX );
    HullFaces->Add( pF );
    pF = new Facet; 
    pF->CreateOrientatedFace( PMinX, PCurr, PCurr2, PMaxX );
    HullFaces->Add( pF );
    pF = new Facet; 
    pF->CreateOrientatedFace( PMaxX, PMinX, PCurr, PCurr2 );
    HullFaces->Add( pF );
    pF = new Facet; 
    pF->CreateOrientatedFace( PMaxX, PMinX, PCurr2, PCurr );
    HullFaces->Add( pF );

    AllPoints->FindAndRemoveAll( PMinX );
    AllPoints->FindAndRemoveAll( PMaxX );
    AllPoints->FindAndRemoveAll( PCurr2 );
    AllPoints->FindAndRemoveAll( PCurr );

    insidePoint.Init(   (PMinX.GetX()+PMaxX.GetX()+PCurr2.GetX()+PCurr.GetX())/4, 
                        (PMinX.GetY()+PMaxX.GetY()+PCurr2.GetY()+PCurr.GetY())/4, 
                        (PMinX.GetZ()+PMaxX.GetZ()+PCurr2.GetZ()+PCurr.GetZ())/4 );

    return 1;
};