こんにちは、std::vector<> のコンストラクターが out_of_range 例外をスローしているという奇妙な問題があります。例外は次のようになります。
First-chance exception at 0x000007fefde09e5d in 3dsmax.exe: Microsoft C++ exception: std::out_of_range at memory location 0x6726ee40..
とにかくあまり役に立ちません。デバッガーでは、コードは次のようになります。
std::vector<Point3> points;
std::vector<Point3> normals;
例外は2行目から来ています。これらは 2 つのローカル変数であり、メンバー関数本体にあり、複数回呼び出されたことを意味します。これら 2 つのコンストラクターが最初に呼び出されたときは例外は発生しませんが、2 番目の線 (法線) が 2 回目にヒットしたときに常にスローされます。「Point3」クラスは、次のように 3dsmax SDK で定義されています。
class GEOMEXPORT Point3: public MaxHeapOperators {
public:
float x,y,z;
// Constructors
/*! \remarks Constructor. No initialization is performed. */
Point3() { /* NO INIT */ }
/*! \remarks Constructor. x, y, and z are initialized to the values specified. */
Point3(float X, float Y, float Z) {
x = X; y = Y; z = Z;
}
/*! \remarks Constructor. x, y, and z are initialized to the specified values (cast as floats). */
Point3(double X, double Y, double Z) {
x = (float)X; y = (float)Y; z = (float)Z;
}
/*! \remarks Constructor. x, y, and z are initialized to the specified values (cast as floats). */
Point3(int X, int Y, int Z) {
x = (float)X; y = (float)Y; z = (float)Z;
}
/*! \remarks Constructor. x, y, and z are initialized to the specified Point3. */
Point3(const Point3& a) {
x = a.x; y = a.y; z = a.z;
}
このクラスは、3ds max SDK の Point3.h にあります。内部には3つのフロートしかなく、さまざまなタイプのコンストラクターが十分にあるようです。このクラスに問題があるなんて信じられない。
Windows 7 で VisualStudio 2008 を使用しています。この問題を解決する方法はありますか? ありがとう。
更新: はい、これは初回例外ですが、STL では処理されず、直接ポップアップしてアプリケーションをクラッシュさせます。(そして、そのスコープをtry-catchでワープすると、自分のコードでこの例外をキャッチできます)
更新: 2 つのローカル変数を (new を使用して) スタックからヒープに移動しようとしましたが、問題は解決しませんでした。