lundi 24 mai 2021

shared_ptr in c++, getting points to faces

I have the following class for points:

class MyPoint
{
    public:
    
        // Constructor
        MyPoint(double, double, double);

        // Destructor
        virtual ~MyPoint(){};

    protected:

    private:
        double x;
        double y;
        double z;

};

I would like to create a vector of myPoints to store some data:

vector <MyPoint> vectorOfPoints

for (int i = 0; i < 10 ; i++)
{
    vectorOfPoints.push_back(MyPoint(1,2,3));
}

And I would like to create a class called myFaces to store the address of the points that make up a face.

e.g.,

Face A is built with vectorOfPoints[0], vectorOfPoints[2], vectorOfPoints[5] and vectorOfPoints[6].

How can I pass a vector with the addresses of the above entries to the class myFace?

class myFace
{
    public:

        // Constructor  
        myFace(int, vector<std::shared_ptr<Point> > );

        // Destructor
        virtual  ~myFace(){};
       
         
    protected:

    private:
        int nPointsInFace_;
        vector<std::shared_ptr<Point> > refToPointsThatMakeUpThisFace_;
  
};

Would really appreciate the help!

Aucun commentaire:

Enregistrer un commentaire