If by “C major,” you are assuming the key of C, with, as you explained in a comment, no alterations and no accidentals, and using the note “D” as a reference point, and if you are assuming a triad to mean only the adjacent diatonic intervals of 3rds (based on your graphic), then yes, what you have built is accurate. It is pretty fundamental to music theory.
Of course, this applies to any note in the scale, not just D. In C major, start on C, and you can have C be the root (C major), the third (A minor), or the fifth (F major); go to D, and the same applies; go to E, and the same applies; etc.
Your question more particularly seems to assume the constraint that the melody be part of the triad itself or be a note that is in common with a note in the triad. This need not be the case; indeed, it often is not the case. Melodies can be tricky, fluid things when you are considering harmonization.
Take the well-known “Auld Lang Syne,” for instance:
LilyBin link, with MIDI audio
In this very basic harmonization, even in the first measure, we encounter a melody note that does not “fit” into the triad of F major. In almost every measure, there is a melody note that does not “fit” into the triad that is harmonized with it.
On the other hand, if you harmonized every note in its own triad according to the rules in your question, it might arguably sound worse:
LilyBin link, with MIDI audio
The combination of melody notes that are part of the triad and that are not part of the triad is often what provides musical interest.
This is to say nothing, of course, of extending the harmony beyond triads—suspensions, extensions, and borrowed, oh my! But, given the constraints you provided in your question, yes, notes can be harmonized with any of the three notes in a diatonic triad of which that note is a part—but when harmonizing a melody, I think it is often advisable to know how best to produce good music. To only look for triads that “fit” the melody in the way you describe seems like an inadvisable course to stay on, but it is a good starting point.