Cannot find it in MSDN...
I want to get the right-click context menu where you click on the desktop
Code:
---------
winClass.lpszMenuName = LoadMenu(...);
---------
↧
Could anyone please tell me what the name of the system context menu is?
↧
Visual Studio help
Hello, sorry if this isn't the right topic but I need some help, I need a script, the script to download from a website a file and send it to a directory that I choose, something like this:Attachment 34897 (http://forums.codeguru.com/attachment.php?attachmentid=34897)
Sorry, I'm newbie, and I need some help, hope someone can help me, Thanks. <3
↧
↧
Detecting if a COM exe (out of proc) is alive and auto resart if dead?
Hi folks, we have a out of proc COM exe that is used by all Office applications and more, we want to detect in these callers, if the exe is running (crash situation) and automatically start the exe if it is dead.
Any thoughts?
Thanks
↧
Using Macro value in VC++ header file
Hi i have 2 header files in my project.
*Compile.h* has the following contents
#define Testcase 1
*Config.h* has the folowing contents
#define iTimer 4
#define iCounter 5
I want to use the macro Testcase in my Config.h file like below
*#ifdef Testcase*
#undef iTimer
#define iTimer 5
#undef iCounter
#define iCounter 4
*#endif*
Will this change work? *I just want to swap the values of iTimer and iCounter if the macro Testcase is defined in my code.* For some tests i *comment* the macro in the config.h file. Please help me in this.
↧
[RESOLVED] Using Macro value in VC++ header file
Hi i have 2 header files in my project.
*Compile.h* has the following contents
#define Testcase 1
*Config.h* has the folowing contents
#define iTimer 4
#define iCounter 5
I want to use the macro Testcase in my Config.h file like below
*#ifdef Testcase*
#undef iTimer
#define iTimer 5
#undef iCounter
#define iCounter 4
*#endif*
Will this change work? *I just want to swap the values of iTimer and iCounter if the macro Testcase is defined in my code.* For some tests i *comment* the macro in the config.h file. Please help me in this.
↧
↧
join to piece of a program
hello there . I have a program that is not displaying any result . I would appreciate your help . SO this is my code below
to be clear I should do this :
a) Calculate the integer part of the quotient when integer a is divided by integer b.
b) Calculate the integer remainder when integer a is divided by integer b.
c) Use the program pieces developed in (a) and (b) to write a function that inputs an
integer between 1 and 32767 and prints it as a series of digits, each pair of which is
separated by two spaces. For example, the integer 4562 should print as follows:
4 5 6 2
this is my code where I should join part a and part b to split digits :
Code:
---------
#include < iostream >
using namespace std;
int quotient ( int a , int b ) // first piece.
{
return a / b ;
}
int remainder ( int a, int b ) // second piece.
{
return a % b;
}
void split ( int a ) // problem probably with joining them
{
int div = 10000; // since the max number of digits is 5.
int sep;
bool lastdigit = false; // it will stop on last non zero digit to the left.
while ( div != 1 )
{
sep = quotient( a , div );
if ( lastdigit == false && sep == 0 ) // if 0 do nothing.
{
}
else
{
lastdigit = true;
cout << sep << " ";
}
a = remainder( a , div );
div = div / 10;
}
cout << a << endl;
}
int main ()
{
int x;
cout << "\nThis program will split a number of your choice between the following range : \n " << endl;
do {
cout << "\nPlease enter an interger number X ( 1 < X < 32767 ) :\n " << endl;
cin >> x;
}while ( x < 1 && cout << "\nSorry wrong input!\n" || x > 32767 && cout << "\nSorry wrong input!\n" );
void split ( int x );
cout << "\n";
system ( "pause" );
return 0;
}
---------
thanks for your help ...
↧
[RESOLVED] join to piece of a program
hello there . I have a program that is not displaying any result . I would appreciate your help . SO this is my code below
to be clear I should do this :
a) Calculate the integer part of the quotient when integer a is divided by integer b.
b) Calculate the integer remainder when integer a is divided by integer b.
c) Use the program pieces developed in (a) and (b) to write a function that inputs an
integer between 1 and 32767 and prints it as a series of digits, each pair of which is
separated by two spaces. For example, the integer 4562 should print as follows:
4 5 6 2
this is my code where I should join part a and part b to split digits :
thanks for your help ...
to be clear I should do this :
a) Calculate the integer part of the quotient when integer a is divided by integer b.
b) Calculate the integer remainder when integer a is divided by integer b.
c) Use the program pieces developed in (a) and (b) to write a function that inputs an
integer between 1 and 32767 and prints it as a series of digits, each pair of which is
separated by two spaces. For example, the integer 4562 should print as follows:
4 5 6 2
this is my code where I should join part a and part b to split digits :
Code:
#include < iostream >
using namespace std;
int quotient ( int a , int b ) // first piece.
{
return a / b ;
}
int remainder ( int a, int b ) // second piece.
{
return a % b;
}
void split ( int a ) // problem probably with joining them
{
int div = 10000; // since the max number of digits is 5.
int sep;
bool lastdigit = false; // it will stop on last non zero digit to the left.
while ( div != 1 )
{
sep = quotient( a , div );
if ( lastdigit == false && sep == 0 ) // if 0 do nothing.
{
}
else
{
lastdigit = true;
cout << sep << " ";
}
a = remainder( a , div );
div = div / 10;
}
cout << a << endl;
}
int main ()
{
int x;
cout << "\nThis program will split a number of your choice between the following range : \n " << endl;
do {
cout << "\nPlease enter an interger number X ( 1 < X < 32767 ) :\n " << endl;
cin >> x;
}while ( x < 1 && cout << "\nSorry wrong input!\n" || x > 32767 && cout << "\nSorry wrong input!\n" );
void split ( int x );
cout << "\n";
system ( "pause" );
return 0;
}
thanks for your help ...
↧
[RESOLVED] Issue with stream extraction
So if I want to validate a single character input I was trying something like that
I want the user to enter a single character only if not it will tell him to reenter you see ?
Code:
char ch;
do {
cout << "\nPlease enter a single character :\n " << endl;
getline ( cin ,ch );
}while ( ch.length != 1 && cout <<" Wrong input ! " );
I want the user to enter a single character only if not it will tell him to reenter you see ?
↧
Set the ChildDialog Window Focus when i go to another application and come here
Hi Team,
please help me on how to set the focus for the Child Dialog Window
I have CDialog. In this i have couple of Tool bar [ File, Edit, Options, Tool,help]
Out of all these option,I clicked on Tool->Display panel.
Now Display Panel small Dialog pops-up.In this window there are static controls are available.
(Reset,Draw buttons). when I hover the cursor on the Reset button "Tool-tip" should display.It's happening.
In the "Display panel" dialog i have written the code SetActiveWindow function to activate the dialog. Now if i minimize and maximize the window,
the main Dialog is visible.But the "Display Panel" is hidden. This is where i am facing the problem. In this case, SetActiveWindow function is applied to the parent window.But i need to set child window as active window.
Regards,
Senthil
please help me on how to set the focus for the Child Dialog Window
I have CDialog. In this i have couple of Tool bar [ File, Edit, Options, Tool,help]
Out of all these option,I clicked on Tool->Display panel.
Now Display Panel small Dialog pops-up.In this window there are static controls are available.
(Reset,Draw buttons). when I hover the cursor on the Reset button "Tool-tip" should display.It's happening.
In the "Display panel" dialog i have written the code SetActiveWindow function to activate the dialog. Now if i minimize and maximize the window,
the main Dialog is visible.But the "Display Panel" is hidden. This is where i am facing the problem. In this case, SetActiveWindow function is applied to the parent window.But i need to set child window as active window.
Regards,
Senthil
↧
↧
Issue with code
I have a tiny prob with this piece of code . I want the program to compute fees for each car separately store it somewhere and then display the table will all result . the problem is that I don't now were to put the charges each time then display all of them together . the prog is displaying on each loop how can I modify that to work as I expected .
thanks
Code:
double calculate_charges ( double h ) {
if ( h == 24 ) {
return 10.00;
}
else if ( h <= 3 ) {
return 2.00;
}
else {
double chg = 3 + (( h - 3 ) *0.50);
return chg;
}
}
int main () {
int x; double hours;
do {
cout << "Please enter the number of cars :\n" << endl;
cin >> x;
}while ( x <= 0 && cout <<"Wrong choice!" );
for ( int i = 1 ; i <= x ; ++i ) {
do {
cout << "\nPlease enter the number of hours parked by car " << i << " today :\n" << endl;
cin >> hours;
}while ( hours > 24 && cout << "Wrong choicde! " );
for ( int j = 1 ; j <= i ; j++ )
cout <<"\n"; added this in order to separate them so you can see what the problem try to compute it like this
cout << "Car\t\tHours\t\tCharge\n"
<< "----\t\t------\t\t-------" << endl
<< i <<"\t\t"<< hours << "\t\t" << calculate_charges ( hours ); // this function is out the main .
}
system ( " pause " );
return 0;
}
↧
join to piece of a program 2
SO this is my code . I wanted thee program to take a certai number of car from user and display the result in a table but its actually not please run it to see what I mean
Code:
double calculate_charges ( double h ) {
if ( h == 24 ) {
return 10.00;
}
else if ( h <= 3 ) {
return 2.00;
}
else {
double chg = 3 + (( h - 3 ) *0.50);
return chg;
}
}
int main ()
{
int c; double hours;
do {
cout << "\nPlease enter the number of cars :\n" << endl;
cin >> c;
}while ( c <= 0 && cout <<"Wrong choicet!" );
for ( int i = 1 ; i <= c ; ++i ) {
do {
cout << "\nPlease enter the number of hours by car " << i << " today :\n" << endl;
cin >> hours;
}while ( hours > 24 && cout << "Wrong choice!" );
for ( int j = 1 ; j <= i ; j++ )
cout<<"\n"; // added this in order to separate so you can see what is wrong clearly
cout << "Car\t\tHours\t\tCharge\n"
<< "----\t\t------\t\t-------" << endl
<< i <<"\t\t"<< hours << "\t\t" << calculate_charges ( hours );
system ( "pause" );
return 0;
}
↧
WORD AUTOMATION C++ (VS6.0). How I can overwrite on background picture?
Hello, I use Word Automation in C++ (VS6.0).
I load a picture (file *.jpg) in my document. This picture is the background.
How I can write on this picture?
Thanks for code in C language or links that solve my problem.
Bye
:wave:
I load a picture (file *.jpg) in my document. This picture is the background.
How I can write on this picture?
Thanks for code in C language or links that solve my problem.
Bye
:wave:
↧
hello, guys im newbie help me :(
Code:
---------
#include
int radius, area;
main()
{
printf( "Enter radius (i.e. 10):" );
scanf("%d", &radius);
area = (int)(3.14159*radius*radius);
printf("\n\nArea=%d\n", area);
return 0;
}
---------
this is my code
what is wrong with me ?
there are c4430 error..
help~
↧
↧
Support_for_Coding_a_Picture_Viewer_(like_Flip-Flop)
Hello,
I need support regarding the following code. There are some problems which do not work properly.
Thank you in advance,
The Task is :
Please prepare a program which shows for a picture presentation. It should be loaded two different pictures, which
should be shown each for five seconds (like a flip-flop).
After start the program this should be work automatically. The pictures could be directly given which your own path.
Additionally the program should be able with a "end" button.
What doenst work properly :
I had tried to to load the two pictures and and let them show for each of 5 sec. with a Timer.
This doesnt work directly as it should be and I have to use the QMessageBox Button each time and push it.
I think there is a logical failure or failures in it.
The "bildbetrachter.cpp" file :
------------------------------------------------------
//die Header-Dateien einbinden
#include "bildbetrachter.h"
#include
#include
#include
#include
#include
#include
//der Konstruktor
Bildbetrachter::Bildbetrachter()
{
//die Größe und den Titel setzen
resize(380,400);
setWindowTitle("Bildbetrachter");
//den Timer für Bild1 erzeugen
timerZeit = new QTimer(); //Bild1
//das Signal timeout des Timers mit dem Slot verbinden
QObject::connect(timerZeit, SIGNAL(timeout()), this, SLOT(timerZeitSlot())); //Bild1
//den Timer für Bild2 erzeugen
timerDatum = new QTimer(); //Bild2
QObject::connect(timerDatum, SIGNAL(timeout()), this, SLOT(timerDatumSlot()));//Bild2
bildLabel1 = new QLabel(this);
bildLabel1->setGeometry(10, 10, 10, 10);
bildLabel2 = new QLabel(this);
bildLabel2->setGeometry(10, 10, 10, 10);
//der Programmstart-Button um die Bilder jeweils für 5 Sek.anzuzeigen
startButton = new QPushButton(this);
startButton->setGeometry(250, 10, 100, 30);
startButton->setText("Programmstart");
QObject::connect(startButton, SIGNAL(clicked()), this, SLOT(timerZeitSlot()));
//der Beenden-Button
beendenButton = new QPushButton(this);
beendenButton->setGeometry(250, 45, 100, 30);
beendenButton->setText("Beenden");
QObject::connect(beendenButton, SIGNAL(clicked()), this, SLOT(close()));
}
//die Methode für die Anzeige - Bild1
void Bildbetrachter::timerZeitSlot() //Bild1
{
timerZeit->start(5000);
//das Bild1 anzeigen
zeigeBild1();
}
//die Methode für den Timer des Datums
void Bildbetrachter::timerDatumSlot()
{
//die Methode stopDatum() aufrufen
stopDatum();
}
void Bildbetrachter::zeigeBild1()
{
QPixmap bild1;
if (timerZeit->isActive()==false)
return;
else
{
bild1.load("C:/Qt/Bilder/1.jpg");
//die Größe wird dabei an die Breite 200 angepasst
bild1 = bild1.scaledToWidth(200);
//im Label anzeigen
bildLabel1->setPixmap(bild1);
//die Größe des Labels an die Größe des Bildes anpassen
bildLabel1->resize(bild1.size());
QMessageBox::information(this,"1","1");
stopUhrzeit();
}
}
//die Methode zeigeDatum()
void Bildbetrachter::zeigeBild2() //Bild2
{
QPixmap bild2;
if (timerDatum->isActive()==false)
{stopDatum();
return;
}
else
{
if (timerDatum->isActive()==true)
{
bild2.load("C:/Qt/Bilder/2.jpg");
//die Größe wird dabei an die Breite 200 angepasst
bild2 = bild2.scaledToWidth(200);
//im Label anzeigen
bildLabel2->setPixmap(bild2);
//die Größe des Labels an die Größe des Bildes anpassen
bildLabel2->resize(bild2.size());
QMessageBox::information(this,"2","Bild2");
}
}
}
//die Methode stopUhrzeit()- Bild1 stoppen
void Bildbetrachter::stopUhrzeit() //Bild1
{
//den Timer für Bild-1 anhalten
timerZeit->stop(); //Bild1
bildLabel1->clear();
//den Timer für Bild-2 starten
timerDatum->start(5000); //Bild2
//Bild-2 Anzeige;
zeigeBild2(); //Bild2 anzeigen
}
//die Methode stopDatum()
void Bildbetrachter::stopDatum() //Bild2
{
//QMessageBox::information(this,"2","Bild2");
//den Timer für Bild-2 anhalten
timerDatum->stop(); //Bild2
bildLabel2->clear();
//den Timer für Bild-2 starten
timerZeit->start(5000); //Bild1
//Bild-1 Anzeige;
zeigeBild1(); //Bild1 anzeigen
}
----------------------------------------------------------------
The Header File "bildbetrachter.h"
#ifndef BILDBETRACHTER_H
#define BILDBETRACHTER_H
//die Header-Dateien einbinden
#include
#include
#include
#include
#include
#include
#include
#include
//oder auch
//#include
//unsere eigene Klasse erbt von QWidget
class Bildbetrachter : public QWidget
{
//das Makro Q_OBJECT
Q_OBJECT
public:
//der Konstruktor
Bildbetrachter();
//die Methoden und Attribute
private:
void zeigeUhrzeit(); //Bild1
void zeigeDatum(); //Bild2
void stopUhrzeit(); //Bild1
void stopDatum(); //Bild2
bool doppelpunkt;
//der erste Timer
QTimer* timerZeit; //Bild1
//der zweite Timer
QTimer* timerDatum; //Bild2
//die Slots
public slots:
//void oeffneBilddatei();
//void waehleDateiAus();
void zeigeBild1();
void zeigeBild2();
private slots:
//die Methode für den ersten Timer
void timerZeitSlot();
//die Methode für den zweiten Timer
void timerDatumSlot();
private:
//die Attribute für die Widgets
QLCDNumber *lcdnumber;
QLabel* einLabel, *bildLabel1,*bildLabel2;
QLineEdit* eingabeZeile;
QPushButton* oeffnenButton, *beendenButton, *startButton,*auswaehlenButton;
};
#endif
-------------------------------------------------------
The main.cpp file
#include
#include "bildbetrachter.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
//das Haupt-Widget erzeugen und anzeigen
Bildbetrachter* betrachter = new Bildbetrachter();
betrachter->show();
return app.exec();
}
--------------------------------------------------------
↧
Code repetition
hello there . I had a little problem with my code which I could solve I suppose to read something from user then tell him if palindrome or not the problem is that any word I enter is palidrome and when I repeat it I also got something wrong Do I have to use array instead?
I tried cin.ignore ( 1000 , '\n' ) before the function call didnt work ;
this is the output I had
Execution number 1:
-------------------
Please enter a word or a phase :
elsa
"elsa" is palidrome.
Do you want to do another computation ? Y/N
y
Execution number 2:
-------------------
Please enter a word or a phase :
"" is palidrome.
Do you want to do another computation ? Y/N
thx for your help
Code:
#include < iostream >
#include <string>
#include <algorithm>
using namespace std;
bool is_palindrome( string &s)
{
return equal ( s.begin(), s.end(), s.rbegin() );
}
int main ()
{
string input; char choice; int lc = 1;
do {
cout << "\nExecution number " << lc << ":" <<endl;
cout << "-------------------" << endl;
cout << "\nPlease enter a word or a phase :\n" << endl;
getline ( cin , input );
is_palindrome ( input );
if ( is_palindrome )
cout << "\n\"" << input << "\"" << " is palidrome.\n" << endl;
else
cout << "\n\"" << input << "\"" << " is not palidrome.\n" << endl;
do {
cout << "\nDo you want to do another computation ? Y/N \n" << endl;
cin >> choice;
}while ( choice != 'Y' && choice != 'y' && choice != 'n' && choice != 'N' && cout << "\nSorry wrong input!\n" );
++lc;
}while ( choice == 'y' || choice == 'Y' );
cout << "\n";
system ( "pause" );
return 0;
}
I tried cin.ignore ( 1000 , '\n' ) before the function call didnt work ;
this is the output I had
Execution number 1:
-------------------
Please enter a word or a phase :
elsa
"elsa" is palidrome.
Do you want to do another computation ? Y/N
y
Execution number 2:
-------------------
Please enter a word or a phase :
"" is palidrome.
Do you want to do another computation ? Y/N
thx for your help
↧
code mulfunction
hello guys . So I was working on a code where I should accept numbers from user and store threm only if there unique in that array . so the prob is that I'm getting a wrong input . This is my code below :
thx for you help
Code:
#include <iostream>
using namespace std;
void addToArray ( int array1[], int x )
{
int max = 0;
bool duplicate = false; //assume its false and prove the opposite if any.
for ( int i = 0; i <= max; ++i ) //no number stored ( no duplicates yet ).
{
if ( array1[i] == x )
{
duplicate = true;
break;
}
}
if ( !duplicate ) //from here we only add the number if unique.
{
array1[max] = x;
++max;
}
}
const int Max = 20; //max allowed is 20 ( const use )
int main ()
{
int arr [Max] = {};
int n;
for (int i = 0; i < Max; ++i) {
cout << "\nEnter value between 10 and 100 (" << i + 1 << "/20) :\n" << endl;
cin >> n;
if (n >= 10 && n <= 100)
addToArray(arr, n);
else {
cout << "\nWrong input!\n " << endl;
i--;
}
}
for ( int i = 0 ; i< Max ; ++i )
{
if ( arr[i] != 0)
cout << arr[i] << endl;
}
cout << "\n";
system("pause");
return 0;
}
↧
code generation
hello there I need help with my code plz
↧
↧
Newbie to C++ and visual studio encounters syntax errors during compilation.
Hello Everyone!
I'm new to this forum. Coming from c and java, i thought is about time to learn c++. I started learning about a day ago and today i encountered some syntax errors which i can't identify and fix.
I'm trying to make a simple trie data structure for storing strings. I know exactly how they work, i already made other projects in java about tries, the problem is why i get these errors.
So lets show you my code (I'm working in visual studio community 2017):
If you want for simplicity you can download the Visual Studio Project.
Main.cpp
trie_node.h
trie_node.cpp
map_node.h
map_node.cpp
map.h
map.cpp
Visual Studio Error Codes:
![Name: Capture.jpg
Views: 28
Size: 45.1 KB]()
I'm new to this forum. Coming from c and java, i thought is about time to learn c++. I started learning about a day ago and today i encountered some syntax errors which i can't identify and fix.
I'm trying to make a simple trie data structure for storing strings. I know exactly how they work, i already made other projects in java about tries, the problem is why i get these errors.
So lets show you my code (I'm working in visual studio community 2017):
If you want for simplicity you can download the Visual Studio Project.
Main.cpp
Code:
#include <iostream>
#include "trie_node.h"
int main(void) {
system("pause");
return 0;
}
Code:
#pragma once
#include "map.h"
class TrieNode {
private:
Map map;
bool end_of_world;
public:
TrieNode();
Map getMap();
void setBool(bool value);
bool getBool();
};
Code:
#include "trie_node.h"
TrieNode::TrieNode() {
this->end_of_world = false;
}
Map TrieNode::getMap() {
return this->map;
}
void TrieNode::setBool(bool value) {
this->end_of_world = value;
}
bool TrieNode::getBool() {
return this->end_of_world;
}
Code:
#pragma once
#include "trie_node.h"
class MapNode {
private:
char ch;
::MapNode *next;
TrieNode *trie_node;
public:
MapNode();
char getChar();
::MapNode *getNext();
TrieNode *getTrie();
void setNext(::MapNode *new_node);
void setCh(char ch);
void setTrie(TrieNode *new_node);
};
Code:
#include "map_node.h"
MapNode::MapNode() {
this->ch = '\0';
this->next = nullptr;
this->trie_node = nullptr;
}
char MapNode::getChar() {
return this->ch;
}
MapNode *MapNode::getNext() {
return this->next;
}
TrieNode *MapNode::getTrie() {
return this->trie_node;
}
void MapNode::setNext(MapNode *new_node) {
this->next = new_node;
}
void MapNode::setCh(char ch) {
this->ch = ch;
}
void MapNode::setTrie(TrieNode *new_node) {
this->trie_node = new_node;
}
Code:
#pragma once
#include "map_node.h"
class Map {
private:
MapNode *head;
MapNode *tail;
int size;
public:
Map();
void insert(char ch, TrieNode *new_node);
TrieNode *search(char h);
int getSize();
};
Code:
#include "map.h"
Map::Map() {
this->head = nullptr;
this->tail = nullptr;
this->size = 0;
}
void Map::insert(char ch, TrieNode *trie_node) {
MapNode *new_node = new MapNode();
new_node->setCh(ch);
new_node->setTrie(trie_node);
this->size++;
if (this->head == nullptr) {
this->head = new_node;
this->tail = new_node;
}
else {
this->tail->setNext(new_node);
this->tail = new_node;
}
}
TrieNode *Map::search(char ch) {
MapNode *current = this->head;
while (current != nullptr) {
if (current->getChar() == ch)
return current->getTrie();
current = current->getNext();
}
return nullptr;
}
int Map::getSize() {
return this->size;
}
Visual Studio Error Codes:
↧
[RESOLVED] error LNK2019 unresolved external symbol
How come im getting these errors?
1>CrateDemo.obj : error LNK2019: unresolved external symbol "public: float __thiscall IvVector3::Length(void)const " (?Length@IvVector3@@QBEMXZ) referenced in function "public: float __thiscall CameraApp::SegmentArcLength(unsigned int,float,float)" (?SegmentArcLength@CameraApp@@QAEMIMM@Z)
1>CrateDemo.obj : error LNK2019: unresolved external symbol "public: __thiscall IvVector3::IvVector3(class IvVector3 const &)" (??0IvVector3@@QAE@ABV0@@Z) referenced in function "public: float __thiscall CameraApp::SegmentArcLength(unsigned int,float,float)" (?SegmentArcLength@CameraApp@@QAEMIMM@Z)
1>CrateDemo.obj : error LNK2019: unresolved external symbol "public: class IvVector3 __thiscall IvVector3::operator+(class IvVector3 const &)const " (??HIvVector3@@QBE?AV0@ABV0@@Z) referenced in function "public: float __thiscall CameraApp::SegmentArcLength(unsigned int,float,float)" (?SegmentArcLength@CameraApp@@QAEMIMM@Z)
Code:
---------
class CameraApp : public IvVector3
{
public:
CameraApp();
bool InitializeNatural( const IvVector3* positions, const float* times, unsigned int count );
IvVector3 mPositions[5];
IvVector3 mInTangents[4];
IvVector3 mOutTangents[4];
float mTimes[5];
float mCount[5];
static int count;
float mLengths[4];
static float mTotalLength;
float SegmentArcLength( UInt32 i, float u1, float u2 );
};
int CameraApp::count = 5;
float CameraApp::mTotalLength = 0.0f;
float CameraApp::SegmentArcLength( UInt32 i, float u1, float u2 )
{
static const float x[] =
{
0.0000000000f, 0.5384693101f, -0.5384693101f, 0.9061798459f, -0.9061798459f
};
static const float c[] =
{
0.5688888889f, 0.4786286705f, 0.4786286705f, 0.2369268850f, 0.2369268850f
};
if ( u2 <= u1 )
return 0.0f;
if ( u1 < 0.0f )
u1 = 0.0f;
if ( u2 > 1.0f )
u2 = 1.0f;
// use Gaussian quadrature
float sum = 0.0f;
// set up for computation of IvHermite derivative
IvVector3 A = 2.0f*mPositions[i]
- 2.0f*mPositions[i+1]
+ mInTangents[i]
+ mOutTangents[i];
IvVector3 B = -3.0f*mPositions[i]
+ 3.0f*mPositions[i+1]
- mInTangents[i]
- 2.0f*mOutTangents[i];
IvVector3 C = mInTangents[i];
for ( UInt32 j = 0; j < 5; ++j )
{
float u = 0.5f*((u2 - u1)*x[j] + u2 + u1);
IvVector3 derivative = C + u*(2.0f*B + 3.0f*u*A);
sum += c[j]*derivative.Length();
}
sum *= 0.5f*(u2-u1);
return sum;
} // End of IvHermite::SegmentArcLength()
bool CameraApp::InitializeNatural( const IvVector3* positions,
const float* times,
unsigned int count )
{
// make sure not already initialized
if (mCount != 0)
return false;
// make sure data is valid
if ( count < 3 || !positions || !times )
return false;
// copy positions and times
for ( unsigned int i = 0; i < count; ++i )
{
mPositions[i] = positions[i];
mTimes[i] = times[i];
}
// build tangent data
unsigned int n = count;
float L; // current lower diagonal matrix entry
float* U = new float[n]; // upper diagonal matrix entries
IvVector3* z = new IvVector3[n]; // solution of lower diagonal system Lz = b
// solve for upper matrix and partial solution z
L = 2.0f;
U[0] = 0.5f;
z[0] = 3.0f*(positions[1] - positions[0])/L;
for ( unsigned int i = 1; i < n-1; ++i )
{
// add internal entry to linear system for smooth spline
L = 4.0f - U[i-1];
U[i] = 1.0f/L;
z[i] = 3.0f*(positions[i+1] - positions[i-1]);
z[i] -= z[i-1];
z[i] /= L;
}
L = 2.0f - U[n-2];
z[n-1] = 3.0f*(positions[n-1] - positions[n-2]);
z[n-1] -= z[n-2];
z[n-1] /= L;
// solve Ux = z (see Burden and Faires for details)
mInTangents[n-2] = z[n-1];
for ( unsigned int i = n-2; i > 0; --i )
{
mInTangents[i-1] = z[i] - U[i]*mInTangents[i];
mOutTangents[i] = mInTangents[i-1];
}
mOutTangents[0] = z[0] - U[0]*mInTangents[0];
// set up curve segment lengths
mTotalLength = 0.0f;
for ( unsigned int i = 0; i < count-1; ++i )
{
mLengths[i] = SegmentArcLength(i, 0.0f, 1.0f);
mTotalLength += mLengths[i];
}
delete [] U;
delete [] z;
return true;
} // End of IvHermite::InitializeNatural()
---------
↧
c++ dictionary
I have a total new concept I want to use . I never used this before . I want to add a dictionary to my c++ program I want it to be able to include it in my program to use it to search for words in 2d arrays ( I heard about 8 direction search ) . can you help me ?? thx alot
↧