blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
2
247
content_id
stringlengths
40
40
detected_licenses
listlengths
0
57
license_type
stringclasses
2 values
repo_name
stringlengths
4
111
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
58
visit_date
timestamp[ns]date
2015-07-25 18:16:41
2023-09-06 10:45:08
revision_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
committer_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
github_id
int64
3.89k
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
25 values
gha_event_created_at
timestamp[ns]date
2012-06-07 00:51:45
2023-09-14 21:58:52
gha_created_at
timestamp[ns]date
2008-03-27 23:40:48
2023-08-24 19:49:39
gha_language
stringclasses
159 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
10.5M
extension
stringclasses
111 values
filename
stringlengths
1
195
text
stringlengths
7
10.5M
17c1f3d5e62212b448030c6e0b2ba3d416714f8d
67f3a939a9ed4a922e51141bc394f76aa03c410d
/SLL.cpp
c16ea23a9c0c64b071f6aed0eef089a3c042d159
[]
no_license
ucsb-cs24-w18/SLL
1527d45d434e495199b33894c57f8b13ac3fee87
83b740ea121acd05175f7b09a015622b342bd47a
refs/heads/master
2021-01-24T04:01:43.181160
2018-02-26T20:45:00
2018-02-26T20:45:00
122,917,642
0
0
null
null
null
null
UTF-8
C++
false
false
3,664
cpp
SLL.cpp
/* SLL.cpp * Author: Zack Higgins * Implementation of class SLL defined within SLL.h */ #include <iostream> #include "SLL.h" using namespace std; // Constructor: SLL::SLL() { head = NULL; transient = NULL; } // SLL Destructor: SLL::~SLL() { delete head; } // Node Destructor: node::~node() { delete next; } // Copy Constructor: SLL::SLL(const SLL& SLL1) { // Stub } // Assignment Operator: SLL& SLL::operator=(const SLL& SLL1) { // Stub } // Insertion Functions: void SLL::insertAtHead(int value) { transient = head; transient = new node; transient -> data = value; transient -> next = head; head = transient; return; } void SLL::insertAtTail(int value) { if (!head) // For an empty list. { insertAtHead(value); return; } transient = head; while (transient -> next) { transient = transient -> next; } transient -> next = new node; transient = transient -> next; transient -> data = value; transient -> next = NULL; return; } void SLL::insertAtIndex(int value, int index) { int count(0); node* temporary; transient = head; if (!head) // If an empty list. { insertAtHead(value); return; } if (index < 1) // For indices zero or lesser. { insertAtHead(value); return; } while (transient -> next && count < (index-1)) // Iterates to specified position. { transient = transient -> next; count++; } if (transient) // If another node follows the one being created. { temporary = new node; temporary -> data = value; temporary -> next = transient -> next; transient -> next = temporary; return; } temporary = new node; // If no node follows the one being created. temporary -> data = value; temporary -> next = NULL; transient -> next = temporary; return; } void SLL::insertBeforeData(int value, int data) { node* temporary; transient = head; if (!head) // If an empty list. { return; } while (transient -> next && transient -> next -> data != data) // Iterates until finding specified data or list is complete. { transient = transient -> next; } if (!transient -> next) // If no node data matches specified value. { return; } temporary = new node; temporary -> data = value; temporary -> next = transient -> next; transient -> next = temporary; return; } void SLL::insertAfterData(int value, int data) { node* temporary; transient = head; if (!head) // If an empty list. { return; } while (transient && transient -> data != data) // Iterates until finding specified data or list is complete. { transient = transient -> next; } if (!transient) // If no node data matches specified value. { return; } temporary = new node; temporary -> data = value; temporary -> next = transient -> next; transient -> next = temporary; return; } // Deletion Functions: void SLL::deleteAtHead() { } void SLL::deleteAtTail() { } void SLL::deleteAllPriorToIndex(int index) { } void SLL::deleteAllAfterIndex(int index) { } void SLL::deleteFirstOfData(int data) { } void SLL::deleteAllOfData(int data) { } // Miscellaneous Functions: void SLL::reverseList() { } void SLL::printSLL() { transient = head; while (transient) { cout << transient -> data << endl; transient = transient -> next; } return; } bool SLL::isPalindrome() { }
b8fb41127f1c70ddb74f68bd608005ef50b0a69b
8b289e0b26f7d04af6e02450ae46029a04d7342c
/ex03_03.cpp
0ad02ab8b52273e7a60378d16dd1a7a37829fd55
[]
no_license
kayblecar/CS172
079b1c499263fb0e6f0937d539a49ea91f0f75c9
84e62686d2c4130fef6ed6a1da802855119cfe04
refs/heads/master
2021-01-10T08:47:57.305554
2015-06-26T05:52:55
2015-06-26T05:52:55
36,346,850
0
0
null
null
null
null
UTF-8
C++
false
false
528
cpp
ex03_03.cpp
//Kay Ratcliff //CS 172 #include <iostream> using namespace std; class EvenNumber{ public: int value; EvenNumber(){ value = 0; } EvenNumber(int number){ if (number % 2 == 0) value = number; else value = 0; } int getValue(){ return value; } int getNext(){ return value + 2; } int getPrevious(){ return value - 2; } }; int main(){ EvenNumber e (16); cout << "The value is " << e.getValue() << ", the next value is " << e.getNext() << ", and the previous value is " << e.getPrevious() << endl; }
5367643cb58a0b0eba0bade666fca0a6092b788a
4b1fe891a91128e9b66a2d51b7cb38145c2de23a
/kran.h
e382811a0996e8f46440d68d29530e6f9417ae23
[]
no_license
yss120612/Blink
b535e2d313fac207e36fec117ac9f9efb7ddc4d8
8495fe86b76ca067c1986614d441125c04b97f6b
refs/heads/master
2020-03-15T08:45:54.870962
2018-06-04T00:34:15
2018-06-04T00:34:15
132,059,208
0
0
null
null
null
null
UTF-8
C++
false
false
670
h
kran.h
// kran.h #ifndef _KRAN_h #define _KRAN_h #if defined(ARDUINO) && ARDUINO >= 100 #include "arduino.h" #else #include "WProgram.h" #endif #endif const uint16_t switch_time = 7000; const uint8_t quantumT=70; class Kran { private: boolean inQuantum; boolean inProgress; long progress_time; uint8_t close_pin; uint8_t open_pin; uint8_t measure_pin; uint8_t relay_pin; uint8_t state; int8_t quantum; public: Kran() { }; void forceClose(); void openQuantum(int8_t oq); void shiftQuantum(int8_t oq); void process(long ms); boolean measureState(); void setup(uint8_t c_pin, uint8_t o_pin, uint8_t m_pin, uint8_t r_pin); void close(); void open(); };
d0a0c4753b017584ad5fd5cee38c8074622f615d
71bbaca3a7603cd1baf92f72f104f06f4298f521
/two.cpp
f1107fc6137d735ce73c021d13a2687307bc7755
[]
no_license
zhujiangjiang/redistest
e3dcbdbd1f6fdc45a343514dd41f01b3295ca23f
c0cf4e074850611b63fef2e8de703dbc63062165
refs/heads/master
2021-01-16T19:20:03.025773
2016-02-18T03:56:00
2016-02-18T03:56:00
40,967,558
0
0
null
null
null
null
UTF-8
C++
false
false
95
cpp
two.cpp
#include<iostream> using namespace std; void master() { cout << "master call" << endl; }
be7309d8cde698cf8dba21d9709482959206577c
1369bc79715f22132daf416666703f229b84e39f
/util/time.h
7a7f6c8a6f86ba67e9055209472fbe55c8f0293a
[ "Apache-2.0" ]
permissive
aarossig/aprs-utils
bbfaac0649f947cd47122c97dbdba77d033c0ae4
3f7bdd604fde076c514d91ceaf23604f3f59b53d
refs/heads/master
2022-11-16T00:53:46.583147
2020-07-12T19:58:25
2020-07-12T19:58:25
278,229,937
0
0
null
null
null
null
UTF-8
C++
false
false
1,139
h
time.h
/* * Copyright 2020 Andrew Rossignol andrew.rossignol@gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef APRS_UTILS_UTIL_TIME_H_ #define APRS_UTILS_UTIL_TIME_H_ #include <cstdint> namespace au { // The number of microseconds per second. constexpr uint64_t kUsPerS = 1000000; // Gets the current system time in microseconds. uint64_t GetTimeNowUs(); // Pauses the ucrrent thread for the requested amount of time. void SleepFor(uint64_t time_us); // Pauses the current thread until the requested end time. void SleepUntil(uint64_t end_time_us); } // namespace au #endif // APRS_UTILS_UTIL_TIME_H_
a2511e5fa1a414ac4bb331be86ac70e3a045e061
21f2d33fcb6f9199a41ba6d75ae9339126abd1e1
/src/df_polygon.cpp
e3f07327f190ac42ff5de022eac584f0562aebd3
[ "MIT", "BSD-3-Clause" ]
permissive
abainbridge/deadfrog-lib
d22fe66b5886495132ef79ba2f0da3f080557614
58bd087a600165d929d5811392db31fbc5c32369
refs/heads/master
2023-07-08T09:41:20.282615
2023-06-29T20:36:53
2023-06-29T20:36:53
32,854,035
12
2
MIT
2023-03-05T10:35:29
2015-03-25T09:14:40
C++
UTF-8
C++
false
false
15,058
cpp
df_polygon.cpp
// This code originally came from Michael Abrash's Zen of Graphics, // 2nd edition, chapter 23. // Color-fills a convex polygon. All vertices are offset by (XOffset, // YOffset). "Convex" means that every horizontal line drawn through // the polygon at any point would cross exactly two active edges // (neither horizontal lines nor zero-length edges count as active // edges; both are acceptable anywhere in the polygon), and that the // right & left edges never cross. (It's OK for them to touch, though, // so long as the right edge never crosses over to the left of the // left edge.) Nonconvex polygons won't be drawn properly. Returns 1 // for success, 0 if memory allocation failed. #include "df_polygon.h" #include "df_bitmap.h" #include "df_common.h" #include <stdio.h> #include <stdlib.h> #include <math.h> #include <malloc.h> // Describes the beginning and ending X coordinates of a single // horizontal line struct HLineData { int startX; // X coordinate of leftmost pixel in line int endX; // X coordinate of rightmost pixel in line }; // Describes a Length-long series of horizontal lines, all assumed to // be on contiguous scan lines starting at YStart and proceeding // downward (used to describe a scan-converted polygon to the // low-level hardware-dependent drawing code) struct HLineList { int numLines; int startY; // Y coordinate of topmost line HLineData *hline; // pointer to list of horz lines }; // Advances the index by one vertex forward through the vertex list, // wrapping at the end of the list #define INDEX_FORWARD(index) index = (index + 1) % vertexList->numPoints; // Advances the index by one vertex backward through the vertex list, // wrapping at the start of the list #define INDEX_BACKWARD(index) index = (index - 1 + vertexList->numPoints) % vertexList->numPoints; // Advances the index by one vertex either forward or backward through // the vertex list, wrapping at either end of the list #define INDEX_MOVE(index, direction) \ if (direction > 0) { INDEX_FORWARD(index); } \ else { INDEX_BACKWARD(index); } // Scan converts an edge from (X1,Y1) to (X2,Y2), not including the // point at (X2,Y2). If SkipFirst == 1, the point at (X1,Y1) isn't // drawn; if SkipFirst == 0, it is. For each scan line, the pixel // closest to the scanned edge without being to the left of the // scanned edge is chosen. Uses an all-integer approach for speed and // precision. static void ScanEdge(int x1, int y1, int x2, int y2, int setXStart, int skipFirst, HLineData **edgePointPtr) { int errorTerm, errorTermAdvance, xMajorAdvanceAmt; HLineData *workingEdgePointPtr = *edgePointPtr; // avoid double dereference int deltaX = x2 - x1; int advanceAmt = (deltaX > 0) ? 1 : -1; // direction in which X moves (Y2 is always > Y1, so Y always counts up) int height = y2 - y1; if (height <= 0) // Y length of the edge return; // guard against 0-length and horizontal edges // Figure out whether the edge is vertical, diagonal, X-major // (mostly horizontal), or Y-major (mostly vertical) and handle // appropriately int width = abs(deltaX); if (width == 0) { // The edge is vertical; special-case by just storing the same // X coordinate for every scan line // Scan the edge for each scan line in turn for (int i = height - skipFirst; i-- > 0; workingEdgePointPtr++) { // Store the X coordinate in the appropriate edge list if (setXStart == 1) workingEdgePointPtr->startX = x1; else workingEdgePointPtr->endX = x1; } } else if (width == height) { // The edge is diagonal; special-case by advancing the X // coordinate 1 pixel for each scan line if (skipFirst) // skip the first point if so indicated x1 += advanceAmt; // move 1 pixel to the left or right // Scan the edge for each scan line in turn for (int i = height - skipFirst; i-- > 0; workingEdgePointPtr++) { // Store the X coordinate in the appropriate edge list if (setXStart == 1) workingEdgePointPtr->startX = x1; else workingEdgePointPtr->endX = x1; x1 += advanceAmt; // move 1 pixel to the left or right } } else if (height > width) { // Edge is closer to vertical than horizontal (Y-major) if (deltaX >= 0) errorTerm = 0; // initial error term going left->right else errorTerm = -height + 1; // going right->left if (skipFirst) { // skip the first point if so indicated // Determine whether it's time for the X coord to advance if ((errorTerm += width) > 0) { x1 += advanceAmt; // move 1 pixel to the left or right errorTerm -= height; // advance ErrorTerm to next point } } // Scan the edge for each scan line in turn for (int i = height - skipFirst; i-- > 0; workingEdgePointPtr++) { // Store the X coordinate in the appropriate edge list if (setXStart == 1) workingEdgePointPtr->startX = x1; else workingEdgePointPtr->endX = x1; // Determine whether it's time for the X coord to advance if ((errorTerm += width) > 0) { x1 += advanceAmt; // move 1 pixel to the left or right errorTerm -= height; // advance ErrorTerm to correspond } } } else { // Edge is closer to horizontal than vertical (X-major) // Minimum distance to advance X each time xMajorAdvanceAmt = (width / height) * advanceAmt; // Error term advance for deciding when to advance X 1 extra errorTermAdvance = width % height; if (deltaX >= 0) errorTerm = 0; // initial error term going left->right else errorTerm = -height + 1; // going right->left if (skipFirst) { // skip the first point if so indicated x1 += xMajorAdvanceAmt; // move X minimum distance // Determine whether it's time for X to advance one extra if ((errorTerm += errorTermAdvance) > 0) { x1 += advanceAmt; // move X one more errorTerm -= height; // advance ErrorTerm to correspond } } // Scan the edge for each scan line in turn for (int i = height - skipFirst; i-- > 0; workingEdgePointPtr++) { // Store the X coordinate in the appropriate edge list if (setXStart == 1) workingEdgePointPtr->startX = x1; else workingEdgePointPtr->endX = x1; x1 += xMajorAdvanceAmt; // move X minimum distance // Determine whether it's time for X to advance one extra if ((errorTerm += errorTermAdvance) > 0) { x1 += advanceAmt; // move X one more errorTerm -= height; // advance ErrorTerm to correspond } } } *edgePointPtr = workingEdgePointPtr; // advance caller's ptr } static void DrawHorizontalLineList(DfBitmap *bmp, HLineList *hLines, DfColour col) { int startY = hLines->startY; int len = hLines->numLines; int endY = startY + len; // Clip against the top of the bitmap if (startY < 0) { if (endY < 0) return; hLines -= startY; len += startY; startY = 0; } // Clip against the bottom of the bitmap if (endY >= (int)bmp->height) { if (startY >= (int)bmp->height) return; len = bmp->height - startY; } // Draw the hlines HLineData *firstLine = hLines->hline; HLineData *lastLine = firstLine + len; if (col.a != 255) { // Alpha blended path... int y = startY; for (HLineData * __restrict line = firstLine; line < lastLine; line++, y++) HLine(bmp, line->startX, y, line->endX - line->startX, col); } else { // Solid colour path... DfColour * __restrict row = bmp->pixels + bmp->width * hLines->startY; for (HLineData * __restrict line = firstLine; line < lastLine; line++) { // Clip against sides of bitmap int startX = IntMax(0, line->startX); int endX = IntMin(bmp->width, line->endX); if (startX >= (int)bmp->width || endX < 0) continue; for (int x = startX; x < endX; x++) row[x] = col; row += bmp->width; } } } int FillConvexPolygon(DfBitmap *bmp, PolyVertList *vertexList, DfColour col, int xOffset, int yOffset) { // Point to the vertex list PolyVert *vertices = vertexList->points; // Scan the list to find the top and bottom of the polygon if (vertexList->numPoints == 0) return 1; // reject null polygons int minIndexL, maxIndex, minPointY; int maxPointY = minPointY = vertices[minIndexL = maxIndex = 0].y; for (int i = 1; i < vertexList->numPoints; i++) { if (vertices[i].y < minPointY) minPointY = vertices[minIndexL = i].y; // new top else if (vertices[i].y > maxPointY) maxPointY = vertices[maxIndex = i].y; // new bottom } if (minPointY == maxPointY) return 1; // polygon is 0-height; avoid infinite loop below // Scan in ascending order to find the last top-edge point int minIndexR = minIndexL; while (vertices[minIndexR].y == minPointY) INDEX_FORWARD(minIndexR); INDEX_BACKWARD(minIndexR); // back up to last top-edge point // Now scan in descending order to find the first top-edge point while (vertices[minIndexL].y == minPointY) INDEX_BACKWARD(minIndexL); INDEX_FORWARD(minIndexL); // back up to first top-edge point // Figure out which direction through the vertex list from the top // vertex is the left edge and which is the right int leftEdgeDir = -1; // assume left edge runs down thru vertex list int topIsFlat = (vertices[minIndexL].x != vertices[minIndexR].x) ? 1 : 0; if (topIsFlat == 1) { // If the top is flat, just see which of the ends is leftmost if (vertices[minIndexL].x > vertices[minIndexR].x) { leftEdgeDir = 1; // left edge runs up through vertex list int temp = minIndexL; // swap the indices so MinIndexL minIndexL = minIndexR; // points to the start of the left minIndexR = temp; // edge, similarly for MinIndexR } } else { // Point to the downward end of the first line of each of the // two edges down from the top int nextIndex = minIndexR; INDEX_FORWARD(nextIndex); int previousIndex = minIndexL; INDEX_BACKWARD(previousIndex); // Calculate X and Y lengths from the top vertex to the end of // the first line down each edge; use those to compare slopes // and see which line is leftmost int deltaXN = vertices[nextIndex].x - vertices[minIndexL].x; int deltaYN = vertices[nextIndex].y - vertices[minIndexL].y; int deltaXP = vertices[previousIndex].x - vertices[minIndexL].x; int deltaYP = vertices[previousIndex].y - vertices[minIndexL].y; if ((deltaXN * deltaYP - deltaYN * deltaXP) < 0L) { leftEdgeDir = 1; // left edge runs up through vertex list int temp = minIndexL; // swap the indices so MinIndexL minIndexL = minIndexR; // points to the start of the left minIndexR = temp; // edge, similarly for MinIndexR } } // Set the # of scan lines in the polygon, skipping the bottom edge // and also skipping the top vertex if the top isn't flat because // in that case the top vertex has a right edge component, and set // the top scan line to draw, which is likewise the second line of // the polygon unless the top is flat HLineList workingHLineList; workingHLineList.numLines = maxPointY - minPointY - 1 + topIsFlat; if (workingHLineList.numLines <= 0) return 1; // there's nothing to draw, so we're done workingHLineList.startY = yOffset + minPointY + 1 - topIsFlat; // Get memory in which to store the line list we generate workingHLineList.hline = (HLineData *)alloca(sizeof(HLineData) * workingHLineList.numLines); if (workingHLineList.hline == NULL) return 0; // couldn't get memory for the line list // Scan the left edge and store the boundary points in the list // Initial pointer for storing scan converted left-edge coords HLineData *edgePoint = workingHLineList.hline; // Start from the top of the left edge int previousIndex = minIndexL; int currentIndex = previousIndex; // Skip the first point of the first line unless the top is flat; // if the top isn't flat, the top vertex is exactly on a right // edge and isn't drawn int skipFirst = topIsFlat ? 0 : 1; // Scan convert each line in the left edge from top to bottom do { INDEX_MOVE(currentIndex, leftEdgeDir); ScanEdge(vertices[previousIndex].x + xOffset, vertices[previousIndex].y, vertices[currentIndex].x + xOffset, vertices[currentIndex].y, 1, skipFirst, &edgePoint); previousIndex = currentIndex; skipFirst = 0; // scan convert the first point from now on } while (currentIndex != maxIndex); // Scan the right edge and store the boundary points in the list edgePoint = workingHLineList.hline; previousIndex = currentIndex = minIndexR; skipFirst = topIsFlat ? 0 : 1; // Scan convert the right edge, top to bottom. X coordinates are // adjusted 1 to the left, effectively causing scan conversion of // the nearest points to the left of but not exactly on the edge do { INDEX_MOVE(currentIndex, -leftEdgeDir); ScanEdge(vertices[previousIndex].x + xOffset - 1, vertices[previousIndex].y, vertices[currentIndex].x + xOffset - 1, vertices[currentIndex].y, 0, skipFirst, &edgePoint); previousIndex = currentIndex; skipFirst = 0; // scan convert the first point from now on } while (currentIndex != maxIndex); // Draw the line list representing the scan converted polygon DrawHorizontalLineList(bmp, &workingHLineList, col); return 1; }
2e04cd9acf9710e3e288fc02c65c9a216fd777d0
c008c9d730e57b13d3dbc8b80d1810c9a52995bb
/Logica1_LinguagemC/Aula_6/lista/exercício 4.1.cpp
de415e921136d2e79ea6e1766f901d1cb0d95acb
[]
no_license
andcoelho/Logica1_IFSP
d93d727c4ed32b5660a2a1aead9cd9c7cea7beb8
c0cad6402b792adad893870a9d9065cc0314a36c
refs/heads/main
2023-06-30T04:46:04.631934
2021-08-15T14:29:34
2021-08-15T14:29:34
391,426,302
0
0
null
null
null
null
UTF-8
C++
false
false
925
cpp
exercício 4.1.cpp
#include<stdio.h> int main () { int i, num=0, counter0=0, counter1=0, counter2=0, counter3=0; printf("para sair, digite um numero negativo\n"); while (num>-1){ printf("insira um numero positivo: "); scanf("%d", &num); for(i=0;i<=25;i++){ if(i==num){ counter0++; } } for(i=26;i<=50;i++){ if(i==num){ counter1++; } } for(i=51;i<=75;i++){ if(i==num){ counter2++; } } for(i=76;i<=100;i++){ if(i==num){ counter3++; } } } printf("\n\n\nentre 0 e 25: %d\n", counter0); printf("entre 26 e 50: %d\n", counter1); printf("entre 51 e 75: %d\n", counter2); printf("entre 76 e 100: %d\n", counter3); return 0; }
348193f41aa1172f6fa76fe80d998152a81c31da
d293694daaea6dd869698e8432ef144eb339fd60
/opencensus/tags/internal/tag_map_test.cc
6c41cf44c98707bcadf84fc7efaf70e4325d3dd9
[ "Apache-2.0" ]
permissive
census-instrumentation/opencensus-cpp
b76c979e54cf2e9c53fdeba4a33aaf12d75776ff
50eb5de762e5f87e206c011a4f930adb1a1775b1
refs/heads/master
2023-09-04T23:07:47.635622
2023-05-02T19:13:52
2023-05-02T19:13:52
91,836,765
148
80
Apache-2.0
2023-05-02T19:13:53
2017-05-19T18:59:46
C++
UTF-8
C++
false
false
3,745
cc
tag_map_test.cc
// Copyright 2018, OpenCensus Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "opencensus/tags/tag_map.h" #include <iostream> #include <string> #include <unordered_map> #include <utility> #include <vector> #include "gmock/gmock.h" #include "gtest/gtest.h" namespace opencensus { namespace tags { namespace { using ::testing::HasSubstr; TEST(TagMapTest, ConstructorsEquivalent) { TagKey key = TagKey::Register("k"); const std::vector<std::pair<TagKey, std::string>> tags({{key, "v"}}); EXPECT_EQ(TagMap(tags), TagMap({{key, "v"}})); } TEST(TagMapTest, TagsSorted) { TagKey k1 = TagKey::Register("b"); TagKey k2 = TagKey::Register("c"); TagKey k3 = TagKey::Register("a"); const std::vector<std::pair<TagKey, std::string>> expected = { {k1, "v"}, {k2, "v"}, {k3, "v"}}; const std::vector<std::pair<TagKey, std::string>> tags( {{k2, "v"}, {k3, "v"}, {k1, "v"}}); EXPECT_THAT(TagMap(tags).tags(), ::testing::ElementsAreArray(expected)); EXPECT_THAT(TagMap({{k2, "v"}, {k1, "v"}, {k3, "v"}}).tags(), ::testing::ElementsAreArray(expected)); } TEST(TagMapTest, EqualityDisregardsOrder) { TagKey k1 = TagKey::Register("k1"); TagKey k2 = TagKey::Register("k2"); EXPECT_EQ(TagMap({{k1, "v1"}, {k2, "v2"}}), TagMap({{k2, "v2"}, {k1, "v1"}})); } TEST(TagMapTest, EqualityRespectsMissingKeys) { TagKey k1 = TagKey::Register("k1"); TagKey k2 = TagKey::Register("k2"); EXPECT_NE(TagMap({{k1, "v1"}, {k2, "v2"}}), TagMap({{k1, "v1"}})); } TEST(TagMapTest, EqualityRespectsKeyValuePairings) { TagKey k1 = TagKey::Register("k1"); TagKey k2 = TagKey::Register("k2"); EXPECT_NE(TagMap({{k1, "v1"}, {k2, "v2"}}), TagMap({{k1, "v2"}, {k2, "v1"}})); } TEST(TagMapTest, HashDisregardsOrder) { TagKey k1 = TagKey::Register("k1"); TagKey k2 = TagKey::Register("k2"); TagMap ts1({{k1, "v1"}, {k2, "v2"}}); TagMap ts2({{k2, "v2"}, {k1, "v1"}}); EXPECT_EQ(TagMap::Hash()(ts1), TagMap::Hash()(ts2)); } TEST(TagMapTest, HashRespectsKeyValuePairings) { TagKey k1 = TagKey::Register("k1"); TagKey k2 = TagKey::Register("k2"); TagMap ts1({{k1, "v1"}, {k2, "v2"}}); TagMap ts2({{k1, "v2"}, {k2, "v1"}}); EXPECT_NE(TagMap::Hash()(ts1), TagMap::Hash()(ts2)); } TEST(TagMapTest, UnorderedMap) { // Test that the operators and hash are compatible with std::unordered_map. TagKey key = TagKey::Register("key"); std::unordered_map<TagMap, int, TagMap::Hash> map; TagMap ts = {{key, "value"}}; map.emplace(ts, 1); EXPECT_NE(map.end(), map.find(ts)); EXPECT_EQ(1, map.erase(ts)); } TEST(TagMapTest, DebugStringContainsTags) { TagKey k1 = TagKey::Register("key1"); TagKey k2 = TagKey::Register("key2"); TagMap ts({{k1, "value1"}, {k2, "value2"}}); const std::string s = ts.DebugString(); std::cout << s << "\n"; EXPECT_THAT(s, HasSubstr("key1")); EXPECT_THAT(s, HasSubstr("value1")); EXPECT_THAT(s, HasSubstr("key2")); EXPECT_THAT(s, HasSubstr("value2")); } TEST(TagMapDeathTest, DuplicateKeysNotAllowed) { TagKey k = TagKey::Register("k"); EXPECT_DEBUG_DEATH( { TagMap m({{k, "v1"}, {k, "v2"}}); }, "Duplicate keys are not allowed"); } } // namespace } // namespace tags } // namespace opencensus
93a7b0bcc7acc39c5da0cd5e009501b1c175739b
d3c8fb2cdf9868d95e7c08f904159dd6b04fd150
/processor/mem_hier_handle.h
6e78eccdb0742ac28055020a2d402d59505cd8dd
[]
no_license
dbancajas/dmr3d
006a5cf66a5faa9a4cbe8ca7d26bc5a5b71261b0
29763fc1379376e255d8a2a4e6f88b6b4ec753a2
refs/heads/master
2021-01-22T04:40:31.787563
2014-11-18T20:20:14
2014-11-18T20:20:14
26,828,298
1
1
null
null
null
null
UTF-8
C++
false
false
2,309
h
mem_hier_handle.h
#ifndef _MEM_HIER_HANDLE_H_ #define _MEM_HIER_HANDLE_H_ class mem_hier_handle_iface_t { public: virtual ~mem_hier_handle_iface_t() { } virtual void complete_request (conf_object_t *obj, conf_object_t *cpu, mem_trans_t *trans) = 0; virtual void invalidate_address (conf_object_t *obj, conf_object_t *cpu, invalidate_addr_t *invalid_addr) = 0; }; class mem_hier_handle_t : public mem_hier_handle_iface_t { private: conf_object_t *obj; mem_hier_interface_t *iface; mem_hier_t *mem_hier; string checkpoint_file; string mh_runtime_config_file; chip_t *chip; public: // mem_hier_handle_t (conf_object_t *obj, mem_hier_interface_t *iface, proc_object_t *proc); ~mem_hier_handle_t (); // cycles_t lsq_operate (conf_object_t *proc_obj, conf_object_t *space, map_list_t *map, generic_transaction_t *mem_op); static cycles_t static_lsq_operate (conf_object_t *proc_obj, conf_object_t *space, map_list_t *map, generic_transaction_t *mem_op); // cycles_t snoop_operate (conf_object_t *proc_obj, conf_object_t *space, map_list_t *map, generic_transaction_t *mem_op); static cycles_t static_snoop_operate (conf_object_t *proc_obj, conf_object_t *space, map_list_t *map, generic_transaction_t *mem_op); // void make_request (mem_trans_t *trans); // void complete_request (conf_object_t *obj, conf_object_t *cpu, mem_trans_t *trans); static void static_complete_request (conf_object_t *obj, conf_object_t *cpu, mem_trans_t *trans); // void invalidate_address (conf_object_t *obj, conf_object_t *cpu, invalidate_addr_t *invalid_addr); static void static_invalidate_address (conf_object_t *obj, conf_object_t *cpu, invalidate_addr_t *invalid_addr); // cycles_t handle_icache (mem_xaction_t *mem_xaction); void print_stats (void); // TODO: get void set_cpus (conf_object_t **cpus, uint32 num_cpus); void set_runtime_config (string config); string get_runtime_config (); // TODO: void set_checkpoint_file (string filename) { } string get_checkpoint_file () { return ""; } // DRAMSim2 utilities void printStats(); // Checkpoint utilities void stall_mem_hier(); bool is_mem_hier_quiet(); void clear_stats(); tick_t get_mem_g_cycles(); void profile_commits(dynamic_instr_t *dinst); }; #endif
32a76b67fc79e8a375e78960714379e6c32949ea
0c226f4a47ac0abde45f9daecd8e03ca6e7a2c26
/cpp/11726.cpp
fe165a7817626432fe5b03bcad1d462605bb7dbc
[]
no_license
fjvbn2003/BOJ_backup
1c86542131ffe0621be5dc6f37f3da812ceba00e
9ee0dfcd86bb3010040121b3a09b30b03e66d062
refs/heads/master
2023-01-08T00:43:26.061434
2020-11-11T07:23:05
2020-11-11T07:23:05
100,412,849
1
0
null
null
null
null
UTF-8
C++
false
false
287
cpp
11726.cpp
#include<iostream> using namespace std; long long DP[1001] = {0}; long long t(int d) { if (DP[d] == 0) { DP[d] = t(d - 1) + t(d - 2)*2; return DP[d]%10007; } else { return DP[d]%10007; } } int main() { DP[1] = 1; DP[2] = 3; int a; cin >> a; cout << t(a) << endl; }
089ab40831a643aaeaa4784686df61f5c8ca0a55
1ce24886887966339156e0ba747502e4686c8ff5
/src/lib/amgalan.cpp
dd2fce64535c78dfaf61b9d9ddb652f60009803a
[]
no_license
inductiveload/amgalan
08a361db0569dcdb5c4b151002787e0b822dc819
801c3c8dc7d4868c04c5b74fcb82f11b3a1a5c5c
refs/heads/master
2016-08-04T17:30:44.434214
2013-01-04T18:44:43
2013-01-04T18:44:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
218
cpp
amgalan.cpp
/* * SourceGrabber is a program that will suck down a set of images pages from * some source on the Internet */ #include <iostream> using namespace std; void getSource(void){ cout << "Grabbing source" << endl; }
d9bb4bfd8f2c69bb8fd76ae6b39e90b35008c4ed
43f1c307bccb43ace41c20b38b97e984d5604691
/DoisTriangulos/HelloTriangle/Source.cpp
244b9cb0d34d88e15459b9f1bbad7748aaee8320
[]
no_license
FabianeKuhn/Unisinos-PG
b159ea9f0044c4bcc0322f78733ef0bd34d11886
1269a7894599cec0ae7936333811fdac22ccb8e8
refs/heads/master
2020-04-29T19:46:36.914529
2019-06-08T15:28:23
2019-06-08T15:28:23
176,365,645
0
0
null
null
null
null
ISO-8859-1
C++
false
false
6,409
cpp
Source.cpp
/* Desenho de dois triângulos * * Adaptado por Fabiane Kuhn * para a disciplina de Processamento Gráfico - Unisinos * Versão inicial em 11/03/2019 * Última atualização em 17/03/2019 * */ #include <iostream> #include <string> #include <assert.h> using namespace std; // GLEW //#define GLEW_STATIC -- se habilitar, não precisa da dll #include <GL/glew.h> // GLFW #include <GLFW/glfw3.h> // Function prototypes void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode); // Window dimensions const GLuint WIDTH = 800, HEIGHT = 600; // Shaders const GLchar* vertexShaderSource = "#version 410\n" "layout (location = 0) in vec3 position;\n" "void main()\n" "{\n" "gl_Position = vec4(position.x, position.y, position.z, 1.0);\n" "}\0"; const GLchar* fragmentShaderSource = "#version 410\n" "uniform vec4 inputColor;\n" "out vec4 color;\n" "void main()\n" "{\n" "color = inputColor;\n" "}\n\0"; // The MAIN function, from here we start the application and run the game loop int main() { // Init GLFW glfwInit(); // Create a GLFWwindow object that we can use for GLFW's functions GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "Dois Triangulos", nullptr, nullptr); glfwMakeContextCurrent(window); // Set the required callback functions glfwSetKeyCallback(window, key_callback); // Set this to true so GLEW knows to use a modern approach to retrieving function pointers and extensions glewExperimental = GL_TRUE; // Initialize GLEW to setup the OpenGL Function pointers glewInit(); /* get version info */ const GLubyte* renderer = glGetString(GL_RENDERER); /* get renderer string */ const GLubyte* version = glGetString(GL_VERSION); /* version as a string */ cout << "Renderer: " << renderer << endl; cout << "OpenGL version supported " << version << endl; // Define the viewport dimensions int width, height; glfwGetFramebufferSize(window, &width, &height); glViewport(0, 0, width, height); // Build and compile our shader program // Vertex shader GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER); glShaderSource(vertexShader, 1, &vertexShaderSource, NULL); glCompileShader(vertexShader); // Check for compile time errors GLint success; GLchar infoLog[512]; glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &success); if (!success) { glGetShaderInfoLog(vertexShader, 512, NULL, infoLog); std::cout << "ERROR::SHADER::VERTEX::COMPILATION_FAILED\n" << infoLog << std::endl; } // Fragment shader GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); glShaderSource(fragmentShader, 1, &fragmentShaderSource, NULL); glCompileShader(fragmentShader); // Check for compile time errors glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &success); if (!success) { glGetShaderInfoLog(fragmentShader, 512, NULL, infoLog); std::cout << "ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n" << infoLog << std::endl; } // Link shaders GLuint shaderProgram = glCreateProgram(); glAttachShader(shaderProgram, vertexShader); glAttachShader(shaderProgram, fragmentShader); glLinkProgram(shaderProgram); // Check for linking errors glGetProgramiv(shaderProgram, GL_LINK_STATUS, &success); if (!success) { glGetProgramInfoLog(shaderProgram, 512, NULL, infoLog); std::cout << "ERROR::SHADER::PROGRAM::LINKING_FAILED\n" << infoLog << std::endl; } glDeleteShader(vertexShader); glDeleteShader(fragmentShader); // Set up vertex data (and buffer(s)) and attribute pointers float vertices[] = { -0.8f, 0.0f, 0.0f, // Left -0.2f, 0.0f, 0.0f, // Right -0.5f, 0.5f, 0.0f, // Top 0.2f, 0.0f, 0.0f, // Left 0.8f, 0.0f, 0.0f, // Right 0.5f, 0.5f, 0.0f // Top }; unsigned int indices[] = { // note that we start from 0! 0, 1, 2, // first triangle 3, 4, 5 // second triangle }; unsigned int EBO; glGenBuffers(1, &EBO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); unsigned int VBO, VAO; glGenVertexArrays(1, &VAO); glGenBuffers(1, &VBO); // 1. bind Vertex Array Object glBindVertexArray(VAO); // 2. copy our vertices array in a vertex buffer for OpenGL to use glBindBuffer(GL_ARRAY_BUFFER, VBO); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); // 3. copy our index array in a element buffer for OpenGL to use glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW); // 4. then set the vertex attributes pointers glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0); glEnableVertexAttribArray(0); // color attribute glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float), (void*)(3 * sizeof(float))); glEnableVertexAttribArray(1); //Enviando a cor desejada (vec4) para o fragment shader GLint colorLoc = glGetUniformLocation(shaderProgram, "inputColor"); assert(colorLoc > -1); glUseProgram(shaderProgram); glUniform4f(colorLoc, 1.0f, 0.0f, 1.0f, 1.0f); // Game loop while (!glfwWindowShouldClose(window)) { // Check if any events have been activiated (key pressed, mouse moved etc.) and call corresponding response functions glfwPollEvents(); // Render // Clear the colorbuffer glClearColor(0.2f, 0.3f, 0.3f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); // as we only have a single shader, we could also just activate our shader once beforehand if we want to glUseProgram(shaderProgram); glBindVertexArray(VAO); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); glBindVertexArray(0); // Swap the screen buffers glfwSwapBuffers(window); } // Properly de-allocate all resources once they've outlived their purpose glDeleteVertexArrays(1, &VAO); glDeleteBuffers(1, &VBO); // Terminate GLFW, clearing any resources allocated by GLFW. glfwTerminate(); return 0; } // Is called whenever a key is pressed/released via GLFW void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode) { if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) glfwSetWindowShouldClose(window, GL_TRUE); }
fda0fbdbfe1f97128152acc03843863568b46c01
98c7cc6e4436c2deb43bd965935f42ed6ab5396f
/ClientQT/NoodleClient/changepassword.cpp
4e1465a8efb781c43ec5a1f5d295743d1339ea47
[]
no_license
AndreiVladescu/Noodle
276c172fe3288bf5da8d49b936b0d327462fc68e
a737a9f196ff44ed2bedc707fb82fa28e4bbbf6e
refs/heads/main
2023-08-28T03:20:11.616796
2021-11-04T16:20:01
2021-11-04T16:20:01
357,468,256
0
0
null
null
null
null
UTF-8
C++
false
false
1,381
cpp
changepassword.cpp
#include "changepassword.h" #include "ui_changepassword.h" #include <QMessageBox> #include "IUser.h" ChangePassword::ChangePassword(QWidget *parent,IUser* u) : QDialog(parent), ui(new Ui::ChangePassword) , user(u) { ui->setupUi(this); this->setWindowTitle("Change password"); } ChangePassword::~ChangePassword() { delete ui; } void ChangePassword::on_confirmButton_clicked() { QString qpas1 = ui->NewPassword1->text(); QString qpas2 = ui->NewPassword2->text(); QString qoldp = ui->OldPassword->text(); if(qoldp=="" || qpas1=="" || qpas2=="") { QMessageBox::warning(this,"Change Password Error","All fields must be completed."); } else { if(qoldp.toStdString()!=this->user->getPsswrd()) { QMessageBox::warning(this,"Change Password Error","Old password is wrong, please try again."); } else { if(qpas1!=qpas2) { QMessageBox::warning(this,"Change Password Error","Passwords don't match, please try again."); } else { string newPass = qpas2.toStdString(); this->user->changePsswrd(newPass); QMessageBox::information(this,"Confirmation","Your password has been successfully updated!"); close(); } } } }
cf6d4ad02cfee7395b8e4e3d535765645ea46d0f
8ce838336cd99ffcedd1c8ef98fa5c0127bfba1d
/CMSC-237-Introduction-to-Computer-Graphics/.svn/pristine/cf/cf6d4ad02cfee7395b8e4e3d535765645ea46d0f.svn-base
cff5dcb1d18f4813cfa08883e0637e8792149bee
[]
no_license
mmm2206069/UChicagoCSWork
0122bd4edb41383759b381f3d7c7b834dc0983f5
8a7051133ce48b46cf9d3c5594bb6cde5e8ead69
refs/heads/master
2020-08-31T12:48:24.440348
2016-09-17T23:56:09
2016-09-17T23:56:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,685
cf6d4ad02cfee7395b8e4e3d535765645ea46d0f.svn-base
/*! \file mesh.hxx * * \author John Reppy */ /* CMSC23700 Project 4 sample code (Autumn 2015) * * COPYRIGHT (c) 2015 John Reppy (http://www.cs.uchicago.edu/~jhr) * All rights reserved. */ #ifndef _MESH_HXX_ #define _MESH_HXX_ #include "cs237.hxx" #include "obj.hxx" /*! The locations of the standard mesh attributes. The layout directives in the shaders * should match these values. */ const GLint CoordAttrLoc = 0; //!< location of vertex coordinates attribute const GLint NormAttrLoc = 1; //!< location of normal-vector attribute const GLint TexCoordAttrLoc = 2; //!< location of texture coordinates attribute const GLint TanAttrLoc = 3; //!< location of extended tangent vector //! the information needed to render a mesh class MeshInfo { public: //! create a MeshInfo object by initializing its buffer Ids. The buffer data is //! loaded separately. //! \param p the primitive use to render the mesh //! \param grp the OBJ Group used to initialize the vertex buffers MeshInfo (GLenum p, OBJ::Group const &grp, cs237::color3f diffuseC, cs237::color3f specularC, float shininess, cs237::texture2D *cmap, cs237::texture2D *nmap); //! destructor virtual ~MeshInfo (); //! does this mesh have a diffuse-color map? bool hasDiffuseMap () const { return (this->_cMap != nullptr); } //! return this mesh's diffuse-color map (or nullptr) const cs237::texture2D *DiffuseMap() const { return this->_cMap; } //! return the diffuse color for this mesh to use in lieu of the diffuse-color map cs237::color3f DiffuseColor () const { return this->_diffuseC; } //! bind the mesh's diffuse-color map to the specified texture unit void BindDiffuseMap (GLuint txtUnit) { assert (this->_cMap != nullptr); CS237_CHECK( glActiveTexture(txtUnit) ); this->_cMap->Bind(); } //! return the specular color for this mesh cs237::color3f SpecularColor () const { return this->_specularC; } //! return the shininess of the surface (aka the Phong exponent) float Shininess () const { return this->_shininess; } //! does this mesh have a normal map? bool hasNormalMap () const { return (this->_nMap != nullptr); } //! return this mesh's normal map (or nullptr) const cs237::texture2D *NormalMap() const { return this->_nMap; } //! bind the mesh's normal map to the specified texture unit void BindNormalMap (GLuint txtUnit) { assert (this->_nMap != nullptr); CS237_CHECK( glActiveTexture(txtUnit) ); this->_nMap->Bind(); } //! draw the mesh using a glDrawElements call //! \param enableNorms when true, we enable the normal-vector attribute buffer //! \param enableTxts when true, we enable the texture-coordinate attribute buffer //! \param enableTxts when true, we wnable the tangent=vector attribute buffer void Draw (bool enableNorms, bool enableTxts, bool enableTans); protected: //! a constructor for subclasses of meshes. //! \param p the primitive use to render the mesh MeshInfo (GLenum p); GLuint _vaoId; //!< vertex-array-object ID for this mesh GLuint _ebufId; //!< buffer ID for the index array GLenum _prim; //!< the primitive type for rendering the mesh //! (e.g., GL_TRIANGLES, GL_TRIANGLE_FAN, etc.) int _nIndices; //!< the number of vertex indices // material properties cs237::color3f _diffuseC; //!< the diffuse color cs237::color3f _specularC; //!< the specular color float _shininess; //!< the shininess of the surface cs237::texture2D *_cMap; //!< the color-map texture for the mesh cs237::texture2D *_nMap; //!< the normal-map texture for the mesh }; #endif // !_MESH_HXX_
0ccc4709c132d18882eb09218738ab1524bbbf89
45ca2a12a9f6be20f1442cbe7922b27b9311899a
/etc/classdecl.h
f73c7d57b10dfbf13f13fbe7afbe32e76285f60f
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
LoganDing/cslib
669ce63d97daf681df9f45389df5a2c762c6339c
3401fc6516e6952f01a13bb7de999c79a0937154
refs/heads/master
2020-12-24T13:29:31.181275
2015-06-03T19:32:52
2015-06-03T19:32:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,726
h
classdecl.h
#ifndef xxx_H_LOADED #define xxx_H_LOADED // [ // $ xxx.h // // // This software consists of voluntary contributions made by Chris Sanchez. // Portions of other open source software were used in the creation of this // software. Header files for work based on other source bears the // orininator copyright. // // Copyright 2011 Chris Sanchez // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // ==================================================================== // // Author: your-name // // RCS: // $Revision: 2.0 $ // $State: Exp $ // $Author: $ // $Date: $ // ? // Contents: xxx class // // Purpose: // // Usage Notes: // // // ? // ! Changes History // // ] class XXX { public: // create an XXX XXX(); ~XXX(); // comments for method1 void method1(); protected: private: int _data1; // Unimplemented standard methods XXX(const XXX& ); XXX& operator=(const XXX&); }; // xxx_H_LOADED #endif
b5806ccf8bfbf5b8e0ba129b8b600f5a48035265
edba9d0a6742a6451552a4375f2340dbfc757474
/OLA6/Main.cpp
00470dec55f30fd523b233270cfeaeebd1bc2992
[]
no_license
Silverfoxslash/CSCI-3110
8e9fb4210770f240632c82629fb963411b3c4500
c7ae4e2bb1da5aa48c2c410d68e10d917969ceb3
refs/heads/master
2021-01-13T09:36:28.493394
2016-12-20T06:52:27
2016-12-20T06:52:27
72,043,724
0
0
null
null
null
null
UTF-8
C++
false
false
692
cpp
Main.cpp
/* * File: main.cpp * Author: Jeremy Bickford * Course: CSCI 3110 * Instructor: Zhijiang Dong * Date: NOV 16 2016 * This is the client file that uses the class word check to search dictionary for near misses * */ #include "wordChecker.h" #include <string> #include <iostream> using namespace std; const string FileName = "dict.txt"; int main() { wordChecker dictionary(FileName); string input; while(true) { cout << "Enter a value to search: "; cin >> input; std::transform(input.begin(), input.end(), input.begin(), ::tolower);// makes input lower case dictionary.wordSearch(input); cout << endl; } system("PAUSE"); return 0; }
46cf9fd7e4edbdc010d1b48b2420b198e91c794f
eb0352be6f369ddcd7ae402220fc795fa02d09ca
/example/mergesort.cpp
18b3ab3babaf2c2389f4dae3ee9df1d2e9854c16
[]
no_license
deepsea-inria/pbbs-pctl
05b6a64bc532f91c0af0cb469f84b816cece1db1
d5c0f1337435d50231d55cae537c826c185b6a78
refs/heads/master
2021-01-24T08:41:05.659607
2018-01-29T16:11:17
2018-01-29T16:11:17
48,747,578
2
0
null
null
null
null
UTF-8
C++
false
false
1,364
cpp
mergesort.cpp
/*! * \file mergesort.cpp * \brief Example of parallel mergesort usage * \date 2015 * \copyright COPYRIGHT (c) 2015 Umut Acar, Arthur Chargueraud, and * Michael Rainey. All rights reserved. * \license This project is released under the GNU Public License. * */ #include "example.hpp" #include "psort.hpp" #include "io.hpp" /***********************************************************************/ namespace pasl { namespace pctl { void ex() { // parallel array std::cout << "-- parray -- " << std::endl; { parray<int> xs = { 3, 2, 100, 1, 0, -1, -3 }; std::cout << "xs\t\t\t=\t" << xs << std::endl; pasl::pctl::sort(xs.begin(), xs.end(), std::less<int>()); std::cout << "mergesort(xs)\t=\t" << xs << std::endl; } std::cout << std::endl; // parallel chunked sequence std::cout << "-- pchunkedseq -- " << std::endl; { pchunkedseq<int> xs = { 3, 2, 100, 1, 0, -1, -3 }; std::cout << "xs\t\t\t=\t" << xs << std::endl; std::cout << "mergesort(xs)\t=\t" << pchunked::sort(xs, std::less<int>()) << std::endl; } std::cout << std::endl; } } } /*---------------------------------------------------------------------*/ int main(int argc, char** argv) { pbbs::launch(argc, argv, [&] { pasl::pctl::ex(); }); return 0; } /***********************************************************************/
337cd80e9424b9db391aa05748325f53b029edf2
4155e1f592e56bbdbbcc2147b651e21aedb3fc8b
/src/main.cpp
4e068f4157f3b8f2e7bfee385cb68e05d7317b9c
[ "MIT" ]
permissive
DriftingTimmy/pcl-pole-detector
e03dd503dab7694bf44ac23b6ea58348c2d72fdf
e62702a2626ec7d908650d7ece364eb1828936cb
refs/heads/master
2021-01-25T08:01:41.990205
2017-01-27T14:05:29
2017-01-27T14:05:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,104
cpp
main.cpp
#include <pole_detector.h> int main(int argc, char const *argv[]) { if ( argc != 6 ) // argc should be 4 for correct execution cout<<"usage: "<< argv[0] <<" <path to pcd file> <ground clearance> <height threshold> <min cluster size> <cluster threshold>\n"; else { PCLPoleDetector* poleDetector = new PCLPoleDetector(); poleDetector->algorithmLanda(argv[1], atof(argv[2]), atof(argv[3]), atof(argv[4]), atof(argv[5])); //poleDetector->writePCD("output_pcd.pcd"); /* Testing MinMax3D function pcl::PointCloud<pcl::PointXYZ>::Ptr cloud; cloud = pcl::PointCloud<pcl::PointXYZ>::Ptr (new pcl::PointCloud<pcl::PointXYZ>); pcl::io::loadPCDFile<pcl::PointXYZ> (argv[1], *cloud); pcl::PointXYZ minPt, maxPt; pcl::getMinMax3D (*cloud, minPt, maxPt); std::cout << "Max x: " << maxPt.x << std::endl; std::cout << "Max y: " << maxPt.y << std::endl; std::cout << "Max z: " << maxPt.z << std::endl; std::cout << "Min x: " << minPt.x << std::endl; std::cout << "Min y: " << minPt.y << std::endl; std::cout << "Min z: " << minPt.z << std::endl; */ } return 0; }
144a8c3dded7cde4a3a60bcbffc144983161a789
fe225bb412f3b0c43abe1d257658e7f433346bbf
/apps/rtmp/RtmpAudio.cpp
a24ea707a99f4dfee48336c8e3a3b69a5592d414
[]
no_license
yeti-switch/sems
611f0bc8dfa381d5f8f15c47a7ce287a2e8366f1
f15ab5b638d7447883503d4939170067aba0f807
refs/heads/master
2023-08-18T23:09:58.940541
2023-08-16T19:37:19
2023-08-16T19:37:19
70,628,618
14
9
null
2018-04-02T10:10:05
2016-10-11T19:36:01
C++
WINDOWS-1252
C++
false
false
7,293
cpp
RtmpAudio.cpp
/* * Copyright (C) 2011 Raphael Coeffic * * This file is part of SEMS, a free SIP media server. * * SEMS is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. This program is released under * the GPL with the additional exemption that compiling, linking, * and/or using OpenSSL is allowed. * * For a license to use the SEMS software under conditions * other than those described here, or to purchase support for this * software, please contact iptel.org by e-mail at the following addresses: * info@iptel.org * * SEMS is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "RtmpAudio.h" #include "RtmpSender.h" #include "amci/codecs.h" #define SPEEX_WB_SAMPLES_PER_FRAME 320 #define SPEEX_WB_SAMPLE_RATE 16000 #include <fcntl.h> static void dump_audio(RTMPPacket *packet) { static int dump_fd=0; if(dump_fd == 0){ dump_fd = open("speex_in.raw",O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH); if(dump_fd < 0) ERROR("could not open speex_in.raw: %s",strerror(errno)); } if(dump_fd < 0) return; uint32_t pkg_size = packet->m_nBodySize-1; write(dump_fd,&pkg_size,sizeof(uint32_t)); write(dump_fd,packet->m_body+1,pkg_size); } static void dump_audio(unsigned char* buffer, unsigned int size) { static int dump_fd=0; if(dump_fd == 0){ dump_fd = open("pcm_in.raw",O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH); if(dump_fd < 0) ERROR("could not open pcm_in.raw: %s",strerror(errno)); } if(dump_fd < 0) return; write(dump_fd,buffer,size); } RtmpAudio::RtmpAudio(RtmpSender* s) : AmAudio(new AmAudioFormat(CODEC_SPEEX_WB,SPEEX_WB_SAMPLE_RATE)), playout_buffer(this,SPEEX_WB_SAMPLE_RATE), sender(s), play_stream_id(0), recv_offset_i(false), recv_rtp_offset(0), recv_rtmp_offset(0), send_offset_i(false), send_rtmp_offset(0) { } RtmpAudio::~RtmpAudio() { } // returns bytes read, else -1 if error (0 is OK) int RtmpAudio::get(unsigned long long system_ts, unsigned char* buffer, int output_sample_rate, unsigned int nb_samples) { // - buffer RTMP audio // - read from RTMP recv buffer unsigned int user_ts = scaleSystemTS(system_ts); //DBG("get(%u, %u)",user_ts,nb_samples); process_recv_queue(user_ts); nb_samples = (unsigned int)((float)nb_samples * (float)getSampleRate() / (float)output_sample_rate); u_int32_t size = PCM16_S2B(playout_buffer.read(user_ts, (ShortSample*)((unsigned char*)samples), nb_samples)); if(output_sample_rate != getSampleRate()) { size = resampleOutput((unsigned char*)samples, size, getSampleRate(), output_sample_rate); } memcpy(buffer,(unsigned char*)samples,size); return size; } // returns bytes written, else -1 if error (0 is OK) int RtmpAudio::put(unsigned long long system_ts, unsigned char* buffer, int input_sample_rate, unsigned int size) { if(!size){ return 0; } //dump_audio((unsigned char*)buffer,size); // copy into internal buffer memcpy((unsigned char*)samples,buffer,size); size = resampleInput((unsigned char*)samples, size, input_sample_rate, getSampleRate()); int s = encode(size); //DBG("s = %i",s); if(s<=0){ return s; } return send(scaleSystemTS(system_ts),(unsigned int)s); } int RtmpAudio::send(unsigned int user_ts, unsigned int size) { m_sender.lock(); if(!sender || !play_stream_id) { //DBG("!sender || !play_stream_id"); m_sender.unlock(); return 0; } // - generate a new RTMP audio packet // - send packet RTMPPacket packet; RTMPPacket_Reset(&packet); packet.m_headerType = send_offset_i ? RTMP_PACKET_SIZE_MEDIUM : RTMP_PACKET_SIZE_LARGE; packet.m_packetType = RTMP_PACKET_TYPE_AUDIO; packet.m_nChannel = 4;//TODO packet.m_nInfoField2 = play_stream_id; if(!send_offset_i){ send_rtmp_offset = user_ts; send_offset_i = true; } unsigned int rtmp_ts = (user_ts - send_rtmp_offset) / (SPEEX_WB_SAMPLE_RATE/1000); packet.m_nTimeStamp = rtmp_ts; RTMPPacket_Alloc(&packet,size+1); packet.m_nBodySize = size+1; // soundType (byte & 0x01) » 0 // 0: mono, 1: stereo // soundSize (byte & 0x02) » 1 // 0: 8-bit, 1: 16-bit // soundRate (byte & 0x0C) » 2 // 0: 5.5 kHz, 1: 11 kHz, 2: 22 kHz, 3: 44 kHz // soundFormat (byte & 0xf0) » 4 // 0: Uncompressed, 1: ADPCM, 2: MP3, 5: Nellymoser 8kHz mono, 6: Nellymoser, 11: Speex // 0xB2: speex, 16kHz packet.m_body[0] = 0xB2; memcpy(packet.m_body+1,(unsigned char*)samples,size); //DBG("sending audio packet: size=%u rtmp_ts=%u StreamID=%u (rtp_ts=%u)", // size+1,rtmp_ts,play_stream_id,user_ts); sender->push_back(packet); m_sender.unlock(); //dump_audio(&packet); RTMPPacket_Free(&packet); return size; } void RtmpAudio::bufferPacket(const RTMPPacket& p) { RTMPPacket np = p; if(!RTMPPacket_Alloc(&np,np.m_nBodySize)){ ERROR("could not allocate packet."); return; } memcpy(np.m_body,p.m_body,p.m_nBodySize); m_q_recv.lock(); q_recv.push(np); m_q_recv.unlock(); } void RtmpAudio::process_recv_queue(unsigned int ref_ts) { int size; // flush the recv queue into the playout buffer m_q_recv.lock(); while(!q_recv.empty()){ RTMPPacket p = q_recv.front(); q_recv.pop(); m_q_recv.unlock(); //TODO: // - copy RTMP payload into this->samples // - decode // - put packet in playout buffer if(p.m_nBodySize <= (unsigned int)AUDIO_BUFFER_SIZE){ size = p.m_nBodySize-1; memcpy((unsigned char*)samples, p.m_body+1, size); size = decode(size); if(size <= 0){ ERROR("decode() returned %i",size); return; } // TODO: generate some reasonable RTP timestamp // bool begin_talk = false; if(!recv_offset_i){ recv_rtp_offset = ref_ts; recv_rtmp_offset = p.m_nTimeStamp; recv_offset_i = true; begin_talk = true; } unsigned int rtp_ts = (p.m_nTimeStamp - recv_rtmp_offset) * (SPEEX_WB_SAMPLE_RATE/1000); playout_buffer.write(ref_ts, rtp_ts, (ShortSample*)((unsigned char *)samples), PCM16_B2S(size), begin_talk); RTMPPacket_Free(&p); } m_q_recv.lock(); } m_q_recv.unlock(); } void RtmpAudio::add_to_history(int16_t *, unsigned int) { return; } unsigned int RtmpAudio::conceal_loss(unsigned int, unsigned char *) { return 0; } void RtmpAudio::setSenderPtr(RtmpSender* s) { m_sender.lock(); DBG("sender ptr = %p",s); sender = s; m_sender.unlock(); } void RtmpAudio::setPlayStreamID(unsigned int stream_id) { m_sender.lock(); DBG("play_stream_id = %i",stream_id); play_stream_id = stream_id; m_sender.unlock(); }
5963cb1b91483920f677fe7aa8eae751f3511b7d
041c653b9f3f5271aebeaa8ba76fe31b1f6a5219
/cpp/Digihome_bridge/src/Led.cpp
21c412a69467000bfa0fcf930842dba585482300
[]
no_license
pac94/Digihome
dc4dd7e557bbc9aab9ff81f7b4e1743e78bc8d31
ed4f27058ee1f207610a8a536041e60edc64564b
refs/heads/master
2020-03-30T06:05:08.657522
2014-07-04T06:43:19
2014-07-04T06:43:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,329
cpp
Led.cpp
#include "../include/Led.h" #include "../include/Pin.h" #include <jsoncpp/json.h> Led::Led(string _room, int _Red_pin, int _Green_pin, int _Blue_pin):Equipement(_room, "led") { room = _room; red.Setnumber( _Red_pin); green.Setnumber( _Green_pin); blue.Setnumber( _Blue_pin); type = 1; } Led::~Led() { //dtor } void Led::allumer() { Set_led_color(1, 1, 1); } void Led::eteindre() { Set_led_color(0, 0, 0); } void Led::Set_led_color(int red_state, int green_state, int blue_state) { red.Setstate(red_state); green.Setstate(green_state); blue.Setstate(blue_state); } int Led::Get_led_color() { return (red.Getstate()*4) + (green.Getstate()*2) + (blue.Getstate()*1); } uint8_t Led::ToArduinoFormat(uint8_t * buff) { buff[0] = 0x7E; buff[1] = 0x07; buff[2] = 0x01; buff[3] = red.Getnumber(); buff[4] = red.Getstate(); buff[5] = green.Getnumber(); buff[6] = green.Getstate(); buff[7] = blue.Getnumber(); buff[8] = blue.Getstate(); buff[9] = 0xE7; return 10; } Json::Value Led::ToJsonFormat() { Json::Value led; led["sensor"] = "led"; int val = Get_led_color(); if(val <= 0) { led["color"] = 0; } else { led["color"] = val; } led["location"] = room; return led; }
a87b4a1656fcf7caa54edb4811132b896ac4728b
c3903103e3d78b835fe5ddf64eb9618a06b458f3
/10.Graphs/KruskalsMinimumSpanningTree.cpp
5e9a42b82721096298284b52de9ade4cb886cb74
[]
no_license
Cquential/Data-Structures-and-Algorithms
3e1f6202eb30b1d4966ea20de7f1cbdd36093e0d
a43254d1704de140bf77cad62d7768197e458639
refs/heads/master
2020-05-22T14:08:55.333805
2019-10-15T10:56:44
2019-10-15T10:56:44
186,378,378
0
2
null
2019-10-23T07:45:31
2019-05-13T08:32:35
C
UTF-8
C++
false
false
2,398
cpp
KruskalsMinimumSpanningTree.cpp
/* Amit Bansal - @amitbansal7 */ #include <bits/stdc++.h> #include <string> #define lli long long int #define llu unsigned long long int #define S(x) scanf("%d",&x) #define Sl(x) scanf("%lld",&x) #define Mset(p,i) memset(p,i,sizeof(p)) #define mlc(t,n) (t *)malloc(sizeof(t)*n) #define NIL -1 #define INF 0x3f3f3f3f #define TC int testcase; S(testcase); while(testcase--) #define Pi 3.14159 using namespace std; struct DisjointSet { int v; int *parent; int *rank; }; struct DisjointSet* CreateSet(int v) { struct DisjointSet* Set = (struct DisjointSet*)malloc(sizeof(struct DisjointSet)); Set->v = v; Set->parent = (int *)malloc(sizeof(int)*v); Set->rank = (int *)malloc(sizeof(int)*v); for(int i=0;i<v;i++) { Set->parent[i] = i; Set->rank[i] = 0; } return Set; } int find(int u,struct DisjointSet* Set) { if(u != Set->parent[u]) Set->parent[u] = find(Set->parent[u],Set); return Set->parent[u]; } void merge(int x,int y,struct DisjointSet* Set) { if(Set->rank[x] > Set->rank[y]) Set->parent[y] = x; else Set->parent[x] = y; if(Set->rank[x] == Set->rank[y]) Set->rank[y]++; } int KruskalMST(vector <pair<int ,pair<int, int> > > edges, int v) { int Minwt = 0; sort(edges.begin(),edges.end()); struct DisjointSet* Set = CreateSet(v); vector<pair<int,pair<int,int> > > ::iterator it; for(it = edges.begin();it != edges.end();it++) { int u = (*it).second.first; int v = (*it).second.second; int su = find(u,Set); int sv = find(v,Set); if(su!=sv) { Minwt += (*it).first; printf("%d - %d\n",u,v); merge(su,sv,Set); } } return Minwt; } int main() { int v = 9; vector <pair<int,pair<int,int> > > edges; edges.push_back(make_pair(4,make_pair(0,1))); edges.push_back(make_pair(8,make_pair(0,7))); edges.push_back(make_pair(8,make_pair(1,2))); edges.push_back(make_pair(11,make_pair(1,7))); edges.push_back(make_pair(7,make_pair(2,3))); edges.push_back(make_pair(2,make_pair(2,8))); edges.push_back(make_pair(4,make_pair(2,5))); edges.push_back(make_pair(9,make_pair(3,4))); edges.push_back(make_pair(14,make_pair(3,5))); edges.push_back(make_pair(10,make_pair(4,5))); edges.push_back(make_pair(2,make_pair(5,6))); edges.push_back(make_pair(1,make_pair(6,7))); edges.push_back(make_pair(6,make_pair(6,8))); edges.push_back(make_pair(7,make_pair(7,8))); printf("Minimum wieght of MST is %d\n",KruskalMST(edges,v)); }
be2339fb004e9484402a27f63eee075266f21baa
dc499607be7067801d0d8a4b3d8b90694d8a7e70
/hello_world_cpp/include/hello_world_cpp/parameter_component.hpp
831dc928fe9048f536a7a5a159059640bee33766
[ "BSD-2-Clause" ]
permissive
fjnkt98/hello_world
9ca82e0fd364ab3bec6f0f601e9ddd0dac87da28
095301082410a73ebee4a38970d04a2b9fcccae4
refs/heads/master
2021-07-10T02:32:56.779879
2020-11-24T04:13:10
2020-11-24T04:13:10
220,123,144
0
0
null
null
null
null
UTF-8
C++
false
false
771
hpp
parameter_component.hpp
#ifndef HELLO_WORLD_CPP_PARAMETER_COMPONENT_HPP_ #define HELLO_WORLD_CPP_PARAMETER_COMPONENT_HPP_ #include <string> #include <rclcpp/rclcpp.hpp> #include <std_msgs/msg/string.hpp> #include "hello_world_cpp/visibility.h" namespace hello_world_cpp { class Parameter : public rclcpp::Node{ public: HELLO_WORLD_CPP_PUBLIC explicit Parameter(const rclcpp::NodeOptions &options); private: std_msgs::msg::String msg_; rclcpp::Publisher<std_msgs::msg::String>::SharedPtr pub_; rclcpp::TimerBase::SharedPtr timer_; std::string decoration_; void publishMessage(); rcl_interfaces::msg::SetParametersResult parameterSetCallback(const std::vector<rclcpp::Parameter> params); }; } // namespace hello_world_cpp #endif
20f779357843aade0e647eaabcffe5fbb2d5aebe
71b6c8e28bdabf1876b110a8e08aad9a17780008
/DLL430_v3/src/TI/DLL430/logging/Logging.cpp
9b2cafa035297990f4ca816fb16aae2a609310e7
[]
no_license
BuLogics/libMSP430
bbae668a1df96e045b0d1e55e5e9aceda1354952
d949a8159e86dfaf0e1457682555b9278e0e48d2
refs/heads/master
2016-09-06T01:57:14.643076
2013-03-14T20:07:19
2013-03-14T20:07:19
8,761,493
16
21
null
null
null
null
UTF-8
C++
false
false
3,253
cpp
Logging.cpp
/* * Logging.cpp * * Copyright (C) 2007 - 2011 Texas Instruments Incorporated - http://www.ti.com/ * * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "Logging.h" #include <boost/date_time/posix_time/posix_time.hpp> //#define USE_STDOUT using namespace TI::DLL430::Logging; Debug& TI::DLL430::Logging::DefaultLogger() { static Debug defaultLogger; return defaultLogger; } Debug::Debug() : filePtr(stdout) { #ifndef USE_STDOUT filePtr = fopen("comm.log", "w"); #endif if (!filePtr) fprintf(stderr, "File could not be opened\n!"); } Debug::~Debug() { if (filePtr) fclose(filePtr); } void Debug::PrintSendBuffer(const uint8_t *buf, long size) { PrintBuffer(buf, size, "send:"); } void Debug::PrintReceiveBuffer(const uint8_t *buf, long size) { PrintBuffer(buf, size, "receive:"); } void Debug::PrintBuffer(const uint8_t *buf, long size, const char *direction) { if (filePtr) { std::stringstream sstr; sstr << "\n" << boost::posix_time::microsec_clock::local_time() << " " << direction << std::endl << "[" << std::hex; for (long i = 0 ; i < size; ++i) { sstr << std::setw(2) << std::setfill('0') << static_cast<unsigned int>(buf[i]); if (i != size -1) sstr << "]["; } sstr << "]" << std::endl << std::dec; fprintf(filePtr, "%s", sstr.str().c_str()); fflush(filePtr); } }
cd5ae46b2006a2a61c61070e2fa3ad31aa994cfe
0d1645e912fc1477eef73245a75af85635a31bd8
/sdk/vl/include/parser/vlbnf.hpp
d4e27655029ce8d63bda87659eda61e2c6593a4e
[ "MIT" ]
permissive
qianxj/XExplorer
a2115106560f771bc3edc084b7e986332d0e41f4
00e326da03ffcaa21115a2345275452607c6bab5
refs/heads/master
2021-09-03T13:37:39.395524
2018-01-09T12:06:29
2018-01-09T12:06:29
114,638,878
0
0
null
null
null
null
UTF-8
C++
false
false
1,664
hpp
vlbnf.hpp
#pragma once #include "../vl.h" #include "vldef.hpp" #include "vlsym.hpp" namespace vl { class vArrayMgr; class vlang3; //bnf manager class vlbnf { public: vlbnf(vlang3 * lv); ~vlbnf(); public: enum Field {arNameID , arTokenID, arKeywordID,arStmtID, arObjectID, arCount}; //lang array ,every element have fields nameid, tokenid,keywordid,stmtid,objectid //row 0 for save fields arrayid int m_arlang; //current parse lang index in m_arlang int m_langid; public: vArrayMgr* getArrayMgr(); int AddLang(tchar * p); public: int pushToken(tchar *p); //start from 1 const tchar* getToken(int id); //start from 1 int getToken(tchar *p); public: //get array id by item int getArName(bool make=true); int getArToken(bool make=true); int getArKeyword(bool make=true); int getArStmt(bool make=true); int getArObject(bool make=true); int getArItem(Field item, bool make=true); public: //make stmt id; int makeStmt(); //set stmt subject int pushStmtSubject(int stmt,int subjectId); //set stmt pred int pushStmtPred(int stmt,int predId); //set stmt object int pushStmtObject(int stmt,int objectId); int pushStmtObjectItemEof(int stmt); int pushStmtObjectStmtEof(int stmt); public: int AddTokenRef(int tokenid,int stmt,int objectid); int getTokenRef(int tokenid,int index,int &objectid); int getTokenRefCount(int tokenid,int &objectref); private: vlang3 * vlang_; public: vlang3 * getVlang(); void setVlang(vlang3 * v); public: int determine(int token,void * param,fnFetchData fetchData ,int arCalced); int determine(tchar* token,void * param,fnFetchData fetchData,int arCalced); }; }
a4bcb28aefc54ddcfe26b503d02dc279341cf7d1
bc9426aad7ac41817b9b3637ff68e11de99759e7
/src/utils/split_tets_on_edges.cpp
3fa3cb7685b448d4f593c1c2ee7f78c2232f6a9c
[]
no_license
ab1153/polycube
779af55dcbe4ac92311805c02a4c7b7a81c3b86b
b8a8b752360bc91f6eb9121e7d70df9c0b7b4bf1
refs/heads/master
2021-01-03T08:17:29.034876
2014-12-09T16:10:57
2014-12-09T16:10:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,739
cpp
split_tets_on_edges.cpp
#include "../tetmesh/tetmesh.h" #include "../tet_mesh_sxx/tet_mesh_sxx.h" int load_edge_file(const char * file, vector<pair<size_t,size_t> > & split_edges) { ifstream ifs(file); if(ifs.fail()){ cerr << "# [error] can not open edge file." << endl; return __LINE__; } size_t edge_num = 0; ifs >> edge_num; split_edges.clear(); pair<size_t,size_t> one_edge; for(size_t ei = 0; ei < edge_num; ++ei){ ifs >> one_edge.first >> one_edge.second; split_edges.push_back(one_edge); } return 0; } int split_tets_on_edges(int argc, char * argv[]) { using namespace zjucad::matrix; if(argc != 4 && argc != 6){ cerr << "# [usage] split_tets_on_edges input_tet input_edges_file output_tet [input_zyz] [output_zyz]" << endl; return __LINE__; } vector<pair<size_t,size_t> > split_edges; if(load_edge_file(argv[2], split_edges)){ return __LINE__; } sxx::tet_mesh stm; stm.create_tetmesh(argv[1]) ; for(const auto & one_edge : split_edges){ stm.split_edge(one_edge); } stm.write_tetmesh_to_file(argv[3]); if(argc == 6){ zjucad::matrix::matrix<size_t> new_tet; zjucad::matrix::matrix<double> new_node; stm.write_tetmesh_to_matrix(new_node, new_tet); zjucad::matrix::matrix<double> zyz; jtf::mesh::read_matrix(argv[4], zyz); zjucad::matrix::matrix<size_t> tet_map; stm.get_tet2orginal_index(new_tet, tet_map); zjucad::matrix::matrix<double> old_zyz = zyz; zyz.resize(3, new_tet.size(2)); for(size_t ti = 0; ti < new_tet.size(2); ++ti){ zyz(colon(),ti) = old_zyz(colon(), tet_map[ti]); } jtf::mesh::write_matrix(argv[5], zyz); } return 0; }
b4199517cb6cfceb449323d0be7ad93ee6f0d27c
f9b5ebcaa34fb78ea2da81a7a21b3f76605eab33
/ACM模板/最小生成树/Kruskal 算法模板(并查集) (Poj 1287 Networking ).cpp
0f6d81bde158779813ced8d505e2ad3aca441ac3
[]
no_license
jwhuseu/ACM
ab33de875e032b80354f82d9f80f98923ad942a5
b10f407996c04bb012daf566a7ab9d7cc1048623
refs/heads/master
2021-10-14T08:21:10.187719
2019-02-03T04:45:45
2019-02-03T04:45:45
null
0
0
null
null
null
null
GB18030
C++
false
false
1,538
cpp
Kruskal 算法模板(并查集) (Poj 1287 Networking ).cpp
//题目链接 : http://poj.org/problem?id=1287 //kruskal模板 #include <iostream> #include <stdio.h> #include <string.h> #include <vector> #include <algorithm> #include <queue> using namespace std; const int maxn = 1e5 + 10; int Fa[maxn],Rank[maxn]; void init(){ for(int i = 0; i <= maxn; i++)Fa[i] = i; for(int i = 0; i <= maxn; i++)Rank[i] = 1; } int Find(int v){ return Fa[v] == v ? v : Fa[v] = Find(Fa[v]); } void Union(int x, int y){ int fx = Find(x); int fy = Find(y); if (fx == fy)return; if (Rank[fx] < Rank[fy]) Fa[fx] = fy; else{ Fa[fy] = fx; if (Rank[fx] == Rank[fy])Rank[fy]++; } } struct Edge{ int u,v,w; Edge(){} Edge(int u,int v,int w):u(u),v(v),w(w){} }edge[maxn*2]; int cmp(const void *a,const void *b){ Edge *aa = (Edge*)a; Edge *bb = (Edge*)b; return aa->w > bb->w ? 1 : -1; //降序 } int krusal(int n,int m){ qsort(edge,m,sizeof(edge[0]),cmp); int ans = 0; int cnt = 0; for(int i = 0; i < m; i++){ int u = edge[i].u; int v = edge[i].v; if(Find(u) != Find(v)){ Union(u,v); cnt++; ans += edge[i].w; } if(cnt == n-1)break; } return ans; } int main(){ //freopen("in.txt","r",stdin); int n,m; while(~scanf("%d",&n)&&n){ scanf("%d",&m); init(); for(int i = 0; i < m; i++) scanf("%d%d%d",&edge[i].u,&edge[i].v,&edge[i].w); //注意这题有重边但是没事 printf("%d\n",krusal(n,m)); } return 0; }
a28a17ff7359a5246ad297ad7c43e247b87ef280
5af1594a6ac0b0c92072f7a710198721b5eb4a32
/001_qt_prj/OMS/sSystem/ControlDemo.cpp
9acd6d0af967e26d55b094bf3b767c5593e2556f
[]
no_license
ZhaoRui321/00_work
aabeea06ab0ff4a3cf93ec5117efa026c9bcf884
06ad82c244aa0518a4c9488f212bb02d425331ac
refs/heads/master
2020-08-17T17:43:32.606913
2020-03-13T03:16:54
2020-03-13T03:16:54
215,692,552
0
0
null
null
null
null
UTF-8
C++
false
false
2,212
cpp
ControlDemo.cpp
#include "ControlDemo.h" #include "ui_ControlDemo.h" #include <QPainter> ControlDemo::ControlDemo(QWidget *parent) : QWidget(parent), ui(new Ui::ControlDemo) { ui->setupUi(this); this->setAttribute(Qt::WA_TranslucentBackground); //this->setWindowFlags(Qt::FramelessWindowHint); ui->lineEdit->setStyleSheet("background-color: transparent;"); // "border-top: 2px solid white;" // "border-bottom: 2px solid white;"); ui->switchBtn->SetSize(220,80); setState(false); connect(ui->switchBtn,SIGNAL(clicked()),this,SLOT(on_clicked())); connect(ui->lineEdit,SIGNAL(textChanged(QString)),this,SLOT(on_LineEditChanged(QString))); } ControlDemo::~ControlDemo() { delete ui; } void ControlDemo::paintEvent(QPaintEvent *e) { QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); //反锯齿 //painter.setBrush(QBrush(Qt::white)); painter.setPen(Qt::white); QRect rect = this->rect(); rect.setWidth(rect.width()-1); rect.setHeight(rect.height()-1); painter.drawRoundedRect(rect,30,30); QWidget::paintEvent(e); } void ControlDemo::setTitle(QString str) { ui->label->setText(str); } void ControlDemo::setDescription(QString str) { ui->descriptLaber->setText(str); } void ControlDemo::setLineEdit(QString num) { ui->lineEdit->setText(num); } void ControlDemo::on_clicked() { emit stateChange(); } int ControlDemo::getState() { if(ui->switchBtn->IsSelected()) return 1; else return 0; } void ControlDemo::setState(bool state) { ui->switchBtn->SetSelected(state); } void ControlDemo::setEnabled(bool state) { ui->switchBtn->SetEnabel(state); } void ControlDemo::on_LineEditChanged(QString text) { if(text.toDouble() < rangeInput[0]) ui->lineEdit->setText(QString::number(rangeInput[0])); if(text.toDouble() > rangeInput[1]) ui->lineEdit->setText(QString::number(rangeInput[1])); ui->switchBtn->SetSelected(false); } QString ControlDemo::getValue() { return ui->lineEdit->text(); }
255c48b4d6217882c25d9242faef3ed9224210d5
dd6147bf9433298a64bbceb7fdccaa4cc477fba6
/[8304] SaniZayyad/sanizayyad_lab1/sources/LogicService/mediator.cpp
695d83b2af56a9165de0dbdf7a802fce778f8454
[]
no_license
moevm/oop
64a89677879341a3e8e91ba6d719ab598dcabb49
faffa7e14003b13c658ccf8853d6189b51ee30e6
refs/heads/master
2023-03-16T15:48:35.226647
2020-06-08T16:16:31
2020-06-08T16:16:31
85,785,460
42
304
null
2023-03-06T23:46:08
2017-03-22T04:37:01
C++
UTF-8
C++
false
false
1,908
cpp
mediator.cpp
#include "mediator.hpp" #include "BattleField.hpp" #include "unit.hpp" Mediator::Mediator(std::shared_ptr<BattleField> battleField) { this->battleField = battleField; } bool Mediator::notify(std::shared_ptr<Unit> unit,const std::string& action) { Position2D currentPosition = unit->getPosition(); FieldCell& currentCell = battleField->getFieldCell(currentPosition); Position2D nextPoint = currentPosition; if (action == MOVE_TOP) { nextPoint.y--; if (nextPoint.y < 0) { return false; } FieldCell& nextCell = battleField->getFieldCell(nextPoint); if (nextCell.isEmpty()) { nextCell.addUnit(unit); currentCell.deleteUnit(); return true; } } else if (action == MOVE_LEFT) { nextPoint.x--; if (nextPoint.x < 0) { return false; } FieldCell& nextCell = battleField->getFieldCell(nextPoint); if (nextCell.isEmpty()) { nextCell.addUnit(unit); currentCell.deleteUnit(); return true; } } else if (action == MOVE_RIGHT) { nextPoint.x++; if (nextPoint.x >= static_cast<int>(battleField->getWidth())) { return false; } FieldCell& nextCell = battleField->getFieldCell(nextPoint); if (nextCell.isEmpty()) { nextCell.addUnit(unit); currentCell.deleteUnit(); return true; } } else if (action == MOVE_BOTTOM) { nextPoint.y++; if (nextPoint.y >= static_cast<int>(battleField->getHeight())) { return false; } FieldCell& nextCell = battleField->getFieldCell(nextPoint); if (nextCell.isEmpty()) { nextCell.addUnit(unit); currentCell.deleteUnit(); return true; } } return false; }
1b04e37afb62ceeb2d8bc4502fff39c5dea2f625
3ae80dbc18ed3e89bedf846d098b2a98d8e4b776
/header/Map/WebMapTileServiceSource.h
5d7f26059eb6abd5020e0889358274c5cf8d9edc
[]
no_license
sswroom/SClass
deee467349ca249a7401f5d3c177cdf763a253ca
9a403ec67c6c4dfd2402f19d44c6573e25d4b347
refs/heads/main
2023-09-01T07:24:58.907606
2023-08-31T11:24:34
2023-08-31T11:24:34
329,970,172
10
7
null
null
null
null
UTF-8
C++
false
false
4,630
h
WebMapTileServiceSource.h
#ifndef _SM_MAP_WEBMAPTILESERVICESOURCE #define _SM_MAP_WEBMAPTILESERVICESOURCE #include "Data/ArrayList.h" #include "Data/ArrayListNN.h" #include "Data/FastStringMap.h" #include "Map/TileMap.h" #include "Net/SocketFactory.h" #include "Text/String.h" #include "Text/XMLReader.h" namespace Map { class WebMapTileServiceSource : public Map::TileMap { private: enum ResourceType { Unknown, Tile, FeatureInfo }; struct TileMatrix { NotNullPtr<Text::String> id; Int32 minRow; Int32 maxRow; Int32 minCol; Int32 maxCol; }; struct ResourceURL { NotNullPtr<Text::String> templateURL; ResourceType resourceType; NotNullPtr<Text::String> format; Map::TileMap::ImageType imgType; }; struct TileMatrixSet { Math::RectAreaDbl bounds; NotNullPtr<Text::String> id; Math::CoordinateSystem *csys; Data::ArrayList<TileMatrix*> tiles; }; struct TileMatrixDef { Math::Coord2DDbl origin; NotNullPtr<Text::String> id; Double scaleDenom; Double unitPerPixel; UInt32 tileWidth; UInt32 tileHeight; UInt32 matrixWidth; UInt32 matrixHeight; }; struct TileMatrixDefSet { Text::String *id; Math::CoordinateSystem *csys; Data::ArrayList<TileMatrixDef*> tiles; }; struct TileLayer { Math::RectAreaDbl wgs84Bounds; Text::String *title; Text::String *id; Data::ArrayListNN<Text::String> format; Data::ArrayListNN<Text::String> infoFormat; Data::ArrayList<TileMatrixSet*> tileMatrixes; Data::ArrayList<ResourceURL*> resourceURLs; }; private: Text::EncodingFactory *encFact; NotNullPtr<Text::String> wmtsURL; NotNullPtr<Text::String> cacheDir; NotNullPtr<Net::SocketFactory> sockf; Net::SSLEngine *ssl; Data::FastStringMap<TileLayer*> layers; TileLayer *currLayer; TileMatrixSet *currSet; TileMatrixDefSet *currDef; ResourceURL *currResource; ResourceURL *currResourceInfo; Math::CoordinateSystem *wgs84; Data::FastStringMap<TileMatrixDefSet*> matrixDef; void LoadXML(); void ReadLayer(NotNullPtr<Text::XMLReader> reader); TileMatrixSet *ReadTileMatrixSetLink(NotNullPtr<Text::XMLReader> reader); TileMatrixDefSet *ReadTileMatrixSet(NotNullPtr<Text::XMLReader> reader); TileMatrix *GetTileMatrix(UOSInt level) const; void ReleaseLayer(TileLayer *layer); void ReleaseTileMatrix(TileMatrix *tileMatrix); void ReleaseTileMatrixSet(TileMatrixSet *set); void ReleaseTileMatrixDef(TileMatrixDef *tileMatrix); void ReleaseTileMatrixDefSet(TileMatrixDefSet *set); void ReleaseResourceURL(ResourceURL *resourceURL); public: WebMapTileServiceSource(NotNullPtr<Net::SocketFactory> sockf, Net::SSLEngine *ssl, Text::EncodingFactory *encFact, Text::CString wmtsURL); virtual ~WebMapTileServiceSource(); virtual Text::CString GetName(); virtual Bool IsError(); virtual TileType GetTileType(); virtual UOSInt GetLevelCount(); virtual Double GetLevelScale(UOSInt level); virtual UOSInt GetNearestLevel(Double scale); virtual UOSInt GetConcurrentCount(); virtual Bool GetBounds(Math::RectAreaDbl *bounds); virtual Math::CoordinateSystem *GetCoordinateSystem(); virtual Bool IsMercatorProj(); virtual UOSInt GetTileSize(); virtual Bool CanQuery() const; virtual Bool QueryInfos(Math::Coord2DDbl coord, UOSInt level, Data::ArrayList<Math::Geometry::Vector2D*> *vecList, Data::ArrayList<UOSInt> *valueOfstList, Data::ArrayListNN<Text::String> *nameList, Data::ArrayList<Text::String*> *valueList) const; virtual UOSInt GetTileImageIDs(UOSInt level, Math::RectAreaDbl rect, Data::ArrayList<Math::Coord2D<Int32>> *ids); virtual Media::ImageList *LoadTileImage(UOSInt level, Math::Coord2D<Int32> tileId, Parser::ParserList *parsers, Math::RectAreaDbl *bounds, Bool localOnly); virtual UTF8Char *GetTileImageURL(UTF8Char *sbuff, UOSInt level, Math::Coord2D<Int32> tileId); virtual IO::StreamData *LoadTileImageData(UOSInt level, Math::Coord2D<Int32> tileId, Math::RectAreaDbl *bounds, Bool localOnly, ImageType *it); Bool SetLayer(UOSInt index); Bool SetMatrixSet(UOSInt index); Bool SetResourceTileType(UOSInt index); Bool SetResourceInfoType(UOSInt index); Bool SetResourceInfoType(Text::CString name); UOSInt GetResourceInfoType(); UOSInt GetLayerNames(Data::ArrayList<Text::String*> *layerNames); UOSInt GetMatrixSetNames(Data::ArrayListNN<Text::String> *matrixSetNames); UOSInt GetResourceTileTypeNames(Data::ArrayListNN<Text::String> *resourceTypeNames); UOSInt GetResourceInfoTypeNames(Data::ArrayListNN<Text::String> *resourceTypeNames); static Text::CString GetExt(Map::TileMap::ImageType imgType); }; } #endif
de24652289e9359851b4216727e6f6dfdd3482d7
1583bc33ca5bb0d53f630ff250ea546d534c9063
/URI/Iniciante/1131.cpp
f08296f1839c43f0de49de476988febbf98e0cb8
[]
no_license
wiltonsr/TEP
dd5e49cb5dce3f4956a7cd783c33ac30718c92d1
50c8aa38f83307773cf579c1c94f17f0e7f28043
refs/heads/master
2020-12-13T10:13:44.818770
2016-04-16T12:59:49
2016-04-16T13:00:32
54,789,303
1
0
null
null
null
null
UTF-8
C++
false
false
654
cpp
1131.cpp
#include<bits/stdc++.h> using namespace std; int main(){ int i, g, o = 1, t = 0, vi = 0, vg = 0, e = 0; while(o == 1){ cin >> i >> g; if ( i > g) vi += 1; else if (g > i) vg += 1; else e += 1; t += 1; cout << "Novo grenal (1-sim 2-nao)" << endl; while ((cin >> o) && o != 1 && o != 2){ cout << "Novo grenal (1-sim 2-nao)" << endl; } } cout << t << " grenais" << endl; cout << "Inter:" << vi << endl; cout << "Gremio:" << vg << endl; cout << "Empates:" << e << endl; if (vi > vg) cout << "Inter venceu mais" << endl; else if (vg > vi) cout << "Gremio venceu mais" << endl; else cout << "Nao houve vencedor" << endl; return 0; }
5bd16a9b4e7efc1f3ccaf8413313ea77fe731c61
0370b81e9ec3f1b1d4bf0da224a613ff576e8dd4
/AOJ/AOJ_562.cpp
35cbd0a143e75808db5a5e946dc6d806cca56aba
[]
no_license
Rolight/ACM_ICPC
c511bc58ac5038ca521bb500a40fcbdf5468832d
6208a20ea66a42b4a06249d97494c77f55121847
refs/heads/master
2021-01-10T22:08:48.336023
2015-07-17T21:46:48
2015-07-17T21:46:48
27,808,805
2
0
null
null
null
null
UTF-8
C++
false
false
198
cpp
AOJ_562.cpp
#include <iostream> #include <cstdio> using namespace std; int main() { int n,m; cin >> n; for(int i = 0;i < n;i++) { cin >> m; printf("%.6f\n",2.0 / (double)m / (m - 1)); } return 0; }
ccde849824558316f284b0fb3315c0c8d1d4468f
5ac688d8b5c7ad6540f52c9f4c304e506d7564c5
/Fundamentals/&operator.cpp
df6793fafcd962819c0d028734f91b9123621b89
[]
no_license
Sana-Gupta/Cplusplus
9a02924f566cbb745a2b68176fbd2cf40684c7f2
d4ca9cf09bedfbb7516b665a890cc20f4380930a
refs/heads/master
2022-02-14T14:44:14.235284
2019-07-23T18:07:45
2019-07-23T18:07:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
675
cpp
&operator.cpp
/* Program to demonstrate the working of the Adress of(&) operator */ #include<iostream> using namespace std; int main(){ int x = 10; cout << &x << endl; //output is a hexadecimal float y = 10; cout << &y << endl; //output is a hexadecimal number char ch = 'A'; cout << &ch << endl; //output is a character because of operator overloading (<< is at fault here) //to get rid of this problem, we change the datatype of the variable ch. //operator overloading won't happen if the 'cout <<' operator doesn't know its a char variable. cout << (void *)&ch << endl; //explicit type conversion //output is a hexadecimal number return 0; }
2e01ea2b9094bfecf60437847083711e623ff112
4e38faaa2dc1d03375010fd90ad1d24322ed60a7
/include/RED4ext/Scripting/Natives/Generated/ink/GradientWidget.hpp
f60f605f61b9a71e016798fac3284991a7c5278e
[ "MIT" ]
permissive
WopsS/RED4ext.SDK
0a1caef8a4f957417ce8fb2fdbd821d24b3b9255
3a41c61f6d6f050545ab62681fb72f1efd276536
refs/heads/master
2023-08-31T08:21:07.310498
2023-08-18T20:51:18
2023-08-18T20:51:18
324,193,986
68
25
MIT
2023-08-18T20:51:20
2020-12-24T16:17:20
C++
UTF-8
C++
false
false
996
hpp
GradientWidget.hpp
#pragma once // clang-format off // This file is generated from the Game's Reflection data #include <cstdint> #include <RED4ext/Common.hpp> #include <RED4ext/Scripting/Natives/Generated/HDRColor.hpp> #include <RED4ext/Scripting/Natives/Generated/ink/BaseShapeWidget.hpp> #include <RED4ext/Scripting/Natives/Generated/ink/GradientMode.hpp> namespace RED4ext { namespace ink { struct GradientWidget : ink::BaseShapeWidget { static constexpr const char* NAME = "inkGradientWidget"; static constexpr const char* ALIAS = "inkGradient"; ink::GradientMode gradientMode; // 230 uint8_t unk231[0x234 - 0x231]; // 231 float angle; // 234 uint8_t unk238[0x240 - 0x238]; // 238 HDRColor startColor; // 240 HDRColor endColor; // 250 uint8_t unk260[0x270 - 0x260]; // 260 }; RED4EXT_ASSERT_SIZE(GradientWidget, 0x270); } // namespace ink using inkGradientWidget = ink::GradientWidget; using inkGradient = ink::GradientWidget; } // namespace RED4ext // clang-format on
df182dbb4d2cb1cb2f069c24e476ed2aa24ff7f8
476a358a2e1d0a70c061582090ff40d9f84b53e1
/src/shared/ai/Point.cpp
fd932ea027de7b2d3ce6e51e76dcd560abf972af
[]
no_license
luigcapo/capochichiboinali
c9a8a6dd585da5666606eb1812fe0a9075d438a2
10c9404833e3319e889cbe022aa730341e9577d0
refs/heads/master
2021-09-04T20:15:47.175844
2018-01-22T03:43:04
2018-01-22T03:43:04
104,048,104
0
0
null
null
null
null
UTF-8
C++
false
false
1,579
cpp
Point.cpp
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ #include "Point.h" namespace ai{ Point::Point(int x, int y, int w): x(x), y(y), weight(w) { } int Point::getWeight() const { return this->weight; } void Point::setWeight(int weight) { this->weight = weight; } int Point::getX() const { return this->x; } int Point::getY() const { return this->y; } void Point::setX(int x) { this->x = x; } void Point::setY(int y) { this->y = y; } Point Point::transform(state::Direction d) { switch (d) { case state::Direction::EAST : return Point(x+1, y, weight); case state::Direction::NORTH : return Point(x, y-1, weight); case state::Direction::NORTH_EAST : return Point(x+1, y-1, weight); case state::Direction::NORTH_WEST : return Point(x-1, y-1, weight); case state::Direction::SOUTH : return Point(x, y+1, weight); case state::Direction::SOUTH_EAST : return Point(x+1, y+1, weight); case state::Direction::SOUTH_WEST : return Point(x-1, y+1, weight); case state::Direction::WEST : return Point(x-1, y, weight); default : return Point(x, y, weight); } } }
d84f90e29f8f1859623227a8117e757a44a84398
e54b9ff5eaf41ab13d156430554077f133b1be06
/leetcode48/leetcode48_1.cpp
2c9f741be308ecf56cc72a89bc395d20ef337d5b
[]
no_license
allpasscool/leetcodes
bb0bd1391d5201baad214e5b4f8089dfe9c782b0
4fd81b4cf9382890cadc6bf8def721cc25eb9949
refs/heads/master
2022-05-21T11:34:06.958063
2022-03-24T08:57:41
2022-03-24T08:57:41
163,725,766
0
0
null
null
null
null
UTF-8
C++
false
false
811
cpp
leetcode48_1.cpp
class Solution { public: void rotate(vector<vector<int>>& matrix) { int n = matrix.size(); if (n <= 1) { return; } // transpose matrix for (int i = 0; i < n; i++) { for (int j = i; j < n; j++) { swap(matrix[i][j], matrix[j][i]); } } // reverse each row for (int i = 0; i < n; i++) { for (int j = 0; j < n / 2; j++) { swap(matrix[i][j], matrix[i][n - 1 - j]); } } return; } }; // Runtime: 4 ms, faster than 81.62% of C++ online submissions for Rotate Image. // Memory Usage: 9.1 MB, less than 58.54% of C++ online submissions for Rotate Image. // time complexity: O(n^2) // space complexity: O(1)
c96bea2c5ce5cea62c7a5448da0c00dbec2c5fd0
08b8cf38e1936e8cec27f84af0d3727321cec9c4
/data/crawl/wget/new_hunk_631.cpp
7b03453e23a1b316de26c751fdeecd20264f0429
[]
no_license
ccdxc/logSurvey
eaf28e9c2d6307140b17986d5c05106d1fd8e943
6b80226e1667c1e0760ab39160893ee19b0e9fb1
refs/heads/master
2022-01-07T21:31:55.446839
2018-04-21T14:12:43
2018-04-21T14:12:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
898
cpp
new_hunk_631.cpp
i++; } printf ("\n"); } printf ("\n"); /* Handle the case when $WGETRC is unset and $HOME/.wgetrc is absent. */ printf ("%s\n", wgetrc_title); env_wgetrc = wgetrc_env_file_name (); if (env_wgetrc && *env_wgetrc) { printf (" %s (env)\n", env_wgetrc); xfree (env_wgetrc); } user_wgetrc = wgetrc_user_file_name (); if (user_wgetrc) { printf (" %s (user)\n", user_wgetrc); xfree (user_wgetrc); } #ifdef SYSTEM_WGETRC printf (" %s (system)\n", SYSTEM_WGETRC); #endif format_and_print_line (locale_title, LOCALEDIR, MAX_CHARS_PER_LINE); format_and_print_line (compile_title, compilation_string, MAX_CHARS_PER_LINE); format_and_print_line (link_title, link_string, MAX_CHARS_PER_LINE); printf ("\n"); /* TRANSLATORS: When available, an actual copyright character
22f3011b544a007f9e8dc03fdf5558f052974f8d
2cae2bb328eb6f92ffc5a54ac8c4fb535677176d
/example/ios/mars.framework/Headers/xlog/preprocessor.h
c414a78f15043b09635dc0b9ab8e1ce2a90617b5
[ "MIT" ]
permissive
EngsShi/react-native-xlog
8683fb94f6d62cd467aa21e4b24912322893b250
3a5949f405a063cf7c9ed1b8f2685d2c6c9313b7
refs/heads/master
2023-03-27T03:53:25.702322
2018-06-04T11:46:19
2018-06-04T11:46:19
78,167,744
56
8
MIT
2018-06-04T11:46:20
2017-01-06T02:48:40
Java
UTF-8
C++
false
false
26,968
h
preprocessor.h
// Tencent is pleased to support the open source community by making Mars available. // Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. // Licensed under the MIT License (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License at // http://opensource.org/licenses/MIT // Unless required by applicable law or agreed to in writing, software distributed under the License is // distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, // either express or implied. See the License for the specific language governing permissions and // limitations under the License. /* ============================================================================ Name : preprocessor.h Author : 范亮亮 Version : 1.0 Created on : 2010-4-18 Copyright : Copyright (C) 1998 - 2009 TENCENT Inc. All Right Reserved Description: ============================================================================ */ #ifndef PREPROCESSOR_H_ #define PREPROCESSOR_H_ #define PP_EMPTY() #define PP_COMMA() , // PP_CAT #define PP_CAT(x, y) PP_CAT_I(x, y) #define PP_CAT_I(x, y) PP_CAT_II(x, y) #define PP_CAT_II(x, y) x##y // PP_ERROR #define PP_ERROR(code) PP_CAT(PP_ERROR_, code) #define PP_ERROR_0x0000 PP_ERROR(0x0000, PP_INDEX_OUT_OF_BOUNDS) #define PP_ERROR_0x0001 PP_ERROR(0x0001, PP_PP_WHILE_OVERFLOW) #define PP_ERROR_0x0002 PP_ERROR(0x0002, PP_FOR_OVERFLOW) #define PP_ERROR_0x0003 PP_ERROR(0x0003, PP_REPEAT_OVERFLOW) #define PP_ERROR_0x0004 PP_ERROR(0x0004, PP_LIST_FOLD_OVERFLOW) #define PP_ERROR_0x0005 PP_ERROR(0x0005, PP_SEQ_FOLD_OVERFLOW) #define PP_ERROR_0x0006 PP_ERROR(0x0006, PP_ARITHMETIC_OVERFLOW) #define PP_ERROR_0x0007 PP_ERROR(0x0007, PP_DIVISION_BY_ZERO) // PP_BOOL #define PP_BOOL(x) PP_BOOL_I(x) #define PP_BOOL_I(x) PP_BOOL_II(x) #define PP_BOOL_II(x) PP_BOOL_##x #define PP_BOOL_0 0 #define PP_BOOL_1 1 #define PP_BOOL_2 1 #define PP_BOOL_3 1 #define PP_BOOL_4 1 #define PP_BOOL_5 1 #define PP_BOOL_6 1 #define PP_BOOL_7 1 #define PP_BOOL_8 1 #define PP_BOOL_9 1 #define PP_BOOL_10 1 #define PP_BOOL_11 1 #define PP_BOOL_12 1 #define PP_BOOL_13 1 #define PP_BOOL_14 1 #define PP_BOOL_15 1 #define PP_BOOL_16 1 // PP_BITNOT #define PP_BITNOT(x) PP_BITNOT_I(x) #define PP_BITNOT_I(x) PP_NOT_##x #define PP_NOT_0 1 #define PP_NOT_1 0 // PP_BITAND #define PP_BITAND(x, y) PP_BITAND_I(x, y) #define PP_BITAND_I(x, y) PP_BITAND_##x##y #define PP_BITAND_00 0 #define PP_BITAND_01 0 #define PP_BITAND_10 0 #define PP_BITAND_11 1 // PP_BITOR #define PP_BITOR(x, y) PP_BITOR_I(x, y) #define PP_BITOR_I(x, y) PP_BITOR_##x##y #define PP_BITOR_00 0 #define PP_BITOR_01 1 #define PP_BITOR_10 1 #define PP_BITOR_11 1 // PP_BITXOR #define PP_BITXOR(x, y) PP_BITXOR_I(x, y) #define PP_BITXOR_I(x, y) PP_BITXOR_##x##y #define PP_BITXOR_00 0 #define PP_BITXOR_01 1 #define PP_BITXOR_10 1 #define PP_BITXOR_11 0 // PP_NOT #define PP_NOT(x) PP_BITNOT(PP_BOOL(x)) // PP_AND #define PP_AND(p, q) PP_BITAND(PP_BOOL(p), PP_BOOL(q)) // PP_OR #define PP_OR(p, q) PP_BITOR(PP_BOOL(p), PP_BOOL(q)) // PP_XOR #define PP_XOR(p, q) PP_BITXOR(PP_BOOL(p), PP_BOOL(q)) // PP_IF #define PP_IF(cond, t, f) PP_IF_I(PP_BOOL(cond), t, f) #define PP_IF_I(b, t, f) PP_IF_II(b, t, f) #define PP_IF_II(b, t, f) PP_IF_##b(t, f) #define PP_IF_0(t, f) f #define PP_IF_1(t, f) t // PP_COMMA_IF #define PP_COMMA_IF(cond) PP_IF(cond, PP_COMMA, PP_EMPTY)() // PP_ENUM #define PP_ENUM(count, param) PP_ENUM_REPEAT(count, PP_ENUM_M, param) #define PP_ENUM_M(n, text) PP_COMMA_IF(n) text // PP_NARG #define PP_RSEQ_N() 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 #define PP_ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, N, ...) N // #ifdef __GNUC__ // #define PP_NARG(...) PP_NARG_(__VA_ARGS__, PP_RSEQ_N()) // #define PP_NARG_(...) PP_ARG_N(__VA_ARGS__) // for all compiler // #elif defined _MSC_VER #define PP_NARG(...) PP_NARG_ ( __VA_ARGS__, PP_RSEQ_N() ) #define PP_NARG_(...) PP_ARG_N PP_BRACKET_L() __VA_ARGS__ PP_BRACKET_R() #define PP_BRACKET_L() ( #define PP_BRACKET_R() ) // #else // #error "no supported!!" // #endif #define PP_NUM_PARAMS(...) PP_IF(PP_DEC(PP_NARG(__VA_ARGS__)), PP_NARG(__VA_ARGS__), PP_NUM_PARAMS_0_1_TEST(__VA_ARGS__)) #define PP_NUM_PARAMS_0_1_TEST(_1, ...) PP_IF(PP_DEC(PP_NARG(PP_NUM_PARAMS_0 _1 ())), 0, 1) #define PP_NUM_PARAMS_0() , #if 0 #define P00_ARG( \ _1, _2, _3, _4, _5, _6, _7, _8, \ _9, _10, _11, _12, _13, _14, _15, _16, \ _17, _18, _19, _20, _21, _22, _23, _24, \ _25, _26, _27, _28, _29, _30, _31, _32, \ _33, _34, _35, _36, _37, _38, _39, _40, \ _41, _42, _43, _44, _45, _46, _47, _48, \ _49, _50, _51, _52, _53, _54, _55, _56, \ _57, _58, _59, _60, _61, _62, _63, _64, \ _65, _66, _67, _68, _69, _70, _71, _72, \ _73, _74, _75, _76, _77, _78, _79, _80, \ _81, _82, _83, _84, _85, _86, _87, _88, \ _89, _90, _91, _92, _93, _94, _95, _96, \ _97, _98, _99, _100, _101, _102, _103, _104, \ _105, _106, _107, _108, _109, _110, _111, _112, \ _113, _114, _115, _116, _117, _118, _119, _120, \ _121, _122, _123, _124, _125, _126, _127, _128, \ _129, _130, _131, _132, _133, _134, _135, _136, \ _137, _138, _139, _140, _141, _142, _143, _144, \ _145, _146, _147, _148, _149, _150, _151, _152, \ _153, _154, _155, _156, _157, _158, _159, \ ...) _159 #define P99_HAS_COMMA(...) P00_ARG(__VA_ARGS__, \ 1, 1, 1, 1, 1, 1, 1, \ 1, 1, 1, 1, 1, 1, 1, 1, \ 1, 1, 1, 1, 1, 1, 1, 1, \ 1, 1, 1, 1, 1, 1, 1, 1, \ 1, 1, 1, 1, 1, 1, 1, 1, \ 1, 1, 1, 1, 1, 1, 1, 1, \ 1, 1, 1, 1, 1, 1, 1, 1, \ 1, 1, 1, 1, 1, 1, 1, 1, \ 1, 1, 1, 1, 1, 1, 1, 1, \ 1, 1, 1, 1, 1, 1, 1, 1, \ 1, 1, 1, 1, 1, 1, 1, 1, \ 1, 1, 1, 1, 1, 1, 1, 1, \ 1, 1, 1, 1, 1, 1, 1, 1, \ 1, 1, 1, 1, 1, 1, 1, 1, \ 1, 1, 1, 1, 1, 1, 1, 1, \ 1, 1, 1, 1, 1, 1, 1, 1, \ 1, 1, 1, 1, 1, 1, 1, 1, \ 1, 1, 1, 1, 1, 1, 1, 1, \ 1, 1, 1, 1, 1, 1, 1, 1, \ 1, 1, 1, 1, 1, 1, 0, 0) #endif // PP_ENUM_PARAMS #define PP_ENUM_PARAMS(count, param) PP_ENUM_REPEAT(count, PP_ENUM_PARAMS_M, param) #define PP_ENUM_PARAMS_M(n, text) PP_COMMA_IF(n) text##n // PP_ENUM_BINARY_PARAMS #define PP_ENUM_BINARY_PARAMS(count, a, b) PP_ENUM_BINARY_REPEAT(count, PP_ENUM_BINARY_PARAMS_M, a, b) #define PP_ENUM_BINARY_PARAMS_M(n, a, b) PP_ENUM_BINARY_PARAMS_M_I(n, a, b) #define PP_ENUM_BINARY_PARAMS_M_I(n, a, b) PP_COMMA_IF(n) a##n b##n // PP_ENUM_TRAILING #define PP_ENUM_TRAILING(count, param) PP_ENUM_REPEAT(count, PP_ENUM_TRAILING_M, param) #define PP_ENUM_TRAILING_M(n, text) , text // PP_ENUM_TRAILING_PARAMS #define PP_ENUM_TRAILING_PARAMS(count, param) PP_ENUM_REPEAT(count, PP_ENUM_TRAILING_PARAMS_M, param) #define PP_ENUM_TRAILING_PARAMS_M(n, text) , text##n // PP_ENUM_TRAILING_BINARY_PARAMS #define PP_ENUM_TRAILING_BINARY_PARAMS(count, a, b) PP_ENUM_BINARY_REPEAT(count, PP_ENUM_TRAILING_BINARY_PARAMS_M, a, b) #define PP_ENUM_TRAILING_BINARY_PARAMS_M(n, a, b) PP_ENUM_TRAILING_BINARY_PARAMS_M_I(n, a, b) #define PP_ENUM_TRAILING_BINARY_PARAMS_M_I(n, a, b) , a##n b##n // PP_ENUM_REPEAT #define PP_ENUM_REPEAT(count, macro, data) PP_ENUM_REPEAT_I(count, macro, data) #define PP_ENUM_REPEAT_I(count, macro, data) PP_ENUM_REPEAT_##count(macro, data) #define PP_ENUM_REPEAT_0(macro, data) #define PP_ENUM_REPEAT_1(macro, data) PP_ENUM_REPEAT_0(macro, data)macro(0, data) #define PP_ENUM_REPEAT_2(macro, data) PP_ENUM_REPEAT_1(macro, data)macro(1, data) #define PP_ENUM_REPEAT_3(macro, data) PP_ENUM_REPEAT_2(macro, data)macro(2, data) #define PP_ENUM_REPEAT_4(macro, data) PP_ENUM_REPEAT_3(macro, data)macro(3, data) #define PP_ENUM_REPEAT_5(macro, data) PP_ENUM_REPEAT_4(macro, data)macro(4, data) #define PP_ENUM_REPEAT_6(macro, data) PP_ENUM_REPEAT_5(macro, data)macro(5, data) #define PP_ENUM_REPEAT_7(macro, data) PP_ENUM_REPEAT_6(macro, data)macro(6, data) #define PP_ENUM_REPEAT_8(macro, data) PP_ENUM_REPEAT_7(macro, data)macro(7, data) #define PP_ENUM_REPEAT_9(macro, data) PP_ENUM_REPEAT_8(macro, data)macro(8, data) #define PP_ENUM_REPEAT_10(macro, data) PP_ENUM_REPEAT_9(macro, data)macro(9, data) #define PP_ENUM_REPEAT_11(macro, data) PP_ENUM_REPEAT_10(macro, data)macro(10, data) #define PP_ENUM_REPEAT_12(macro, data) PP_ENUM_REPEAT_11(macro, data)macro(11, data) #define PP_ENUM_REPEAT_13(macro, data) PP_ENUM_REPEAT_12(macro, data)macro(12, data) #define PP_ENUM_REPEAT_14(macro, data) PP_ENUM_REPEAT_13(macro, data)macro(13, data) #define PP_ENUM_REPEAT_15(macro, data) PP_ENUM_REPEAT_14(macro, data)macro(14, data) #define PP_ENUM_REPEAT_16(macro, data) PP_ENUM_REPEAT_15(macro, data)macro(15, data) // PP_ENUM_BINARY_REPEAT #define PP_ENUM_BINARY_REPEAT(count, macro, data1, data2) PP_ENUM_BINARY_REPEAT_I(count, macro, data1, data2) #define PP_ENUM_BINARY_REPEAT_I(count, macro, data1, data2) PP_ENUM_BINARY_REPEAT_##count(macro, data1, data2) #define PP_ENUM_BINARY_REPEAT_0(macro, data1, data2) #define PP_ENUM_BINARY_REPEAT_1(macro, data1, data2) PP_ENUM_BINARY_REPEAT_0(macro, data1, data2)macro(0, data1, data2) #define PP_ENUM_BINARY_REPEAT_2(macro, data1, data2) PP_ENUM_BINARY_REPEAT_1(macro, data1, data2)macro(1, data1, data2) #define PP_ENUM_BINARY_REPEAT_3(macro, data1, data2) PP_ENUM_BINARY_REPEAT_2(macro, data1, data2)macro(2, data1, data2) #define PP_ENUM_BINARY_REPEAT_4(macro, data1, data2) PP_ENUM_BINARY_REPEAT_3(macro, data1, data2)macro(3, data1, data2) #define PP_ENUM_BINARY_REPEAT_5(macro, data1, data2) PP_ENUM_BINARY_REPEAT_4(macro, data1, data2)macro(4, data1, data2) #define PP_ENUM_BINARY_REPEAT_6(macro, data1, data2) PP_ENUM_BINARY_REPEAT_5(macro, data1, data2)macro(5, data1, data2) #define PP_ENUM_BINARY_REPEAT_7(macro, data1, data2) PP_ENUM_BINARY_REPEAT_6(macro, data1, data2)macro(6, data1, data2) #define PP_ENUM_BINARY_REPEAT_8(macro, data1, data2) PP_ENUM_BINARY_REPEAT_7(macro, data1, data2)macro(7, data1, data2) #define PP_ENUM_BINARY_REPEAT_9(macro, data1, data2) PP_ENUM_BINARY_REPEAT_8(macro, data1, data2)macro(8, data1, data2) #define PP_ENUM_BINARY_REPEAT_10(macro, data1, data2) PP_ENUM_BINARY_REPEAT_9(macro, data1, data2)macro(9, data1, data2) #define PP_ENUM_BINARY_REPEAT_11(macro, data1, data2) PP_ENUM_BINARY_REPEAT_9(macro, data1, data2)macro(10, data1, data2) #define PP_ENUM_BINARY_REPEAT_12(macro, data1, data2) PP_ENUM_BINARY_REPEAT_9(macro, data1, data2)macro(11, data1, data2) #define PP_ENUM_BINARY_REPEAT_13(macro, data1, data2) PP_ENUM_BINARY_REPEAT_9(macro, data1, data2)macro(12, data1, data2) #define PP_ENUM_BINARY_REPEAT_14(macro, data1, data2) PP_ENUM_BINARY_REPEAT_9(macro, data1, data2)macro(13, data1, data2) #define PP_ENUM_BINARY_REPEAT_15(macro, data1, data2) PP_ENUM_BINARY_REPEAT_9(macro, data1, data2)macro(14, data1, data2) #define PP_ENUM_BINARY_REPEAT_16(macro, data1, data2) PP_ENUM_BINARY_REPEAT_9(macro, data1, data2)macro(15, data1, data2) // PP_INC #define PP_INC(x) PP_INC_I(x) #define PP_INC_I(x) PP_INC_II(x) #define PP_INC_II(x) PP_INC_##x #define PP_INC_0 1 #define PP_INC_1 2 #define PP_INC_2 3 #define PP_INC_3 4 #define PP_INC_4 5 #define PP_INC_5 6 #define PP_INC_6 7 #define PP_INC_7 8 #define PP_INC_8 9 #define PP_INC_9 10 #define PP_INC_10 11 #define PP_INC_11 12 #define PP_INC_12 13 #define PP_INC_13 14 #define PP_INC_14 15 #define PP_INC_15 16 #define PP_INC_16 16 // PP_DEC #define PP_DEC(x) PP_DEC_I(x) #define PP_DEC_I(x) PP_DEC_II(x) #define PP_DEC_II(x) PP_DEC_##x #define PP_DEC_0 0 #define PP_DEC_1 0 #define PP_DEC_2 1 #define PP_DEC_3 2 #define PP_DEC_4 3 #define PP_DEC_5 4 #define PP_DEC_6 5 #define PP_DEC_7 6 #define PP_DEC_8 7 #define PP_DEC_9 8 #define PP_DEC_10 9 #define PP_DEC_11 10 #define PP_DEC_12 11 #define PP_DEC_13 12 #define PP_DEC_14 13 #define PP_DEC_15 14 #define PP_DEC_16 15 // PP_TUPLE_REM #define PP_TUPLE_REM(size) PP_TUPLE_REM_I(size) #define PP_TUPLE_REM_I(size) PP_TUPLE_REM_##size #define PP_TUPLE_REM_0() #define PP_TUPLE_REM_1(a) a #define PP_TUPLE_REM_2(a, b) a, b #define PP_TUPLE_REM_3(a, b, c) a, b, c #define PP_TUPLE_REM_4(a, b, c, d) a, b, c, d #define PP_TUPLE_REM_5(a, b, c, d, e) a, b, c, d, e #define PP_TUPLE_REM_6(a, b, c, d, e, f) a, b, c, d, e, f #define PP_TUPLE_REM_7(a, b, c, d, e, f, g) a, b, c, d, e, f, g #define PP_TUPLE_REM_8(a, b, c, d, e, f, g, h) a, b, c, d, e, f, g, h #define PP_TUPLE_REM_9(a, b, c, d, e, f, g, h, i) a, b, c, d, e, f, g, h, i #define PP_TUPLE_REM_10(a, b, c, d, e, f, g, h, i, j) a, b, c, d, e, f, g, h, i, j #define PP_TUPLE_REM_11(a, b, c, d, e, f, g, h, i, j, k) a, b, c, d, e, f, g, h, i, j, k #define PP_TUPLE_REM_12(a, b, c, d, e, f, g, h, i, j, k, l) a, b, c, d, e, f, g, h, i, j, k, l #define PP_TUPLE_REM_13(a, b, c, d, e, f, g, h, i, j, k, l, m) a, b, c, d, e, f, g, h, i, j, k, l, m #define PP_TUPLE_REM_14(a, b, c, d, e, f, g, h, i, j, k, l, m, n) a, b, c, d, e, f, g, h, i, j, k, l, m, n #define PP_TUPLE_REM_15(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) a, b, c, d, e, f, g, h, i, j, k, l, m, n, o #define PP_TUPLE_REM_16(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p // PP_TUPLE_ELEM #define PP_TUPLE_ELEM(size, i, tuple) PP_TUPLE_ELEM_I(size, i, tuple) #define PP_TUPLE_ELEM_I(size, i, tuple) PP_TUPLE_ELEM_##size##_##i tuple #define PP_TUPLE_ELEM_1_0(a) a #define PP_TUPLE_ELEM_2_0(a, b) a #define PP_TUPLE_ELEM_2_1(a, b) b #define PP_TUPLE_ELEM_3_0(a, b, c) a #define PP_TUPLE_ELEM_3_1(a, b, c) b #define PP_TUPLE_ELEM_3_2(a, b, c) c #define PP_TUPLE_ELEM_4_0(a, b, c, d) a #define PP_TUPLE_ELEM_4_1(a, b, c, d) b #define PP_TUPLE_ELEM_4_2(a, b, c, d) c #define PP_TUPLE_ELEM_4_3(a, b, c, d) d #define PP_TUPLE_ELEM_5_0(a, b, c, d, e) a #define PP_TUPLE_ELEM_5_1(a, b, c, d, e) b #define PP_TUPLE_ELEM_5_2(a, b, c, d, e) c #define PP_TUPLE_ELEM_5_3(a, b, c, d, e) d #define PP_TUPLE_ELEM_5_4(a, b, c, d, e) e #define PP_TUPLE_ELEM_6_0(a, b, c, d, e, f) a #define PP_TUPLE_ELEM_6_1(a, b, c, d, e, f) b #define PP_TUPLE_ELEM_6_2(a, b, c, d, e, f) c #define PP_TUPLE_ELEM_6_3(a, b, c, d, e, f) d #define PP_TUPLE_ELEM_6_4(a, b, c, d, e, f) e #define PP_TUPLE_ELEM_6_5(a, b, c, d, e, f) f #define PP_TUPLE_ELEM_7_0(a, b, c, d, e, f, g) a #define PP_TUPLE_ELEM_7_1(a, b, c, d, e, f, g) b #define PP_TUPLE_ELEM_7_2(a, b, c, d, e, f, g) c #define PP_TUPLE_ELEM_7_3(a, b, c, d, e, f, g) d #define PP_TUPLE_ELEM_7_4(a, b, c, d, e, f, g) e #define PP_TUPLE_ELEM_7_5(a, b, c, d, e, f, g) f #define PP_TUPLE_ELEM_7_6(a, b, c, d, e, f, g) g #define PP_TUPLE_ELEM_8_0(a, b, c, d, e, f, g, h) a #define PP_TUPLE_ELEM_8_1(a, b, c, d, e, f, g, h) b #define PP_TUPLE_ELEM_8_2(a, b, c, d, e, f, g, h) c #define PP_TUPLE_ELEM_8_3(a, b, c, d, e, f, g, h) d #define PP_TUPLE_ELEM_8_4(a, b, c, d, e, f, g, h) e #define PP_TUPLE_ELEM_8_5(a, b, c, d, e, f, g, h) f #define PP_TUPLE_ELEM_8_6(a, b, c, d, e, f, g, h) g #define PP_TUPLE_ELEM_8_7(a, b, c, d, e, f, g, h) h #define PP_TUPLE_ELEM_9_0(a, b, c, d, e, f, g, h, i) a #define PP_TUPLE_ELEM_9_1(a, b, c, d, e, f, g, h, i) b #define PP_TUPLE_ELEM_9_2(a, b, c, d, e, f, g, h, i) c #define PP_TUPLE_ELEM_9_3(a, b, c, d, e, f, g, h, i) d #define PP_TUPLE_ELEM_9_4(a, b, c, d, e, f, g, h, i) e #define PP_TUPLE_ELEM_9_5(a, b, c, d, e, f, g, h, i) f #define PP_TUPLE_ELEM_9_6(a, b, c, d, e, f, g, h, i) g #define PP_TUPLE_ELEM_9_7(a, b, c, d, e, f, g, h, i) h #define PP_TUPLE_ELEM_9_8(a, b, c, d, e, f, g, h, i) i #define PP_TUPLE_ELEM_10_0(a, b, c, d, e, f, g, h, i, j) a #define PP_TUPLE_ELEM_10_1(a, b, c, d, e, f, g, h, i, j) b #define PP_TUPLE_ELEM_10_2(a, b, c, d, e, f, g, h, i, j) c #define PP_TUPLE_ELEM_10_3(a, b, c, d, e, f, g, h, i, j) d #define PP_TUPLE_ELEM_10_4(a, b, c, d, e, f, g, h, i, j) e #define PP_TUPLE_ELEM_10_5(a, b, c, d, e, f, g, h, i, j) f #define PP_TUPLE_ELEM_10_6(a, b, c, d, e, f, g, h, i, j) g #define PP_TUPLE_ELEM_10_7(a, b, c, d, e, f, g, h, i, j) h #define PP_TUPLE_ELEM_10_8(a, b, c, d, e, f, g, h, i, j) i #define PP_TUPLE_ELEM_10_9(a, b, c, d, e, f, g, h, i, j) j #define PP_TUPLE_ELEM_11_0(a, b, c, d, e, f, g, h, i, j, k) a #define PP_TUPLE_ELEM_11_1(a, b, c, d, e, f, g, h, i, j, k) b #define PP_TUPLE_ELEM_11_2(a, b, c, d, e, f, g, h, i, j, k) c #define PP_TUPLE_ELEM_11_3(a, b, c, d, e, f, g, h, i, j, k) d #define PP_TUPLE_ELEM_11_4(a, b, c, d, e, f, g, h, i, j, k) e #define PP_TUPLE_ELEM_11_5(a, b, c, d, e, f, g, h, i, j, k) f #define PP_TUPLE_ELEM_11_6(a, b, c, d, e, f, g, h, i, j, k) g #define PP_TUPLE_ELEM_11_7(a, b, c, d, e, f, g, h, i, j, k) h #define PP_TUPLE_ELEM_11_8(a, b, c, d, e, f, g, h, i, j, k) i #define PP_TUPLE_ELEM_11_9(a, b, c, d, e, f, g, h, i, j, k) j #define PP_TUPLE_ELEM_11_10(a, b, c, d, e, f, g, h, i, j, k) k #define PP_TUPLE_ELEM_12_0(a, b, c, d, e, f, g, h, i, j, k, l) a #define PP_TUPLE_ELEM_12_1(a, b, c, d, e, f, g, h, i, j, k, l) b #define PP_TUPLE_ELEM_12_2(a, b, c, d, e, f, g, h, i, j, k, l) c #define PP_TUPLE_ELEM_12_3(a, b, c, d, e, f, g, h, i, j, k, l) d #define PP_TUPLE_ELEM_12_4(a, b, c, d, e, f, g, h, i, j, k, l) e #define PP_TUPLE_ELEM_12_5(a, b, c, d, e, f, g, h, i, j, k, l) f #define PP_TUPLE_ELEM_12_6(a, b, c, d, e, f, g, h, i, j, k, l) g #define PP_TUPLE_ELEM_12_7(a, b, c, d, e, f, g, h, i, j, k, l) h #define PP_TUPLE_ELEM_12_8(a, b, c, d, e, f, g, h, i, j, k, l) i #define PP_TUPLE_ELEM_12_9(a, b, c, d, e, f, g, h, i, j, k, l) j #define PP_TUPLE_ELEM_12_10(a, b, c, d, e, f, g, h, i, j, k, l) k #define PP_TUPLE_ELEM_12_11(a, b, c, d, e, f, g, h, i, j, k, l) l #define PP_TUPLE_ELEM_13_0(a, b, c, d, e, f, g, h, i, j, k, l, m) a #define PP_TUPLE_ELEM_13_1(a, b, c, d, e, f, g, h, i, j, k, l, m) b #define PP_TUPLE_ELEM_13_2(a, b, c, d, e, f, g, h, i, j, k, l, m) c #define PP_TUPLE_ELEM_13_3(a, b, c, d, e, f, g, h, i, j, k, l, m) d #define PP_TUPLE_ELEM_13_4(a, b, c, d, e, f, g, h, i, j, k, l, m) e #define PP_TUPLE_ELEM_13_5(a, b, c, d, e, f, g, h, i, j, k, l, m) f #define PP_TUPLE_ELEM_13_6(a, b, c, d, e, f, g, h, i, j, k, l, m) g #define PP_TUPLE_ELEM_13_7(a, b, c, d, e, f, g, h, i, j, k, l, m) h #define PP_TUPLE_ELEM_13_8(a, b, c, d, e, f, g, h, i, j, k, l, m) i #define PP_TUPLE_ELEM_13_9(a, b, c, d, e, f, g, h, i, j, k, l, m) j #define PP_TUPLE_ELEM_13_10(a, b, c, d, e, f, g, h, i, j, k, l, m) k #define PP_TUPLE_ELEM_13_11(a, b, c, d, e, f, g, h, i, j, k, l, m) l #define PP_TUPLE_ELEM_13_12(a, b, c, d, e, f, g, h, i, j, k, l, m) m #define PP_TUPLE_ELEM_14_0(a, b, c, d, e, f, g, h, i, j, k, l, m, n) a #define PP_TUPLE_ELEM_14_1(a, b, c, d, e, f, g, h, i, j, k, l, m, n) b #define PP_TUPLE_ELEM_14_2(a, b, c, d, e, f, g, h, i, j, k, l, m, n) c #define PP_TUPLE_ELEM_14_3(a, b, c, d, e, f, g, h, i, j, k, l, m, n) d #define PP_TUPLE_ELEM_14_4(a, b, c, d, e, f, g, h, i, j, k, l, m, n) e #define PP_TUPLE_ELEM_14_5(a, b, c, d, e, f, g, h, i, j, k, l, m, n) f #define PP_TUPLE_ELEM_14_6(a, b, c, d, e, f, g, h, i, j, k, l, m, n) g #define PP_TUPLE_ELEM_14_7(a, b, c, d, e, f, g, h, i, j, k, l, m, n) h #define PP_TUPLE_ELEM_14_8(a, b, c, d, e, f, g, h, i, j, k, l, m, n) i #define PP_TUPLE_ELEM_14_9(a, b, c, d, e, f, g, h, i, j, k, l, m, n) j #define PP_TUPLE_ELEM_14_10(a, b, c, d, e, f, g, h, i, j, k, l, m, n) k #define PP_TUPLE_ELEM_14_11(a, b, c, d, e, f, g, h, i, j, k, l, m, n) l #define PP_TUPLE_ELEM_14_12(a, b, c, d, e, f, g, h, i, j, k, l, m, n) m #define PP_TUPLE_ELEM_14_13(a, b, c, d, e, f, g, h, i, j, k, l, m, n) n #define PP_TUPLE_ELEM_15_0(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) a #define PP_TUPLE_ELEM_15_1(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) b #define PP_TUPLE_ELEM_15_2(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) c #define PP_TUPLE_ELEM_15_3(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) d #define PP_TUPLE_ELEM_15_4(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) e #define PP_TUPLE_ELEM_15_5(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) f #define PP_TUPLE_ELEM_15_6(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) g #define PP_TUPLE_ELEM_15_7(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) h #define PP_TUPLE_ELEM_15_8(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) i #define PP_TUPLE_ELEM_15_9(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) j #define PP_TUPLE_ELEM_15_10(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) k #define PP_TUPLE_ELEM_15_11(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) l #define PP_TUPLE_ELEM_15_12(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) m #define PP_TUPLE_ELEM_15_13(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) n #define PP_TUPLE_ELEM_15_14(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) o #define PP_TUPLE_ELEM_16_0(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) a #define PP_TUPLE_ELEM_16_1(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) b #define PP_TUPLE_ELEM_16_2(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) c #define PP_TUPLE_ELEM_16_3(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) d #define PP_TUPLE_ELEM_16_4(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) e #define PP_TUPLE_ELEM_16_5(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) f #define PP_TUPLE_ELEM_16_6(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) g #define PP_TUPLE_ELEM_16_7(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) h #define PP_TUPLE_ELEM_16_8(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) i #define PP_TUPLE_ELEM_16_9(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) j #define PP_TUPLE_ELEM_16_10(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) k #define PP_TUPLE_ELEM_16_11(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) l #define PP_TUPLE_ELEM_16_12(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) m #define PP_TUPLE_ELEM_16_13(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) n #define PP_TUPLE_ELEM_16_14(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) o #define PP_TUPLE_ELEM_16_15(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) p // PP_WHILE #define PP_WHILE(pred, op, state) PP_WHILE_0(pred, op, state) #define PP_WHILE__(pred, op, state) state #define PP_WHILE_0(pred, op, state) PP_WHILE_NEXT_ITEM(0, 1, pred, state)(pred, op, PP_WHILE_NEXT_STATE(0, pred, op, state)) #define PP_WHILE_1(pred, op, state) PP_WHILE_NEXT_ITEM(1, 2, pred, state)(pred, op, PP_WHILE_NEXT_STATE(1, pred, op, state)) #define PP_WHILE_2(pred, op, state) PP_WHILE_NEXT_ITEM(2, 3, pred, state)(pred, op, PP_WHILE_NEXT_STATE(2, pred, op, state)) #define PP_WHILE_3(pred, op, state) PP_WHILE_NEXT_ITEM(3, 4, pred, state)(pred, op, PP_WHILE_NEXT_STATE(3, pred, op, state)) #define PP_WHILE_4(pred, op, state) PP_WHILE_NEXT_ITEM(4, 5, pred, state)(pred, op, PP_WHILE_NEXT_STATE(4, pred, op, state)) #define PP_WHILE_5(pred, op, state) PP_WHILE_NEXT_ITEM(5, 6, pred, state)(pred, op, PP_WHILE_NEXT_STATE(5, pred, op, state)) #define PP_WHILE_6(pred, op, state) PP_WHILE_NEXT_ITEM(6, 7, pred, state)(pred, op, PP_WHILE_NEXT_STATE(6, pred, op, state)) #define PP_WHILE_7(pred, op, state) PP_WHILE_NEXT_ITEM(7, 8, pred, state)(pred, op, PP_WHILE_NEXT_STATE(7, pred, op, state)) #define PP_WHILE_8(pred, op, state) PP_WHILE_NEXT_ITEM(8, 9, pred, state)(pred, op, PP_WHILE_NEXT_STATE(8, pred, op, state)) #define PP_WHILE_9(pred, op, state) PP_WHILE_NEXT_ITEM(9, 10, pred, state)(pred, op, PP_WHILE_NEXT_STATE(9, pred, op, state)) #define PP_WHILE_10(pred, op, state) PP_WHILE_NEXT_ITEM(10, 11, pred, state)(pred, op, PP_WHILE_NEXT_STATE(10, pred, op, state)) #define PP_WHILE_11(pred, op, state) PP_WHILE_NEXT_ITEM(11, 12, pred, state)(pred, op, PP_WHILE_NEXT_STATE(11, pred, op, state)) #define PP_WHILE_12(pred, op, state) PP_WHILE_NEXT_ITEM(12, 13, pred, state)(pred, op, PP_WHILE_NEXT_STATE(12, pred, op, state)) #define PP_WHILE_13(pred, op, state) PP_WHILE_NEXT_ITEM(13, 14, pred, state)(pred, op, PP_WHILE_NEXT_STATE(13, pred, op, state)) #define PP_WHILE_14(pred, op, state) PP_WHILE_NEXT_ITEM(14, 15, pred, state)(pred, op, PP_WHILE_NEXT_STATE(14, pred, op, state)) #define PP_WHILE_15(pred, op, state) PP_WHILE_NEXT_ITEM(15, 16, pred, state)(pred, op, PP_WHILE_NEXT_STATE(15, pred, op, state)) #define PP_WHILE_16(pred, op, state) PP_ERROR(0x0001) #define PP_WHILE_NEXT_ITEM(i, n, pred, state) PP_CAT(PP_WHILE_, PP_IF(PP_BOOL(pred(i, state)), n, _)) #define PP_WHILE_NEXT_STATE(i, pred, op, state) PP_IF(PP_BOOL(pred(i, state)), op(i, state), state) #if 0 #define STATE(d, state) state #define TUPLE4 (1, 2, 3, 4) #define TUPLE2 (4, 8) #define PRED(d, state) PP_TUPLE_ELEM(2, 0, state) #define OP(d, state) (PP_DEC(PP_TUPLE_ELEM(2, 0, state)), PP_INC(PP_TUPLE_ELEM(2, 1, state))) void _f1() { PP_TUPLE_ELEM(4, 2, TUPLE4); PP_INC(3); PP_DEC(3); PRED(1, TUPLE2); OP(1, TUPLE2); PP_WHILE(PRED, OP, TUPLE2); // PP_IF(PP_BOOL(pred(2, state)), 3, 0); // PP_TUPLE_ELEM(2, 1, WHILE(PRED, OP, TUPLE2)); } #define DECL(n, text) text##n = n; #define DECL2(n, text) , text##n #define DECL3(n, text) PP_COMMA_IF(n)text##n void test() { PP_BOOL(0); PP_BOOL(2); PP_NOT(0); PP_NOT(2); PP_AND(0, 0); PP_AND(0, 2); PP_AND(2, 0); PP_AND(1, 2); PP_OR(0, 0); PP_OR(0, 2); PP_OR(2, 0); PP_OR(1, 2); PP_XOR(0, 0); PP_XOR(0, 2); PP_XOR(2, 0); PP_XOR(1, 2); PP_IF(2, a, b); PP_IF(0, a, b); int a PP_COMMA_IF(2) b; // int a, b PP_COMMA_IF(0); PP_ENUM_PARAMS(3, class T); // class T0, class T1, class T2 PP_ENUM_REPEAT(3, DECL, int a); // int a0 = 0; int a1 = 1; int a2 = 2; PP_ENUM(3, class); // class, class, class } void test2(PP_ENUM_REPEAT(3, DECL3, int a)) { } void test3(PP_ENUM_PARAMS(3, int a)) { } void test4(int x, int y PP_ENUM_REPEAT(9, DECL2, int a)) { } void test5(int x, int y PP_ENUM_TRAILING_PARAMS(9, int a)) { } template <PP_ENUM_PARAMS(3, typename A)> void test6(PP_ENUM_BINARY_PARAMS(3, A, a)) { } template <PP_ENUM_PARAMS(3, typename A)> void test7(int x PP_ENUM_TRAILING_BINARY_PARAMS(3, A, a)) { } #endif #endif /* PREPROCESSOR_H_ */
a5e30ab8b847e5b9727d4f97881df7a550f40a1b
34f275a9c25960874ba5d982e5c6f211ab41233f
/lab(ds) 9/lab(ds) 9/lab(ds) 9.cpp
a7f2da9384db6580e9ea1fd4709e0a911baf22fe
[]
no_license
ValentineGladyshkoip51/KPI-DS-labs
524603810a24a81e9451f1fbd43970d54e700676
426b7fe25b1ad9e1792fefd196c50beadc65575c
refs/heads/master
2017-12-03T19:19:16.711937
2016-06-04T13:15:35
2016-06-04T13:15:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,829
cpp
lab(ds) 9.cpp
#include "stdafx.h" #include <stdio.h> #include <vector> #include <iostream> #include <iomanip> #include <algorithm> using namespace std; const int n0 = 100; const int m0 = 1000; const int INF = 1000000000; int a, b, c, n, m, e, len; int h[n0]; int l[n0]; int Way[n0]; bool u[n0] = { 0 }; int A[m0][m0] = { 0 }; int g_s[n0][n0] = { 0 }; int way_floyd[n0][n0]; int W[n0][n0] = { INF }; int W1[n0][n0] = { INF }; int D[n0][n0] = { 0 }; bool visit[n0] = { 0 }; struct Tedge { int v; int u; int w; }; Tedge edges[m0]; vector <int> way; void input(); void output(int[n0][n0]); int floyd(int[n0][n0]); void func_way(int, int, int[n0][n0]); void output1(int, int); int ford_belman(int, int[m0][m0], Tedge[m0]); void change(int[n0][n0]); void func(int, int[]); void dijkstra(int, int[]); void johnson(); int main(void) { input(); output1(a, b); johnson(); system("pause"); } void input() { cout << "Enter the number of vertices of the graph (n<=100) :" << endl; cin >> n; cout << "Enter the number of edges of the graph (m<=1000) :" << endl; cin >> m; for (int i = 1; i <= m; i++) { cout << "Enter edge and it weight(" << i << ") :" << endl; scanf_s("%d%d%d", &(edges[i].v), &(edges[i].u), &(edges[i].w)); W[edges[i].v][edges[i].u] = edges[i].w; g_s[edges[i].v][edges[i].u] = 1; } cout << "Enter a b" << endl; cin >> a >> b; } void output(int matr[n0][n0]) { cout << "Distance Matrix :" << endl; for (int i = 1;i <= n;i++) { for (int j = 1;j <= n;j++) cout << setw(6) << matr[i][j]; cout << endl; } } int floyd(int matr[n0][n0]) { int e1 = 0; int e2 = 0; int i, j, k; for (i = 1;i <= n;i++) for (j = 1;j <= n;j++) if (i == j) way_floyd[i][j] = 0; else way_floyd[i][j] = i; for (int d = 1; d <= m; d++) if (edges[d].w == 0) e2++; if (!e2) { for (i = 1;i <= n;i++) for (j = 1;j <= n;j++) if (matr[i][j] == 0) matr[i][j] = INF; } for (i = 1;i <= n;i++) for (j = 1;j <= n;j++) for (k = 1;k <= n;k++) if ((matr[i][k] != INF) && (matr[k][j] != INF)) if (matr[i][j] > (matr[i][k] + matr[k][j])) { matr[i][j] = (matr[i][k] + matr[k][j]); way_floyd[i][j] = way_floyd[k][j]; } for (i = 1;i <= n;i++) if (matr[i][i] < 0) e1++; for (i = 1;i <= n;i++) for (j = 1;j <= n;j++) if ((matr[i][j] == INF) || (i == j)) matr[i][j] = 0; for (i = 0;i<n;i++) for (j = 0;j<n;j++) if (g_s[i][j] == 0) g_s[i][j] = 999; for (i = 0;i<n;i++) for (j = 0;j<n;j++) for (k = 0;k<n;k++) g_s[i][j] = min(g_s[i][j], g_s[i][k] + g_s[k][j]); for (i = 0;i < n;i++) for (j = 0;j < n;j++) if ((g_s[i][j] == 999) || (i == j)) g_s[i][j] = 0; return e1; } void func_way(int a1, int b1, int matr[n0][n0]) { int j = b1; while (j != a1) { way.push_back(j); j = matr[a1][j]; } way.push_back(a1); } void output1(int a1, int b1) { cout << endl; cout << "============= Floyd algorithm =============" << endl; cout << endl; e = floyd(W); if (e) cout << "Graf has negative cycles" << endl; else { output(W); cout << endl; func_way(a1, b1, way_floyd); cout << "Length of way from " << a1 << " to " << b1 << " = " << W[a1][b1] << endl; cout << "way from " << a1 << " to " << b1 << " : "; for (int i = way.size(); i > 0; i--) cout << way[i - 1] << " "; cout << endl; cout << endl; } } int ford_belman(int a1, int matr[m0][m0], Tedge b[m0]) { int e1 = 0; for (int i = 0;i <= n;i++) for (int v = 1;v <= (n+1);v++) matr[i][v] = INF; matr[0][a1] = 0; for (int i = 1;i <= n;i++) { for (int j = 1;j <= (n + m);j++) { if (matr[i][b[j].u] > (matr[(i - 1)][b[j].v] + b[j].w)) { matr[i][b[j].u] = (matr[(i - 1)][b[j].v] + b[j].w); } } } for (int j = 1;j <= (n + 1);j++) if (matr[n][b[j].u] > (matr[n][b[j].v] + b[j].w)) e1++; return e1; } void change(int matr[n0][n0]) { for (int i = 1;i <= n;i++) for (int j = 1;j <= n;j++) matr[i][j] = (matr[i][j] - h[i] + h[j]); } void func(int b, int a[]) { if (a[b] == -1) { return; } way.push_back(a[b]); func(a[b], a); } void dijkstra(int a1, int l1[]) { int x, v1; if (a1 == a) Way[a1] = -1; for (int i = 1;i <= n;i++) { l[i] = 0; u[i] = 0; W1[i][i] = 0; if (i == a1) l1[i] = 0; else l1[i] = INF; } x = a1; u[x] = 1; for (int j = 1;j <= n;j++) if (W[a1][j] == 0) u[j] = 1; for (int i = 1;i <= n;i++) while (!u[i]) { if (x == b) e++; for (int v = 1;v <= n;v++) if (!u[v]) { if (l1[v] > (l1[x] + W1[x][v])) { l1[v] = (l1[x] + W1[x][v]); if ((a1 == a) && (!e)) Way[v] = x; } } int min2 = INF; for (int v = 1;v <= n;v++) { if (!u[v]) min2 = min(min2, l1[v]); } for (int v = 1;v <= n;v++) { if (l1[v] == min2) v1 = v; } u[v1] = 1; x = v1; } for (int i = 1;i <= n;i++) if (l1[i] != INF) D[a1][i] = l1[i]; if (a1 == a) { len = W[a][b]; } } void johnson() { cout << "============= Johnson algorithm =============" << endl; cout << endl; for (int i = 1; i <= n; i++) { edges[(i + m)].v = (n + 1); edges[(i + m)].u = i; edges[(i + m)].w = 0; } e = ford_belman((n + 1), A, edges); if (e) cout << "Graf has negative cycles" << endl; else { for (int i = 1; i <= n; i++) { int l = INF; for (int j = 1;j < (n + 1);j++) l = min(l, A[j][i]); h[i] = l; } len = W[a][b]; for (int i = 1; i <= n; i++) { edges[i].w = edges[i].w + h[edges[i].v] - h[edges[i].u]; W1[edges[i].v][edges[i].u] = edges[i].w; } cout << endl; output(W); cout << endl; cout << "Length of way from " << a << " to " << b << " = " << len << endl; cout << "way from " << a << " to " << b << " : "; for (int i = way.size(); i > 0; i--) cout << way[i - 1] << " "; cout << endl; } }
5c32271d29332a5e17c474b67414979ddb49468e
5a66ab025f1d0f1959eba8b8d077195f1295325d
/hardware/tf_broadcaster/src/tf_broadcaster.cpp
d077feb641c5c039cca7518c902c549617e66d82
[]
no_license
PyroTeam/robocup-pkg
e07eac96cacb17f2dd3b5232bd39e8f01e7a6535
a38e15f4d1d1c6a2c6660af2ea675c0fa6069c79
refs/heads/devel
2020-12-25T16:54:06.609071
2017-01-07T15:30:13
2017-01-07T15:30:13
26,918,239
9
3
null
2017-01-07T15:30:13
2014-11-20T15:21:22
C++
UTF-8
C++
false
false
3,667
cpp
tf_broadcaster.cpp
#include "tf_broadcaster/tf_broadcaster.h" void poseCallback(const nav_msgs::Odometry &odom) { static tf::TransformBroadcaster odomToBaseLink; static ros::NodeHandle nh; static ros::NodeHandle nhPriv("~"); bool onlyOdomToBase; std::string tf_prefix; nh.param<std::string>("simuRobotNamespace", tf_prefix, ""); if (tf_prefix.size() != 0) tf_prefix += "/"; if (nhPriv.hasParam("onlyOdomToBase")) { nhPriv.getParam("onlyOdomToBase", onlyOdomToBase); } else { onlyOdomToBase = false; } tf::Transform transform; tf::Quaternion q; // Odom to Base Link transform.setOrigin(tf::Vector3(odom.pose.pose.position.x, odom.pose.pose.position.y, 0.0)); tf::quaternionMsgToTF(odom.pose.pose.orientation, q); transform.setRotation(q); odomToBaseLink.sendTransform(tf::StampedTransform(transform, odom.header.stamp , tf_prefix+"odom", tf_prefix+"base_link")); if (onlyOdomToBase) { return; } static tf::TransformBroadcaster mapToOdom; static tf::TransformBroadcaster baseLinkToLaserLink; static tf::TransformBroadcaster baseLinkToTowerCameraLink; static tf::TransformBroadcaster baseLinkToPlatformCameraLink; // Map to odom transform.setOrigin(tf::Vector3(0.0, 0.0, 0.0)); q.setRPY(0.0, 0.0, 0.0); transform.setRotation(q); mapToOdom.sendTransform(tf::StampedTransform(transform, odom.header.stamp, "map", tf_prefix+"odom")); // Base Link to Laser Link static double laser_link_x = 0; static double laser_link_y = 0; static double laser_link_z = 0; nh.param<double>("hardware/robotDescription/baseLink_to_laserLink/x", laser_link_x, 0.10+0.01); nh.param<double>("hardware/robotDescription/baseLink_to_laserLink/y", laser_link_y, 0.0); nh.param<double>("hardware/robotDescription/baseLink_to_laserLink/z", laser_link_z, 0.235+0.0175); transform.setOrigin(tf::Vector3(laser_link_x, laser_link_y, laser_link_z)); q.setRPY(0.0, 0.0, 0.0); transform.setRotation(q); baseLinkToLaserLink.sendTransform(tf::StampedTransform(transform, odom.header.stamp, tf_prefix+"base_link", tf_prefix+"laser_link")); // Base Link to Tower Camera Link static double tower_camera_link_x = 0; static double tower_camera_link_y = 0; static double tower_camera_link_z = 0; nh.param<double>("hardware/robotDescription/baseLink_to_towerCameraLink/x", tower_camera_link_x, 0.20); nh.param<double>("hardware/robotDescription/baseLink_to_towerCameraLink/y", tower_camera_link_y, 0.00); nh.param<double>("hardware/robotDescription/baseLink_to_towerCameraLink/z", tower_camera_link_z, 0.53); transform.setOrigin(tf::Vector3(tower_camera_link_x, tower_camera_link_y, tower_camera_link_z)); q.setRPY(-1.57, 0, -1.57); transform.setRotation(q); baseLinkToTowerCameraLink.sendTransform(tf::StampedTransform(transform, odom.header.stamp , tf_prefix+"base_link", tf_prefix+"tower_camera_link")); // Base Link to Platform Camera Link static double platform_camera_link_x = 0; static double platform_camera_link_y = 0; static double platform_camera_link_z = 0; nh.param<double>("hardware/robotDescription/baseLink_to_platformCameraLink/x", platform_camera_link_x, 0.0); nh.param<double>("hardware/robotDescription/baseLink_to_platformCameraLink/y", platform_camera_link_y, 0.00); nh.param<double>("hardware/robotDescription/baseLink_to_platformCameraLink/z", platform_camera_link_z, 0.90); transform.setOrigin(tf::Vector3(platform_camera_link_x, platform_camera_link_y, platform_camera_link_z)); q.setRPY(-1.57, 0, -1.57); transform.setRotation(q); baseLinkToPlatformCameraLink.sendTransform(tf::StampedTransform(transform, odom.header.stamp , tf_prefix+"base_link", tf_prefix+"platform_camera_link")); }
1d4b22f32fa8e6722dca6328a74427abc9d64670
e90d9f70c71421648e3545833c89522c1370a56b
/ImGuiSizeCallbackData.h
e6a460dfd044721f28098c02bdda9cd08a75ad59
[]
no_license
Paril/ImGuiCppCli
95ab25d6ae5bcc9347947ac5614dcf13752914b6
586937aa8d79a5695477d8fd4e0d11193fe8e73c
refs/heads/master
2020-12-01T15:04:19.905651
2020-01-05T13:22:11
2020-01-05T13:22:11
230,674,107
1
1
null
null
null
null
UTF-8
C++
false
false
344
h
ImGuiSizeCallbackData.h
#pragma once using namespace System; #include "ImVec2.h" namespace ImGuiCppCli { public value struct ImGuiSizeCallbackData { private: IntPtr UserData; public: ImVec2 Pos; ImVec2 CurrentSize; ImVec2 DesiredSize; }; public delegate void ImGuiSizeDelegate(ImGuiSizeCallbackData% data); }
454f67738c3506c0c908ae2d9a92d6cd2b27316c
62126238af2e3e85b9337f66293c2a29946aa2a1
/framework/Thread/ThreadWindows/Sources/ThreadRunMethodWin32.cpp
30c9d5be1bd371c809137e8dfa20b6960f7daf19
[ "MIT" ]
permissive
metalkin/kigs
b43aa0385bdd9a495c5e30625c33a170df410593
87d1757da56a5579faf1d511375eccd4503224c7
refs/heads/master
2021-02-28T10:29:30.443801
2020-03-06T13:39:38
2020-03-06T13:51:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,415
cpp
ThreadRunMethodWin32.cpp
#include "PrecompiledHeaders.h" #include "ThreadRunMethodWin32.h" #include "Core.h" #include "Thread.h" #include "CoreBaseApplication.h" IMPLEMENT_CLASS_INFO(ThreadRunMethodWin32) ThreadRunMethodWin32::ThreadRunMethodWin32(const kstl::string& name,CLASS_NAME_TREE_ARG) : ThreadRunMethod(name,PASS_CLASS_NAME_TREE_ARG) { myHandle=0; } ThreadRunMethodWin32::~ThreadRunMethodWin32() { if(myHandle) { CloseHandle(myHandle); myHandle=0; } } void ThreadRunMethodWin32::EndThread() { if(myHandle) { // seems a bad idea TerminateThread(myHandle,0); CloseHandle(myHandle); myHandle=0; } } void ThreadRunMethodWin32::StartThread() { myHandle = CreateThread( NULL, // default security attributes 0, // use default stack size (LPTHREAD_START_ROUTINE)GetThreadRunMethod(), // thread function myThread, // argument to thread function 0, // use default creation flags &myThreadId); // returns the thread identifier } void ThreadRunMethodWin32::setAffinityMask(int mask) { CoreBaseApplication::setThreadAffinityMask(myHandle,mask); } void ThreadRunMethodWin32::sleepThread() { SuspendThread(myHandle); } void ThreadRunMethodWin32::wakeUpThread() { ResumeThread(myHandle); } void ThreadRunMethodWin32::waitDeath(unsigned long P_Time_Out) { WaitForSingleObject(myHandle,P_Time_Out); }
1ad23e32c82601e6a57b867c7accf32499a5148c
3de5a328c9372fc996d265cf005a33f70a76f9de
/playstate/playstate/kernel.cpp
8e8866163e8948c8e8d6612a501d16db75f57136
[]
no_license
perandersson/playstate
6c22942f295ee85482332776e6b94041e765247d
7e6a426e834e43663846c3c1a5ae4f3a9fa94619
refs/heads/master
2020-04-28T00:49:30.853108
2013-10-14T17:24:35
2013-10-14T17:24:35
10,280,928
2
0
null
null
null
null
UTF-8
C++
false
false
167
cpp
kernel.cpp
#include "memory/memory.h" #include "kernel.h" using namespace playstate; template<> playstate::IKernel* playstate::Singleton<playstate::IKernel>::gSingleton = NULL;
fc35fc8a5f37d44ee55a65af3bd048906c3126d4
84a04da079e1cbd120813de748e4aa3d97143601
/Tank.h
208b7d6c93601910d75e1a52e9623b18ee66385a
[]
no_license
Sylean92/Compsci_376_ZombieWar
db4f9602bafea12ef7eadc9674e792b879b9e77f
dd8cddc24a87a41cebdb3a14c2f4e57fb5c09d4b
refs/heads/master
2021-01-13T09:22:44.328668
2016-10-17T02:36:47
2016-10-17T02:36:47
69,929,909
0
2
null
2016-10-15T17:28:52
2016-10-04T02:57:19
C++
UTF-8
C++
false
false
1,081
h
Tank.h
#ifndef TANK_H #define TANK_H class ISurvivor; class Tank{ private: int health; //variable to hold health int at; //variable to store attack strength public: Tank(){health = 150; at = 20;} //Constructor to initialize a common infected int getHealth(){return health;} //Accessor to return the health void decreaseHealth(int damage){health -= damage;} //Mutator to update health when attacked int getAttack() {return at;} virtual void attack(ISurvivor * Survivor){ Survivor -> decreaseHealth(getAttack()); } }; /* public: Tank(); ~Tank(); double getHealth(); double getAttack(); void setHealth(double newHp); private: double health; double attack; }; Tank :: Tank(){ health=150; attack=20; } double Tank:: getAttack(){ return attack; } double Tank:: getHealth(){ return health; } void Tank:: setHealth(double attack){ health = health-attack; } */ #endif
0f0a1f94d788398a461df7398674248ab97183b1
5658c36304688edf55c5d5229dfc7e8fdf2e5ea7
/FaceAugmentationLib/FaceAugmentation/FaceAugmentation.h
af0d57681c132fa7a398ad2d20a88d53771b1d4f
[]
no_license
cllanjim/3DFaceAugmentation
82824b81c89c3fc2043eae6c42097911de67726b
c3c519debc6afc3aefe2d91e3c23d49945c85b45
refs/heads/master
2020-03-18T06:24:51.877780
2018-05-21T19:32:40
2018-05-21T19:32:40
null
0
0
null
null
null
null
ISO-8859-1
C++
false
false
1,511
h
FaceAugmentation.h
/* * Description: 3D facial augmentation for Augmented Reality purpose. * * @author João Otávio Brandão (jobal@cin.ufpe.br) * @since 2018-04-06 */ #pragma once #ifdef FACEAUGMENTATION_EXPORTS #define FACEAUGMENTATION_API __declspec(dllexport) #else #define FACEAUGMENTATION_API __declspec(dllimport) #endif #include "SeetaFaceDetection.h" #include "FeatureExtraction.h" #include "PoseEstimation.h" #include <opencv2\features2d.hpp> #include "opencv2\xfeatures2d.hpp" #include <opencv2\opencv.hpp> #include <iostream> #include <windows.h> class FaceAugmentation { public: static FACEAUGMENTATION_API FaceAugmentation& Instance(); /** * Constructor */ FACEAUGMENTATION_API FaceAugmentation(); FACEAUGMENTATION_API void ExtractFacialFeatures(BYTE* pixels, FeatureExtraction::Features &features, int width, int height, FeatureExtraction::DescriptorType descriptorType, FeatureExtraction::DetectorType detectorType, SeetaFaceDetection::Face face); FACEAUGMENTATION_API void ExtractFacialFeatures(BYTE* pixels, FeatureExtraction::Features &features, int width, int height, FeatureExtraction::DescriptorType descriptorType, FeatureExtraction::DetectorType detectorType, bool cropFace); FACEAUGMENTATION_API void Create2D3DCorrespondences(std::vector<cv::DMatch> matches, std::vector<cv::KeyPoint> imageKeypoints, std::vector<cv::Point3d> model3Dpoints, std::vector<cv::Point2d> &imagePoints, std::vector<cv::Point3d> &modelPoints); private: static FaceAugmentation* instance; };
cdea39f2dcdc0897296b7ea34d8b8bf4f54bd3bc
4bcb30a6752081e77db45bfb7b4a9492b8282500
/mwengine/src/main/cpp/tests/utilities/eventutility_test.cpp
26491525da93168a20094b850a38330b638d69c4
[ "MIT" ]
permissive
igorski/MWEngine
b30507f9419761b6fdf345e9410bd0b0ab6d4ac5
ff7dc12658766d9961941741161999cb7210dc71
refs/heads/master
2022-11-02T07:37:46.513309
2022-10-29T14:26:14
2022-10-29T14:26:14
17,284,944
270
54
MIT
2022-10-09T10:27:26
2014-02-28T12:01:31
C++
UTF-8
C++
false
false
2,053
cpp
eventutility_test.cpp
#include "../../utilities/eventutility.h" #include "../../events/baseaudioevent.h" TEST( EventUtility, EventStartAndEndMeasures ) { AudioEngine::samples_per_bar = 512; BaseAudioEvent* audioEvent = new BaseAudioEvent(); // expected to occupy measure 0 (0 - 511) audioEvent->setEventStart(0); audioEvent->setEventLength(512); EXPECT_EQ(0, EventUtility::getStartMeasureForEvent( audioEvent )); EXPECT_EQ(0, EventUtility::getEndMeasureForEvent( audioEvent )); // expected to occupy measures 0 and 1 (0 - 1023) audioEvent->setEventLength(1024); EXPECT_EQ(0, EventUtility::getStartMeasureForEvent( audioEvent )); EXPECT_EQ(1, EventUtility::getEndMeasureForEvent( audioEvent )); // expected to occupy measures 1 and 2 (512 - 1535) audioEvent->setEventStart(512); EXPECT_EQ(1, EventUtility::getStartMeasureForEvent( audioEvent )); EXPECT_EQ(2, EventUtility::getEndMeasureForEvent( audioEvent )); delete audioEvent; } TEST( EventUtility, VectorContains ) { BaseAudioEvent* audioEvent = new BaseAudioEvent(); std::vector<BaseAudioEvent*>* vector = new std::vector<BaseAudioEvent*>(); ASSERT_FALSE( EventUtility::vectorContainsEvent( vector, audioEvent )); vector->push_back( audioEvent ); ASSERT_TRUE( EventUtility::vectorContainsEvent( vector, audioEvent )); delete audioEvent; delete vector; } TEST( EventUtility, RemoveEventFromVector ) { BaseAudioEvent* audioEvent = new BaseAudioEvent(); std::vector<BaseAudioEvent*>* vector = new std::vector<BaseAudioEvent*>(); ASSERT_FALSE( EventUtility::removeEventFromVector( vector, audioEvent )) << "expected removal of non-added event to return false"; vector->push_back( audioEvent ); ASSERT_TRUE( EventUtility::removeEventFromVector( vector, audioEvent )) << "expected removal of added event to return true"; ASSERT_FALSE( EventUtility::vectorContainsEvent( vector, audioEvent )) << "expected event to have been removed from vector"; delete audioEvent; delete vector; }
1bd7173a5095fb678e5189c217ef0827ed178cb9
4c04ef1077f8e240792da2abbd91f9b7950b1599
/MapaEstelar/src/input/ManipulationInput.h
c313cfbc5ea1fd2536d66b1c2f9152967dca2f59
[]
no_license
HansLehnert/mapa_estelar
72be9addaace746ef2315cdb963b03c67c4a8135
41d0e59bbb39e1aa464d6bf8f34395d2a658175f
refs/heads/master
2021-06-09T22:13:34.105628
2016-12-06T03:14:06
2016-12-06T03:14:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
338
h
ManipulationInput.h
#pragma once #include "InputComponent.h" #include <glm\glm.hpp> class ManipulationInput : public InputComponent { public: ManipulationInput(InputSystem* sys, Object* obj, InputSystem::Priority priority) : InputComponent(sys, obj, priority), offset(0) { } int update(); int sendMessage(Message); private: glm::vec2 offset; };
d4c9e716ef09f5a8948aff1b86ecef5f9f318f3a
551a4a96d3881d536eaa74fa35f86f4594453951
/graphs/shortestPathTree/main.cpp
0f359d03dd4344923a96cbea73bb32244d5cfa76
[]
no_license
chrzhang/abc
ab0cefc051a9fa077bfc08b9f3e5827d267a025d
a24254740bdcaa0892f7306df161f6c0df3a10cd
refs/heads/master
2022-12-08T14:34:25.499603
2022-12-01T16:13:41
2022-12-01T16:13:41
47,222,439
1
0
null
null
null
null
UTF-8
C++
false
false
5,599
cpp
main.cpp
#include <iostream> #include <iomanip> #include <algorithm> #include <set> #include <unordered_map> #include <climits> #include <vector> #include <cassert> #define WIDTH 5 // Find the shortest-path tree, a spanning tree such that the path distance from // the chosen root vertex to any other vertex is the shortest possible // Note the program does not create a graph but outputs the minimal distance // between a chosen root and every other vertex struct Edge; struct Vertex { int id; std::set<Edge> adjList; Vertex(int i) : id(i) {} }; struct Edge { Vertex * destination; unsigned weight; Edge(Vertex * d, unsigned w) : destination(d), weight(w) {} }; bool operator<(const Edge & e1, const Edge & e2) { if (e1.destination == e2.destination) { return e1.weight < e2.weight; } else { return e1.destination < e2.destination; } } struct Graph { std::unordered_map<int, Vertex *> allVertices; int currVertexIndex; Graph() : currVertexIndex(0) {} ~Graph() { for (auto idVertex : allVertices) { delete idVertex.second; } } void addVertex(size_t amount) { for (size_t v = 0; v < amount; ++v) { int id = currVertexIndex++; auto seek = allVertices.find(id); if (seek != allVertices.end()) { std::cout << "Prevented adding a duplicate vertex.\n"; return; } allVertices[id] = new Vertex(id); } } void connect(int id1, int id2, unsigned weight) { auto seek1 = allVertices.find(id1); auto seek2 = allVertices.find(id2); if (weight == 0 || seek1 == allVertices.end() || seek2 == allVertices.end()) { std::cout << "Invalid arguments to adding an edge.\n"; return; } Vertex * v1 = seek1->second; Vertex * v2 = seek2->second; v1->adjList.insert(Edge(v2, weight)); v2->adjList.insert(Edge(v1, weight)); } }; void genShortestPath(int idRoot, const Graph * g) { if (!g || idRoot < 0 || idRoot >= (int) g->allVertices.size()) { return; } // Create a set of all vertices in the shortest path tree std::set<int> shortestPathTreeSet; // Starts empty // Assign a distance to all vertices in the graph (INF, 0 at source) std::vector<unsigned> distances (g->allVertices.size(), UINT_MAX); distances[idRoot] = 0; // While not all nodes are accounted for while (shortestPathTreeSet.size() < g->allVertices.size()) { // Pick a vertex that is not accounted for with minimum distance value int smallestIndex = -1; unsigned smallestVal = UINT_MAX; for (size_t i = 0; i < distances.size(); ++i) { auto seek = shortestPathTreeSet.find(i); if (seek != shortestPathTreeSet.end()) { continue; } if (distances[i] < smallestVal) { smallestVal = distances[i]; smallestIndex = (int) i; } } if (smallestIndex == -1) { assert(false); } // Add vertex to set of nodes accounted for shortestPathTreeSet.insert(smallestIndex); // Update distance of all adjacent nodes by giving it the value of // min(currDistanceValue, currDistanceValueOfSource + edgeWeight) for (auto e : g->allVertices.at(smallestIndex)->adjList) { Vertex * dest = e.destination; distances[dest->id] = std::min(distances[dest->id], smallestVal + e.weight); } } for (size_t i = 0; i < distances.size(); ++i) { std::cout << "Shortest path from " << idRoot << " to " << i << " is " << distances[i] << "\n"; } } unsigned isConnectedTo(Vertex * v1, Vertex * v2) { if (!v1 || !v2) { return 0; } std::set<Edge> & adjList = v1->adjList; for (auto e : adjList) { if (e.destination == v2) { return e.weight; } } return 0; } std::ostream & operator<<(std::ostream & os, const Graph & g) { os << "Adjacency list:\n"; for (auto it = g.allVertices.begin(); it != g.allVertices.end(); ++it) { os << it->first << ": "; for (auto edge : it->second->adjList) { os << edge.destination->id << " (" << edge.weight << ") "; } os << "\n"; } os << "Adjacency matrix:\n"; for (int i = -1; i < (int) g.allVertices.size(); ++i) { for (int j = -1; j < (int) g.allVertices.size(); ++j) { if (i == -1 && j == -1) { std::cout << std::setw(WIDTH) << " " << " "; } else if (i == -1) { std::cout << std::setw(WIDTH) << j << " "; } else if (j == -1) { std::cout << std::setw(WIDTH) << i << " "; } else { auto r = isConnectedTo(g.allVertices.at(i), g.allVertices.at(j)); os << std::setw(WIDTH) << (r ? std::to_string(r) : " ") << " "; } } os << "\n"; } return os; } int main() { Graph g; g.addVertex(9); g.connect(0, 1, 4); g.connect(1, 2, 8); g.connect(2, 3, 7); g.connect(3, 4, 9); g.connect(4, 5, 10); g.connect(5, 6, 2); g.connect(6, 7, 1); g.connect(7, 0, 8); g.connect(1, 7, 11); g.connect(7, 8, 7); g.connect(6, 8, 6); g.connect(2, 8, 2); g.connect(2, 5, 4); g.connect(3, 5, 14); std::cout << g; genShortestPath(0, &g); return 0; }
b85b7dc6de73a25f5aeaf94ca210b49fc0142064
ae50e9c0197fd56751a2e53dd849646852be8091
/hackerRank/Gem_Stones.cpp
3fadc56d78ff71f70e99d0fc7fd923c98dd85079
[]
no_license
mgiridhar/code
3edbd481f5f17e38c78e7ab7087c58702c525b34
fd1a792ddb861160ff86543c3f66091fbcd7148b
refs/heads/master
2020-04-05T22:48:50.307652
2018-04-30T08:07:34
2018-04-30T08:07:34
22,779,070
0
1
null
null
null
null
UTF-8
C++
false
false
629
cpp
Gem_Stones.cpp
#include<iostream> #include<cstdio> #include<cstring> using namespace std; int main() { int n; cin>>n; int rock_comp[n][26]; for(int i=0;i<n;i++) for(int j=0;j<26;j++) rock_comp[i][j]=0; for(int i=0;i<n;i++) { char comp[100]; cin>>comp; for(int j=0;j<strlen(comp);j++) rock_comp[i][comp[j]-97]=1; } int count=0; int flag; for(int i=0;i<26;i++) { flag=1; for(int j=0;j<n;j++) { if(!rock_comp[j][i]) { flag=0; break; } } if(flag) count++; } cout<<count<<endl; /*for(int i=0;i<n;i++) { for(int j=0;j<26;j++) { cout<<rock_comp[i][j]; } cout<<endl; }*/ return 0; }
9fd4ba6242db5b884a5c23f9a998ea9814928f83
d7906e84bda2bd386e074eab9f05479205e7d2a9
/Development/Source/Core/Geometry/E3GeometryMesh.cpp
b636465b7de016c0956159360295699b95d5ac38
[ "BSD-3-Clause" ]
permissive
jwwalker/Quesa
6fedd297a5a4dd1c21686e71bba3c68228f61724
1816b0772409c2faacdb70b40d5c02a55d643793
refs/heads/master
2023-07-27T16:36:55.757833
2023-07-06T23:55:10
2023-07-06T23:55:10
204,233,833
33
7
BSD-3-Clause
2023-09-09T23:17:36
2019-08-25T01:59:21
C++
UTF-8
C++
false
false
178,536
cpp
E3GeometryMesh.cpp
/* NAME: E3GeometryMesh.cpp DESCRIPTION: Implementation of Quesa Mesh geometry class. COPYRIGHT: Copyright (c) 1999-2021, Quesa Developers. All rights reserved. For the current release of Quesa, please see: <https://github.com/jwwalker/Quesa> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: o Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. o Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. o Neither the name of Quesa nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ___________________________________________________________________________ */ //============================================================================= // Include files //----------------------------------------------------------------------------- #include "E3Prefix.h" #include "E3View.h" #include "E3Geometry.h" #include "E3GeometryMesh.h" #include "E3ArrayOrList.h" #include "E3Pool.h" //============================================================================= // Macros //----------------------------------------------------------------------------- // Unlike C++, C does not distinguish between various kinds of type casts. // Use E3_CONST_CAST to cast away const-ness. //----------------------------------------------------------------------------- #ifndef E3_CONST_CAST #define E3_CONST_CAST(cast, value) ((cast) (value)) #endif //============================================================================= // Internal types //----------------------------------------------------------------------------- // Part and mesh data typedef struct TE3MeshPartData TE3MeshPartData; typedef struct TE3MeshCornerData TE3MeshCornerData; typedef struct TE3MeshVertexData TE3MeshVertexData; typedef struct TE3MeshContourData TE3MeshContourData; typedef struct TE3MeshFaceData TE3MeshFaceData; typedef struct TE3MeshData TE3MeshData; // External references to parts - distinct types typedef TQ3MeshVertex TE3MeshVertexExtRef; typedef TQ3MeshContour TE3MeshContourExtRef; typedef TQ3MeshFace TE3MeshFaceExtRef; typedef TQ3MeshEdge TE3MeshEdgeExtRef; typedef TQ3MeshComponent TE3MeshComponentExtRef; // TE3MeshPartPtr typedef TE3MeshPartData* TE3MeshPartPtr; E3_POOL_DECLARE(TE3MeshPartPtr, e3meshPartPtr, static); E3_POOL_DEFINE(TE3MeshPartPtr, e3meshPartPtr, static, 16); // TE3MeshVertexPtr typedef TE3MeshVertexData* TE3MeshVertexPtr; E3_PTR_ARRAY_DECLARE(TE3MeshVertexPtr, e3meshVertexPtr, static); E3_PTR_ARRAY_DEFINE(TE3MeshVertexPtr, e3meshVertexPtr, static, kE3MeshVertexPtr); // TE3MeshPartData struct TE3MeshPartData { union { TE3MeshPartData* newPartPtr; TE3MeshPartData** partHdl; } partPtrOrHdl; }; // TE3MeshContourData struct TE3MeshContourData { TE3MeshPartData part; // base class TE3MeshFaceData* containerFacePtr; TE3MeshVertexPtrArray vertexPtrArray; }; E3_ARRAY_OR_LIST_DECLARE(TE3MeshContourData, e3meshContour, static); E3_ARRAY_OR_LIST_DEFINE(TE3MeshContourData, e3meshContour, static, kE3MeshContour); // TE3MeshFaceData struct TE3MeshFaceData { TE3MeshPartData part; // base class TE3MeshContourDataArrayOrList contourArrayOrList; TQ3AttributeSet attributeSet; }; E3_ARRAY_OR_LIST_DECLARE(TE3MeshFaceData, e3meshFace, static); E3_ARRAY_OR_LIST_DEFINE(TE3MeshFaceData, e3meshFace, static, kE3MeshFace); // TE3MeshFacePtr typedef TE3MeshFaceData* TE3MeshFacePtr; E3_PTR_ARRAY_OR_LIST_DECLARE(TE3MeshFacePtr, e3meshFacePtr, static); E3_PTR_ARRAY_OR_LIST_DEFINE(TE3MeshFacePtr, e3meshFacePtr, static, kE3MeshFacePtr); // TE3MeshCornerData struct TE3MeshCornerData { // *** A corner is NOT a part! *** TE3MeshFacePtrArrayOrList facePtrArrayOrList; TQ3AttributeSet attributeSet; }; E3_ARRAY_OR_LIST_DECLARE(TE3MeshCornerData, e3meshCorner, static); E3_ARRAY_OR_LIST_DEFINE(TE3MeshCornerData, e3meshCorner, static, kE3MeshCorner); // TE3MeshVertexData struct TE3MeshVertexData { TE3MeshPartData part; // base class TQ3Point3D point; TE3MeshCornerDataArrayOrList cornerArrayOrList; TQ3AttributeSet attributeSet; }; E3_ARRAY_OR_LIST_DECLARE(TE3MeshVertexData, e3meshVertex, static); E3_ARRAY_OR_LIST_DEFINE(TE3MeshVertexData, e3meshVertex, static, kE3MeshVertex); // TQ3PolyhedronTriangleData E3_ARRAY_OR_LIST_DECLARE(TQ3PolyhedronTriangleData, e3polyhedronTriangle, static); E3_ARRAY_OR_LIST_DEFINE(TQ3PolyhedronTriangleData, e3polyhedronTriangle, static, kE3PolyhedronTriangle); // TE3MeshData struct TE3MeshData { // Note: In order for e3meshPartPtr_IsMeshPtr to be an effective function // for recognizing tags in partPtrPool, the first word of a mesh // structure must *not* be, in effect, a handle (TE3MeshData**) // referring back to this mesh! As the first word of a // TE3MeshPartPtrPool is a pointer (to a block or a free item) or // is null, making 'partPtrPool' the first member of a TE3MeshData // ensures that tags will work. TE3MeshPartPtrPool partPtrPool; TQ3Uns32 numCorners; TE3MeshVertexDataArrayOrList vertexArrayOrList; TE3MeshFaceDataArrayOrList faceArrayOrList; TQ3AttributeSet attributeSet; }; class E3Mesh : public E3Geometry // This is a leaf class so no other classes use this, // so it can be here in the .c file rather than in // the .h file, hence all the fields can be public // as nobody should be including this file { Q3_CLASS_ENUMS ( kQ3GeometryTypeMesh, E3Mesh, E3Geometry ) public : TE3MeshData instanceData ; // N.B. NOT TQ3MeshData } ; //============================================================================= // Internal functions //----------------------------------------------------------------------------- // e3meshPartPtr_Relink : Relink pointer to part. //----------------------------------------------------------------------------- // Warning : In contrast to other functions, the parameter for this // function is a pointer to a pointer, not a pointer! //----------------------------------------------------------------------------- // Note : See e3meshPart_Relocate. //----------------------------------------------------------------------------- static TQ3Status e3meshPartPtr_Relink( TE3MeshPartPtr* partHdl) { // Validate our parameters Q3_ASSERT_VALID_PTR(partHdl); Q3_ASSERT_VALID_PTR(*partHdl); (*partHdl) = (*partHdl)->partPtrOrHdl.newPartPtr; return(kQ3Success); } //============================================================================= // e3meshPartPtr_IsMeshPtr : Return if this part pointer is actually a // mesh pointer. //----------------------------------------------------------------------------- // Warning : In contrast to other functions, the parameter for this // function is a pointer to a pointer, not a pointer! //----------------------------------------------------------------------------- // Note : The e3meshPartPtr_IsMeshPtr function handles only allocated // master pointers. Unallocated pointers can be ignored because // pointers in the pool are allocated sequentially and the mesh // code never unallocates (frees) a master pointer -- except in // specific, well-defined cases where a pointer is allocated, // found to be unneeded, and immediately unallocated: "pop" then // "push". //----------------------------------------------------------------------------- static TQ3Boolean e3meshPartPtr_IsMeshPtr( const TE3MeshPartPtr* partHdl) { // Validate our parameters Q3_ASSERT_VALID_PTR(partHdl); // A null pointer is not a pointer to mesh data if ((*partHdl) == nullptr) return(kQ3False); // If this pointer points to a pointer that points back to this pointer, // it is a pointer to part data -- not mesh data if ((*partHdl)->partPtrOrHdl.partHdl == partHdl) return(kQ3False); return(kQ3True); } //============================================================================= // e3meshCornerPtr_Relink : Relink pointer to corner. //----------------------------------------------------------------------------- // Warning : In contrast to other functions, the parameter for this // function is a pointer to a pointer, not a pointer! //----------------------------------------------------------------------------- // Note : See e3meshCorner_Relocate. //----------------------------------------------------------------------------- #pragma mark - static void e3meshCornerPtr_Relink( TE3MeshCornerData** cornerHdl) { // Validate our parameters Q3_ASSERT_VALID_PTR(cornerHdl); // Get pointer to new corner from old corner's attribute set (*cornerHdl) = (TE3MeshCornerData*) (*cornerHdl)->attributeSet; } //============================================================================= // e3meshVertexPtr_Relink : Relink pointer to vertex. //----------------------------------------------------------------------------- // Warning : In contrast to other functions, the parameter for this // function is a pointer to a pointer, not a pointer! //----------------------------------------------------------------------------- #pragma mark - static TQ3Status e3meshVertexPtr_Relink( TE3MeshVertexPtr* vertexHdl, void* unusedArg) { (void)unusedArg; /* Suppress compiler warning */ return(e3meshPartPtr_Relink(E3_UP_CAST(TE3MeshPartPtr*, vertexHdl))); } //============================================================================= // e3meshFacePtr_Relink : Relink pointer to face. //----------------------------------------------------------------------------- // Warning : In contrast to other functions, the parameter for this // function is a pointer to a pointer, not a pointer! //----------------------------------------------------------------------------- #pragma mark - static TQ3Status e3meshFacePtr_Relink( TE3MeshFacePtr* faceHdl, void* unusedArg) { (void)unusedArg; /* Suppress compiler warning */ return(e3meshPartPtr_Relink(E3_UP_CAST(TE3MeshPartPtr*, faceHdl))); } //============================================================================= // e3meshPart_AcquireHandleInMesh : Acquire handle to part. //----------------------------------------------------------------------------- // Note : If unable to acquire handle (out of memory), return kQ3Failure. //----------------------------------------------------------------------------- #pragma mark - static TQ3Status e3meshPart_AcquireHandleInMesh( TE3MeshPartData* partPtr, TE3MeshData* meshPtr) { TE3MeshPartData** partHdl; // Validate our parameters Q3_ASSERT_VALID_PTR(partPtr); Q3_ASSERT_VALID_PTR(meshPtr); if (partPtr->partPtrOrHdl.partHdl == nullptr) { // Allocate master pointer to part from mesh's pool // Note: The type of items in the pool is, in effect, a union: // // union { // TE3MeshPartData* partPtr; // TE3MeshData* meshPtr; // }; // // Regular items in the pool are of type TE3MeshPartData* and tags in // the pool are of type TE3MeshData*. // // Neverthless, for simplicity the type is declared to be simply // TE3MeshPartData* and we use a type cast to coerce one pointer // type to the other. if ((partHdl = e3meshPartPtrPool_AllocateTagged( &meshPtr->partPtrPool, (const TE3MeshPartPtr*) &meshPtr)) == nullptr) goto failure; // Initialize master pointer to part *partHdl = partPtr; // Initialize part's handle to self partPtr->partPtrOrHdl.partHdl = partHdl; } return(kQ3Success); failure: return(kQ3Failure); } //============================================================================= // e3meshPart_ReleaseHandleInMesh : Release handle, if any, to part. //----------------------------------------------------------------------------- // Warning : Use this function with care! Releasing the handle to a part // that is still referenced will result in a fatal error. //----------------------------------------------------------------------------- static void e3meshPart_ReleaseHandleInMesh( TE3MeshPartData* partPtr, TE3MeshData* meshPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(partPtr); Q3_ASSERT_VALID_PTR(meshPtr); // Free master pointer to part in mesh's pool; set part's handle to self to nullptr e3meshPartPtrPool_Free(&meshPtr->partPtrPool, &partPtr->partPtrOrHdl.partHdl); } //============================================================================= // e3meshPart_HandleInMesh : Return handle to part. //----------------------------------------------------------------------------- // Note : If unable to get handle (out of memory), return nullptr. //----------------------------------------------------------------------------- static TE3MeshPartData** e3meshPart_HandleInMesh( TE3MeshPartData* partPtr, TE3MeshData* meshPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(partPtr); Q3_ASSERT_VALID_PTR(meshPtr); // Acquire handle to part if ( (partPtr == nullptr) || (e3meshPart_AcquireHandleInMesh(partPtr, meshPtr) == kQ3Failure) ) goto failure; return(partPtr->partPtrOrHdl.partHdl); failure: return(nullptr); } //============================================================================= // e3meshPart_CreateUnreferenced : TE3MeshPartData constructor. //----------------------------------------------------------------------------- static TQ3Status e3meshPart_CreateUnreferenced( TE3MeshPartData* partPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(partPtr); // Initialize handle partPtr->partPtrOrHdl.partHdl = nullptr; return(kQ3Success); } //============================================================================= // e3meshPart_Create : TE3MeshPartData constructor. //----------------------------------------------------------------------------- // Note : If unable to create (out of memory), return kQ3Failure. //----------------------------------------------------------------------------- static TQ3Status e3meshPart_Create( TE3MeshPartData* partPtr, TE3MeshData* meshPtr, TQ3Boolean isReferenced) { // Validate our parameters Q3_ASSERT_VALID_PTR(partPtr); Q3_ASSERT_VALID_PTR(meshPtr); // Initialize handle BEFORE calling e3meshPart_AcquireHandleInMesh partPtr->partPtrOrHdl.partHdl = nullptr; // If requested, acquire handle to part if (isReferenced) { if (e3meshPart_AcquireHandleInMesh(partPtr, meshPtr) == kQ3Failure) goto failure; } return(kQ3Success); failure: return(kQ3Failure); } //============================================================================= // e3meshPart_Destroy : TE3MeshPartData destructor. //----------------------------------------------------------------------------- static void e3meshPart_Destroy( TE3MeshPartData* partPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(partPtr); // If part has handle, clear master pointer to part if (partPtr->partPtrOrHdl.partHdl != nullptr) *partPtr->partPtrOrHdl.partHdl = nullptr; } //============================================================================= // e3meshPart_Relocate : Relocate part. //----------------------------------------------------------------------------- // Note : See also e3meshPartPtr_Relink. //----------------------------------------------------------------------------- static void e3meshPart_Relocate( TE3MeshPartData* newPartPtr, TE3MeshPartData* oldPartPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(newPartPtr); Q3_ASSERT_VALID_PTR(oldPartPtr); // If part has handle, update master pointer to part if (newPartPtr->partPtrOrHdl.partHdl != nullptr) *newPartPtr->partPtrOrHdl.partHdl = newPartPtr; // Save pointer to new part in old part oldPartPtr->partPtrOrHdl.newPartPtr = newPartPtr; } //============================================================================= // e3meshPartHdl_Part : Return part for part handle. //----------------------------------------------------------------------------- // Note : If part deleted, return nullptr. //----------------------------------------------------------------------------- #pragma mark - static TE3MeshPartData* e3meshPartHdl_Part( TE3MeshPartData** partHdl) { // Validate our parameters Q3_ASSERT_VALID_PTR(partHdl); return(*partHdl); } //============================================================================= // e3meshPartHdl_Mesh : Return mesh for part handle. //----------------------------------------------------------------------------- // Note : This is a subtle function. It takes a handle (pointer to // pointer) to a mesh part (vertex, contour, face, edge or // component) and returns the containing mesh, even though parts // don't store pointers to their containing mesh. This is possible // because part handles point to master pointers in a pool of // master pointers, and the pool has been "tagged" with a pointer // to the mesh. The subtle part is that the pool can contain // allocated non-null or null master pointers, and unallocated // pointers. See e3meshPartPtr_IsMeshPtr. //----------------------------------------------------------------------------- static TE3MeshData* e3meshPartHdl_Mesh( TE3MeshPartData** partHdl) { // Validate our parameters Q3_ASSERT_VALID_PTR(partHdl); return(* (TE3MeshData**) e3meshPartPtrPoolItem_Tag(partHdl, &e3meshPartPtr_IsMeshPtr)); } //============================================================================= // e3meshCorner_CreateEmptyListOfFacePtrs : TE3MeshCornerData constructor. //----------------------------------------------------------------------------- // Note : If unable to create (out of memory), return kQ3Failure. //----------------------------------------------------------------------------- #pragma mark - static TQ3Status e3meshCorner_CreateEmptyListOfFacePtrs( TE3MeshCornerData* cornerPtr, TQ3AttributeSet attributeSet) { // Validate our parameters Q3_ASSERT_VALID_PTR(cornerPtr); // Must have a non-null attribute set Q3_ASSERT_VALID_PTR(attributeSet); // Create empty list of face pointers if (e3meshFacePtrList_Create(&cornerPtr->facePtrArrayOrList.list, 0, nullptr) == kQ3Failure) goto failure; // Initialize attribute set E3Shared_Acquire(&cornerPtr->attributeSet, attributeSet); return(kQ3Success); // Dead code to reverse e3meshFacePtrList_Create failure: return(kQ3Failure); } //============================================================================= // e3meshCorner_CreateFromExtData : TE3MeshCornerData constructor from // external data. //----------------------------------------------------------------------------- // Note : If face indices out-of-range or duplicated, if corner attribute // set null, or if unable to create (out of memory), return // kQ3Failure. //----------------------------------------------------------------------------- static TQ3Status e3meshCorner_CreateFromExtData( TE3MeshCornerData* cornerPtr, const TQ3MeshCornerData* cornerExtDataPtr, TE3MeshFaceDataArray* meshFaceArrayPtr) { TQ3Uns32 meshNumFaces; TE3MeshFaceData* meshFaces; TQ3Uns32 numFaces; const TQ3Uns32* faceIndices; TE3MeshFacePtr* facePtrs; TQ3Uns32 i; // Validate our parameters Q3_ASSERT_VALID_PTR(cornerPtr); Q3_ASSERT_VALID_PTR(cornerExtDataPtr); Q3_ASSERT_VALID_PTR(meshFaceArrayPtr); // Get mesh faces meshNumFaces = e3meshFaceArray_Length(meshFaceArrayPtr); meshFaces = e3meshFaceArray_FirstItem(meshFaceArrayPtr); // Get and validate face indices numFaces = cornerExtDataPtr->numFaces; faceIndices = cornerExtDataPtr->faceIndices; if (numFaces == 0) goto failure_1; if (faceIndices == nullptr) goto failure_2; // Check for out-of-range or duplicate face indices for (i = 0; i < numFaces; ++i) { TQ3Uns32 faceIndex = faceIndices[i]; TQ3Uns32 i2; if (faceIndex >= meshNumFaces) goto failure_3; for (i2 = 0; i2 < i; ++i2) { TQ3Uns32 faceIndex2 = faceIndices[i2]; if (faceIndex == faceIndex2) goto failure_4; } } // Check for null attribute set if (cornerExtDataPtr->cornerAttributeSet == nullptr) goto failure_5; // Create array of uninitialized face pointers if (e3meshFacePtrArray_Create(&cornerPtr->facePtrArrayOrList.array, numFaces, nullptr) == kQ3Failure) goto failure_6; // Initialize face pointers facePtrs = e3meshFacePtrArray_FirstItem(&cornerPtr->facePtrArrayOrList.array); for (i = 0; i < numFaces; ++i) facePtrs[i] = &meshFaces[faceIndices[i]]; // Initialize attribute set E3Shared_Acquire(&cornerPtr->attributeSet, cornerExtDataPtr->cornerAttributeSet); return(kQ3Success); // Dead code to reverse e3meshFacePtrArray_Create failure_6: failure_5: failure_4: failure_3: failure_2: failure_1: return(kQ3Failure); } //============================================================================= // e3meshCorner_Destroy : TE3MeshCornerData destructor. //----------------------------------------------------------------------------- static void e3meshCorner_Destroy( TE3MeshCornerData* cornerPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(cornerPtr); // Release attribute set Q3Object_CleanDispose(&cornerPtr->attributeSet); // Destroy face pointer array or list e3meshFacePtrArrayOrList_Destroy(&cornerPtr->facePtrArrayOrList, nullptr); } //============================================================================= // e3meshCorner_Relocate : Relocate corner. //----------------------------------------------------------------------------- // Note : See also e3meshCornerPtr_Relink. //----------------------------------------------------------------------------- static void e3meshCorner_Relocate( TE3MeshCornerData* newCornerPtr, TE3MeshCornerData* oldCornerPtr) { // Save pointer to new corner in old corner's attribute set *((TE3MeshCornerData**) &oldCornerPtr->attributeSet) = newCornerPtr; } //============================================================================= // e3meshCorner_RelinkFaces : Relink pointers to faces. //----------------------------------------------------------------------------- static TQ3Status e3meshCorner_RelinkFaces( TE3MeshCornerData* cornerPtr, void* unusedArg) { (void)unusedArg; /* Suppress compiler warning */ // Validate our parameters Q3_ASSERT_VALID_PTR(cornerPtr); return(e3meshFacePtrArrayOrList_DoForEach( &cornerPtr->facePtrArrayOrList, &e3meshFacePtr_Relink, nullptr)); } //============================================================================= // e3meshCorner_UseFacePtrArray : Use face pointer array. //----------------------------------------------------------------------------- // Note : If unable to convert (out of memory), return kQ3Failure. //----------------------------------------------------------------------------- static TQ3Status e3meshCorner_UseFacePtrArray( TE3MeshCornerData* cornerPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(cornerPtr); return(e3meshFacePtrArrayOrList_UseArray( &cornerPtr->facePtrArrayOrList, nullptr, nullptr, nullptr)); } //============================================================================= // e3meshCorner_UseFacePtrList : Use face pointer list. //----------------------------------------------------------------------------- // Note : If unable to convert (out of memory), return kQ3Failure. //----------------------------------------------------------------------------- static TQ3Status e3meshCorner_UseFacePtrList( TE3MeshCornerData* cornerPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(cornerPtr); return(e3meshFacePtrArrayOrList_UseList( &cornerPtr->facePtrArrayOrList, nullptr, nullptr, nullptr)); } //============================================================================= // e3meshCorner_NumFaces : Return number of faces for corner. //----------------------------------------------------------------------------- static TQ3Uns32 e3meshCorner_NumFaces( const TE3MeshCornerData* cornerPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(cornerPtr); return(e3meshFacePtrArrayOrList_Length(&cornerPtr->facePtrArrayOrList)); } //============================================================================= // e3meshCorner_HasFace : Return if corner has face. //----------------------------------------------------------------------------- static TQ3Boolean e3meshCorner_HasFace( const TE3MeshCornerData* cornerPtr, TE3MeshFaceData* facePtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(cornerPtr); Q3_ASSERT_VALID_PTR(facePtr); return(e3meshFacePtrArrayOrList_HasPtr( &cornerPtr->facePtrArrayOrList, facePtr)); } //============================================================================= // e3meshCorner_AttachFace : Attach face to corner. //----------------------------------------------------------------------------- // Note : If unable to use list of face pointers of if unable to insert // face pointer, return kQ3Failure. //----------------------------------------------------------------------------- static TQ3Status e3meshCorner_AttachFace( TE3MeshCornerData* cornerPtr, TE3MeshFaceData* facePtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(cornerPtr); Q3_ASSERT_VALID_PTR(facePtr); // Use list of face pointers (*** MAY RELOCATE FACE POINTERS ***) if (e3meshCorner_UseFacePtrList(cornerPtr) == kQ3Failure) goto failure_1; // Push back face pointer if (e3meshFacePtrList_PushBackPtr(&cornerPtr->facePtrArrayOrList.list, facePtr) == nullptr) goto failure_2; return(kQ3Success); // Dead code to reverse e3meshFacePtrList_PushBackPtr failure_2: failure_1: return(kQ3Failure); } //============================================================================= // e3meshCorner_DetachFace : Detach face from corner. //----------------------------------------------------------------------------- // Note : If unable to use list of face pointers, return kQ3Failure. //----------------------------------------------------------------------------- static TQ3Status e3meshCorner_DetachFace( TE3MeshCornerData* cornerPtr, TE3MeshFaceData* facePtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(cornerPtr); Q3_ASSERT_VALID_PTR(facePtr); // Use list of face pointers (*** MAY RELOCATE FACE POINTERS ***) if (e3meshCorner_UseFacePtrList(cornerPtr) == kQ3Failure) goto failure_1; // Erase face pointer if (e3meshFacePtrList_ErasePtr(&cornerPtr->facePtrArrayOrList.list, facePtr) == kQ3Failure) goto failure_2; return(kQ3Success); // Dead code to reverse e3meshFacePtrList_ErasePtr failure_2: failure_1: return(kQ3Failure); } //============================================================================= // e3meshCorner_SpliceFace : Splice face into new corner from old corner. //----------------------------------------------------------------------------- // Note : If unable to use list of face pointers, return kQ3Failure. //----------------------------------------------------------------------------- static TQ3Status e3meshCorner_SpliceFace( TE3MeshCornerData* newCornerPtr, TE3MeshCornerData* oldCornerPtr, TE3MeshFaceData* facePtr) { TE3MeshFaceData** faceHdl; // Validate our parameters Q3_ASSERT_VALID_PTR(newCornerPtr); Q3_ASSERT_VALID_PTR(oldCornerPtr); Q3_ASSERT_VALID_PTR(facePtr); // Use list of face pointers (*** MAY RELOCATE FACE POINTERS ***) if (e3meshCorner_UseFacePtrList(oldCornerPtr) == kQ3Failure) goto failure_1; // Find face pointer for old corner if ((faceHdl = e3meshFacePtrList_FindPtr(&oldCornerPtr->facePtrArrayOrList.list, facePtr)) == nullptr) goto failure_2; // Use list of face pointers (*** MAY RELOCATE FACE POINTERS ***) if (e3meshCorner_UseFacePtrList(newCornerPtr) == kQ3Failure) goto failure_3; // Splice face pointer e3meshFacePtrList_SpliceBackListItem( &newCornerPtr->facePtrArrayOrList.list, &oldCornerPtr->facePtrArrayOrList.list, faceHdl); return(kQ3Success); failure_3: failure_2: failure_1: return(kQ3Failure); } //============================================================================= // e3meshCorner_HasAttributeSet : Return if corner has attribute set. //----------------------------------------------------------------------------- static TQ3Boolean e3meshCorner_HasAttributeSet( const TE3MeshCornerData* cornerPtr, TQ3AttributeSet attributeSet) { // Validate our parameters Q3_ASSERT_VALID_PTR(cornerPtr); Q3_ASSERT_VALID_PTR(attributeSet); return(cornerPtr->attributeSet == attributeSet ? kQ3True : kQ3False); } //============================================================================= // e3meshCorner_GetExtData : Get external data. //----------------------------------------------------------------------------- // Note : If unable to get (out of memory), return kQ3Failure. //----------------------------------------------------------------------------- static TQ3Status e3meshCorner_GetExtData( const TE3MeshCornerData* cornerPtr, TQ3MeshCornerData* cornerExtDataPtr, const TE3MeshFaceDataArray* meshFaceArrayPtr) { const TE3MeshFaceData* meshFaces; TQ3Uns32 numFaces; TQ3Uns32* faceIndices; const TE3MeshFacePtr* facePtrs; TQ3Uns32 i; // Validate our parameters Q3_ASSERT_VALID_PTR(cornerPtr); Q3_ASSERT_VALID_PTR(cornerExtDataPtr); Q3_ASSERT_VALID_PTR(meshFaceArrayPtr); // Get mesh faces meshFaces = e3meshFaceArray_FirstItemConst(meshFaceArrayPtr); // Use array of face pointers (*** MAY RELOCATE FACE POINTERS ***) if (e3meshCorner_UseFacePtrArray(E3_CONST_CAST(TE3MeshCornerData*, cornerPtr)) == kQ3Failure) goto failure_1; // Allocate array of uninitialized face indices numFaces = e3meshCorner_NumFaces(cornerPtr); if ((faceIndices = (TQ3Uns32*) Q3Memory_Allocate(numFaces * sizeof(TQ3Uns32))) == nullptr) goto failure_2; cornerExtDataPtr->numFaces = numFaces; cornerExtDataPtr->faceIndices = faceIndices; // Get face indices facePtrs = e3meshFacePtrArray_FirstItemConst(&cornerPtr->facePtrArrayOrList.array); for (i = 0; i < numFaces; ++i) faceIndices[i] = static_cast<TQ3Uns32>(facePtrs[i] - meshFaces); // Get attribute set E3Shared_Acquire(&cornerExtDataPtr->cornerAttributeSet, cornerPtr->attributeSet); return(kQ3Success); // Dead code to reverse Q3Memory_Allocate failure_2: failure_1: return(kQ3Failure); } //============================================================================= // e3meshCornerExtData_Empty : Empty external data. //----------------------------------------------------------------------------- #pragma mark - static TQ3Status e3meshCornerExtData_Empty( TQ3MeshCornerData* cornerExtDataPtr) { TQ3Status result = kQ3Success; TQ3Uns32 numFaces; TQ3Uns32* faceIndices; // Validate our parameters Q3_ASSERT_VALID_PTR(cornerExtDataPtr); // Release attribute set Q3Object_CleanDispose(&cornerExtDataPtr->cornerAttributeSet); // Validate face indices numFaces = cornerExtDataPtr->numFaces; faceIndices = cornerExtDataPtr->faceIndices; if (numFaces == 0) result = kQ3Failure; if (faceIndices == nullptr) result = kQ3Failure; // Deallocate array of face indices Q3Memory_Free(&cornerExtDataPtr->faceIndices); cornerExtDataPtr->numFaces = 0; return(result); } //============================================================================= // e3meshVertex_CreateEmptyArrayOfCorners : TE3MeshVertexData constructor. //----------------------------------------------------------------------------- // Note : If unable to create (out of memory), return kQ3Failure. //----------------------------------------------------------------------------- #pragma mark - static TQ3Status e3meshVertex_CreateEmptyArrayOfCorners( TE3MeshVertexData* vertexPtr, TE3MeshData* meshPtr, TQ3Boolean isReferenced, const TQ3Vertex3D* vertexExtDataPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(vertexPtr); Q3_ASSERT_VALID_PTR(meshPtr); Q3_ASSERT_VALID_PTR(vertexExtDataPtr); // Create part if (e3meshPart_Create(&vertexPtr->part, meshPtr, isReferenced) == kQ3Failure) goto failure_1; // Initialize point vertexPtr->point = vertexExtDataPtr->point; // Create empty array of corners if (e3meshCornerArray_Create(&vertexPtr->cornerArrayOrList.array, 0, nullptr) == kQ3Failure) goto failure_2; // Initialize attribute set E3Shared_Acquire(&vertexPtr->attributeSet, vertexExtDataPtr->attributeSet); return(kQ3Success); // Dead code to reverse e3meshCornerArray_Create failure_2: e3meshPart_ReleaseHandleInMesh(&vertexPtr->part, meshPtr); e3meshPart_Destroy(&vertexPtr->part); failure_1: return(kQ3Failure); } //============================================================================= // e3meshVertex_CreateFromExtData : TE3MeshVertexData constructor from // external data. //----------------------------------------------------------------------------- // Note : If unable to create (out of memory), return kQ3Failure. //----------------------------------------------------------------------------- static TQ3Status e3meshVertex_CreateFromExtData( TE3MeshVertexData* vertexPtr, const TQ3MeshVertexData* vertexExtDataPtr, TE3MeshFaceDataArray* meshFaceArrayPtr) { TQ3Uns32 numCorners; const TQ3MeshCornerData* cornerExtDatas; TE3MeshCornerData* corners; TQ3Uns32 iSave; TQ3Uns32 i1, j1, i2, j2; // Validate our parameters Q3_ASSERT_VALID_PTR(vertexPtr); Q3_ASSERT_VALID_PTR(vertexExtDataPtr); Q3_ASSERT_VALID_PTR(meshFaceArrayPtr); // Create part, without reference if (e3meshPart_CreateUnreferenced(&vertexPtr->part) == kQ3Failure) goto failure_1; // Initialize point vertexPtr->point = vertexExtDataPtr->point; // Get and validate corners numCorners = vertexExtDataPtr->numCorners; cornerExtDatas = vertexExtDataPtr->corners; if (numCorners > 0 && cornerExtDatas == nullptr) goto failure_2; // Create array of uninitialized corners if (e3meshCornerArray_Create(&vertexPtr->cornerArrayOrList.array, numCorners, nullptr) == kQ3Failure) goto failure_3; // Initialize corners corners = e3meshCornerArray_FirstItem(&vertexPtr->cornerArrayOrList.array); for (iSave = 0; iSave < numCorners; ++iSave) if (e3meshCorner_CreateFromExtData(&corners[iSave], &cornerExtDatas[iSave], meshFaceArrayPtr) == kQ3Failure) goto failure_4; // Check for duplicate face indices (in different corners for this vertex) for (i2 = 0; i2 < numCorners; ++i2) { TQ3Uns32 cornerNumFaces2 = cornerExtDatas[i2].numFaces; TQ3Uns32* cornerFacesIndices2 = cornerExtDatas[i2].faceIndices; for (j2 = 0; j2 < cornerNumFaces2; ++j2) { TQ3Uns32 faceIndex2 = cornerFacesIndices2[j2]; for (i1 = 0; i1 < i2; ++i1) { TQ3Uns32 cornerNumFaces1 = cornerExtDatas[i1].numFaces; TQ3Uns32* cornerFacesIndices1 = cornerExtDatas[i1].faceIndices; for (j1 = 0; j1 < cornerNumFaces1; ++j1) { TQ3Uns32 faceIndex1 = cornerFacesIndices1[j1]; if (faceIndex1 == faceIndex2) goto failure_5; } } } } // Initialize attribute set E3Shared_Acquire(&vertexPtr->attributeSet, vertexExtDataPtr->attributeSet); return(kQ3Success); failure_5: failure_4: while (iSave > 0) e3meshCorner_Destroy(&corners[--iSave]); e3meshCornerArray_Destroy(&vertexPtr->cornerArrayOrList.array, nullptr); failure_3: failure_2: e3meshPart_Destroy(&vertexPtr->part); failure_1: return(kQ3Failure); } //============================================================================= // e3meshVertex_Destroy : TE3MeshVertexData destructor. //----------------------------------------------------------------------------- static void e3meshVertex_Destroy( TE3MeshVertexData* vertexPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(vertexPtr); // Release attribute set Q3Object_CleanDispose(&vertexPtr->attributeSet); // Destroy corner array or list e3meshCornerArrayOrList_Destroy(&vertexPtr->cornerArrayOrList, e3meshCorner_Destroy); // Destroy part e3meshPart_Destroy(&vertexPtr->part); } //============================================================================= // e3meshVertex_Relocate : Relocate vertex. //----------------------------------------------------------------------------- static void e3meshVertex_Relocate( TE3MeshVertexData* newVertexPtr, TE3MeshVertexData* oldVertexPtr) { // Relocate part e3meshPart_Relocate( &newVertexPtr->part, &oldVertexPtr->part); } //============================================================================= // e3meshVertex_RelinkCornerFaces : Relink pointers to corner faces. //----------------------------------------------------------------------------- static TQ3Status e3meshVertex_RelinkCornerFaces( TE3MeshVertexData* vertexPtr, void* unusedArg) { (void)unusedArg; /* Suppress compiler warning */ // Validate our parameters Q3_ASSERT_VALID_PTR(vertexPtr); return(e3meshCornerArrayOrList_DoForEach( &vertexPtr->cornerArrayOrList, &e3meshCorner_RelinkFaces, nullptr)); } //============================================================================= // e3meshVertex_UseCornerArray : Use corner array, optionally relinking // corner pointer. //----------------------------------------------------------------------------- // Note : If unable to convert (out of memory), return kQ3Failure. //----------------------------------------------------------------------------- static TQ3Status e3meshVertex_UseCornerArray( TE3MeshVertexData* vertexPtr, TE3MeshCornerData** cornerHdl) { // Validate our parameters Q3_ASSERT_VALID_PTR(vertexPtr); if (cornerHdl == nullptr) return(e3meshCornerArrayOrList_UseArray( &vertexPtr->cornerArrayOrList, nullptr, nullptr, nullptr)); else return(e3meshCornerArrayOrList_UseArray( &vertexPtr->cornerArrayOrList, nullptr, E3_UP_CAST(void (*)(void*), &e3meshCornerPtr_Relink), cornerHdl)); } //============================================================================= // e3meshVertex_UseCornerList : Use corner list, optionally relinking // corner pointer. //----------------------------------------------------------------------------- // Note : If unable to convert (out of memory), return kQ3Failure. //----------------------------------------------------------------------------- static TQ3Status e3meshVertex_UseCornerList( TE3MeshVertexData* vertexPtr, TE3MeshCornerData** cornerHdl) { // Validate our parameters Q3_ASSERT_VALID_PTR(vertexPtr); if (cornerHdl == nullptr) return(e3meshCornerArrayOrList_UseList( &vertexPtr->cornerArrayOrList, nullptr, nullptr, nullptr)); else return(e3meshCornerArrayOrList_UseList( &vertexPtr->cornerArrayOrList, nullptr, E3_UP_CAST(void (*)(void*), &e3meshCornerPtr_Relink), cornerHdl)); } //============================================================================= // e3meshVertex_NumCorners : Return number of corners in vertex. //----------------------------------------------------------------------------- static TQ3Uns32 e3meshVertex_NumCorners( const TE3MeshVertexData* vertexPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(vertexPtr); return(e3meshCornerArrayOrList_Length(&vertexPtr->cornerArrayOrList)); } //============================================================================= // e3meshVertex_NewCorner : Return new empty corner for vertex. //----------------------------------------------------------------------------- // Note : If unable to use list of corners, if unable to insert corner // item, or if unable to create corner, return nullptr. //----------------------------------------------------------------------------- static TE3MeshCornerData* e3meshVertex_NewCorner( TE3MeshVertexData* vertexPtr, TE3MeshData* meshPtr, TQ3AttributeSet attributeSet) { TE3MeshCornerData* cornerPtr; // Validate our parameters Q3_ASSERT_VALID_PTR(vertexPtr); Q3_ASSERT_VALID_PTR(meshPtr); // Must have a non-null attribute set Q3_ASSERT_VALID_PTR(attributeSet); // Use list of corners (*** MAY RELOCATE CORNERS ***) if (e3meshVertex_UseCornerList(vertexPtr, nullptr) == kQ3Failure) goto failure_1; // Push back new uninitialized corner if ((cornerPtr = e3meshCornerList_PushBackItem(&vertexPtr->cornerArrayOrList.list, nullptr)) == nullptr) goto failure_2; // Create corner with empty list of face pointers if (e3meshCorner_CreateEmptyListOfFacePtrs(cornerPtr, attributeSet) == kQ3Failure) goto failure_3; // Increment number of (defined) corners in mesh ++meshPtr->numCorners; return(cornerPtr); // Dead code to reverse e3meshCorner_CreateEmptyListOfFacePtrs failure_3: e3meshCornerList_EraseItem(&vertexPtr->cornerArrayOrList.list, nullptr, cornerPtr); failure_2: failure_1: return(nullptr); } //============================================================================= // e3meshVertex_DeleteCorner : Delete corner from vertex. //----------------------------------------------------------------------------- // Note : If unable to use list of corners, return kQ3Failure. //----------------------------------------------------------------------------- static TQ3Status e3meshVertex_DeleteCorner( TE3MeshVertexData* vertexPtr, TE3MeshData* meshPtr, TE3MeshCornerData* cornerPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(vertexPtr); Q3_ASSERT_VALID_PTR(meshPtr); Q3_ASSERT_VALID_PTR(cornerPtr); // Use list of corners (*** MAY RELOCATE CORNERS ***) if (e3meshVertex_UseCornerList(vertexPtr, &cornerPtr) == kQ3Failure) goto failure; // Erase corner e3meshCornerList_EraseItem(&vertexPtr->cornerArrayOrList.list, nullptr, cornerPtr); // Decrement number of (defined) corners in mesh --meshPtr->numCorners; return(kQ3Success); failure: return(kQ3Failure); } //============================================================================= // e3meshVertex_FaceCorner : Return corner for vertex-face combination. //----------------------------------------------------------------------------- // Note : If corner undefined, return nullptr. //----------------------------------------------------------------------------- static TE3MeshCornerData* e3meshVertex_FaceCorner( const TE3MeshVertexData* vertexPtr, const TE3MeshFaceData* facePtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(vertexPtr); Q3_ASSERT_VALID_PTR(facePtr); return(e3meshCornerArrayOrList_Find( &vertexPtr->cornerArrayOrList, E3_DOWN_CAST(TQ3Boolean (*)(const TE3MeshCornerData*, void*), &e3meshCorner_HasFace), (void*)facePtr)); } //============================================================================= // e3meshVertex_AttributeSetCorner : Return corner for vertex-attribute // set combination. //----------------------------------------------------------------------------- // Note : If corner undefined, return nullptr. //----------------------------------------------------------------------------- static TE3MeshCornerData* e3meshVertex_AttributeSetCorner( TE3MeshVertexData* vertexPtr, TE3MeshData* meshPtr, TQ3AttributeSet attributeSet) { // Validate our parameters Q3_ASSERT_VALID_PTR(vertexPtr); Q3_ASSERT_VALID_PTR(meshPtr); Q3_ASSERT_VALID_PTR(attributeSet); return(e3meshCornerArrayOrList_Find( &vertexPtr->cornerArrayOrList, E3_DOWN_CAST(TQ3Boolean (*)(const TE3MeshCornerData*, void*), &e3meshCorner_HasAttributeSet), attributeSet)); } //============================================================================= // e3meshVertex_ExtRefInMesh : Return external reference to vertex. //----------------------------------------------------------------------------- // Note : If unable to get external reference (out of memory), return nullptr. //----------------------------------------------------------------------------- static TE3MeshVertexExtRef e3meshVertex_ExtRefInMesh( TE3MeshVertexData* vertexPtr, TE3MeshData* meshPtr) { return(E3_DOWN_CAST(TE3MeshVertexExtRef, e3meshPart_HandleInMesh( &vertexPtr->part, meshPtr))); } //============================================================================= // e3meshVertex_GetExtData : Get external data. //----------------------------------------------------------------------------- // Note : If unable to get (out of memory), return kQ3Failure. //----------------------------------------------------------------------------- static TQ3Status e3meshVertex_GetExtData( const TE3MeshVertexData* vertexPtr, TQ3MeshVertexData* vertexExtDataPtr, const TE3MeshFaceDataArray* meshFaceArrayPtr) { TQ3Uns32 numCorners; TQ3MeshCornerData* cornerExtDatas; const TE3MeshCornerData* corners; TQ3Uns32 iSave; // Validate our parameters Q3_ASSERT_VALID_PTR(vertexPtr); Q3_ASSERT_VALID_PTR(vertexExtDataPtr); Q3_ASSERT_VALID_PTR(meshFaceArrayPtr); // Get point vertexExtDataPtr->point = vertexPtr->point; // Use array of corners (*** MAY RELOCATE CORNERS ***) if (e3meshVertex_UseCornerArray(E3_CONST_CAST(TE3MeshVertexData*, vertexPtr), nullptr) == kQ3Failure) goto failure_1; // Allocate array of uninitialized corners numCorners = e3meshVertex_NumCorners(vertexPtr); if (numCorners == 0) cornerExtDatas = nullptr; else if ((cornerExtDatas = (TQ3MeshCornerData*) Q3Memory_Allocate(numCorners * sizeof(TQ3MeshCornerData))) == nullptr) goto failure_2; vertexExtDataPtr->numCorners = numCorners; vertexExtDataPtr->corners = cornerExtDatas; // Get corners corners = e3meshCornerArray_FirstItemConst(&vertexPtr->cornerArrayOrList.array); for (iSave = 0; iSave < numCorners; ++iSave) if (e3meshCorner_GetExtData(&corners[iSave], &cornerExtDatas[iSave], meshFaceArrayPtr) == kQ3Failure) goto failure_3; // Get attribute set E3Shared_Acquire(&vertexExtDataPtr->attributeSet, vertexPtr->attributeSet); return(kQ3Success); failure_3: while (iSave > 0) e3meshCornerExtData_Empty(&cornerExtDatas[--iSave]); Q3Memory_Free(&cornerExtDatas); failure_2: failure_1: return(kQ3Failure); } //============================================================================= // e3meshVertexExtRef_Vertex : Return vertex for external reference. //----------------------------------------------------------------------------- // Note : If vertex deleted, return nullptr. //----------------------------------------------------------------------------- #pragma mark - static TE3MeshVertexData* e3meshVertexExtRef_Vertex( TE3MeshVertexExtRef vertexExtRef) { return(E3_DOWN_CAST(TE3MeshVertexData*, e3meshPartHdl_Part( E3_UP_CAST(TE3MeshPartData**, vertexExtRef)))); } //============================================================================= // e3meshVertexExtRef_Mesh : Return mesh for external reference. //----------------------------------------------------------------------------- static TE3MeshData* e3meshVertexExtRef_Mesh( TE3MeshVertexExtRef vertexExtRef) { return(e3meshPartHdl_Mesh(E3_UP_CAST(TE3MeshPartData**, vertexExtRef))); } //============================================================================= // e3meshVertexExtData_Empty : Empty external data. //----------------------------------------------------------------------------- #pragma mark - static TQ3Status e3meshVertexExtData_Empty( TQ3MeshVertexData* vertexExtDataPtr) { TQ3Status result = kQ3Success; TQ3Uns32 numCorners; TQ3MeshCornerData* cornerExtDatas; TQ3Uns32 i; // Validate our parameters Q3_ASSERT_VALID_PTR(vertexExtDataPtr); // Release attribute set Q3Object_CleanDispose(&vertexExtDataPtr->attributeSet); // Validate and empty corners numCorners = vertexExtDataPtr->numCorners; cornerExtDatas = vertexExtDataPtr->corners; if (numCorners > 0 && cornerExtDatas == nullptr) result = kQ3Failure; else { // Empty corners for (i = 0; i < numCorners; ++i) if (e3meshCornerExtData_Empty(&cornerExtDatas[i]) == kQ3Failure) result = kQ3Failure; } // Deallocate array of corners Q3Memory_Free(&vertexExtDataPtr->corners); vertexExtDataPtr->numCorners = 0; return(result); } //============================================================================= // e3meshContour_CreateFromVertexExtRefs : TE3MeshContourData constructor // from an array of vertex // external references. //----------------------------------------------------------------------------- // Note : If any vertex is deleted or if unable to create (out of memory), // return kQ3Failure. If a particular vertex occurs more than once // in succession, repeated occurrences are eliminated. If after // this elimination less than 2 vertices remain, return kQ3Failure. // Thus we ensure that every edge connects two distinct vertices. //----------------------------------------------------------------------------- #pragma mark - static TQ3Status e3meshContour_CreateFromVertexExtRefs( TE3MeshContourData* contourPtr, TE3MeshData* meshPtr, TQ3Boolean isReferenced, TE3MeshFaceData* containerFacePtr, TQ3Uns32 numVertices, const TE3MeshVertexExtRef* vertexExtRefs) { TQ3Uns32 effectiveNumVertices; TE3MeshVertexPtr* vertexPtrs; TQ3Uns32 i, i2; // Validate our parameters Q3_ASSERT_VALID_PTR(contourPtr); Q3_ASSERT_VALID_PTR(meshPtr); Q3_ASSERT_VALID_PTR(containerFacePtr); Q3_ASSERT_VALID_PTR(vertexExtRefs); // Check for deleted vertices; count effective number of vertices (excluding repeats) effectiveNumVertices = 0; for (i = 0; i < numVertices; ++i) { if (e3meshVertexExtRef_Vertex(vertexExtRefs[i]) == nullptr) goto failure_1; if (vertexExtRefs[i] != vertexExtRefs[i > 0 ? i-1 : numVertices-1]) ++effectiveNumVertices; } if (effectiveNumVertices < 2) goto failure_2; // Create part if (e3meshPart_Create(&contourPtr->part, meshPtr, isReferenced) == kQ3Failure) goto failure_3; // Initialize pointer to container face contourPtr->containerFacePtr = containerFacePtr; // Create array of uninitialized vertex pointers if (e3meshVertexPtrArray_Create(&contourPtr->vertexPtrArray, effectiveNumVertices, nullptr) == kQ3Failure) goto failure_4; // Initialize vertex pointers vertexPtrs = e3meshVertexPtrArray_FirstItem(&contourPtr->vertexPtrArray); for (i = 0, i2 = 0; i < numVertices; ++i) if (vertexExtRefs[i] != vertexExtRefs[i > 0 ? i-1 : numVertices-1]) vertexPtrs[i2++] = e3meshVertexExtRef_Vertex(vertexExtRefs[i]); return(kQ3Success); // Dead code to reverse e3meshVertexPtrArray_Create failure_4: e3meshPart_ReleaseHandleInMesh(&contourPtr->part, meshPtr); e3meshPart_Destroy(&contourPtr->part); failure_3: failure_2: failure_1: return(kQ3Failure); } //============================================================================= // e3meshContour_CreateFromExtData : TE3MeshContourData constructor from // external data. //----------------------------------------------------------------------------- // Warning : Upon entry, the mesh vertices must be organized in an array. //----------------------------------------------------------------------------- // Note : If any vertex index is out of range or if unable to create // (out of memory), return kQ3Failure. If a particular vertex // occurs more than once in succession, repeated occurrences are // eliminated. If after this elimination less than 2 vertices // remain, return kQ3Failure. Thus we ensure that every edge // connects two distinct vertices. //----------------------------------------------------------------------------- static TQ3Status e3meshContour_CreateFromExtData( TE3MeshContourData* contourPtr, TE3MeshFaceData* containerFacePtr, const TQ3MeshContourData* contourExtDataPtr, TE3MeshVertexDataArray* meshVertexArrayPtr) { TQ3Uns32 meshNumVertices; TE3MeshVertexData* meshVertices; TQ3Uns32 numVertices, effectiveNumVertices; const TQ3Uns32* vertexIndices; TE3MeshVertexPtr* vertexPtrs; TQ3Uns32 i, i2; // Validate our parameters Q3_ASSERT_VALID_PTR(contourPtr); Q3_ASSERT_VALID_PTR(containerFacePtr); Q3_ASSERT_VALID_PTR(contourExtDataPtr); Q3_ASSERT_VALID_PTR(meshVertexArrayPtr); // Get mesh vertices meshNumVertices = e3meshVertexArray_Length(meshVertexArrayPtr); meshVertices = e3meshVertexArray_FirstItem(meshVertexArrayPtr); // Get and validate vertex indices numVertices = contourExtDataPtr->numVertices; vertexIndices = contourExtDataPtr->vertexIndices; if (numVertices > 0 && vertexIndices == nullptr) goto failure_2; // Check for out-of-range vertex indices; count effective number of vertices (excluding repeats) effectiveNumVertices = 0; for (i = 0; i < numVertices; ++i) { if (vertexIndices[i] >= meshNumVertices) goto failure_1; if (vertexIndices[i] != vertexIndices[i > 0 ? i-1 : numVertices-1]) ++effectiveNumVertices; } if (effectiveNumVertices < 2) goto failure_2; // Create part, without reference if (e3meshPart_CreateUnreferenced(&contourPtr->part) == kQ3Failure) goto failure_3; // Initialize pointer to container face contourPtr->containerFacePtr = containerFacePtr; // Create array of uninitialized vertex pointers if (e3meshVertexPtrArray_Create(&contourPtr->vertexPtrArray, effectiveNumVertices, nullptr) == kQ3Failure) goto failure_4; // Initialize vertex pointers vertexPtrs = e3meshVertexPtrArray_FirstItem(&contourPtr->vertexPtrArray); for (i = 0, i2 = 0; i < numVertices; ++i) if (vertexIndices[i] != vertexIndices[i > 0 ? i-1 : numVertices-1]) vertexPtrs[i2++] = &meshVertices[vertexIndices[i]]; return(kQ3Success); // Dead code to reverse e3meshVertexPtrArray_Create failure_4: e3meshPart_Destroy(&contourPtr->part); failure_3: failure_2: failure_1: return(kQ3Failure); } //============================================================================= // e3meshContour_Destroy : TE3MeshContourData destructor. //----------------------------------------------------------------------------- static void e3meshContour_Destroy( TE3MeshContourData* contourPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(contourPtr); // Destroy vertex pointer array e3meshVertexPtrArray_Destroy(&contourPtr->vertexPtrArray, nullptr); // Destroy part e3meshPart_Destroy(&contourPtr->part); } //============================================================================= // e3meshContour_Relocate : Relocate contour. //----------------------------------------------------------------------------- static void e3meshContour_Relocate( TE3MeshContourData* newContourPtr, TE3MeshContourData* oldContourPtr) { // Relocate part e3meshPart_Relocate( &newContourPtr->part, &oldContourPtr->part); } //============================================================================= // e3meshContour_RelinkContainerFace : Relink pointer to container face. //----------------------------------------------------------------------------- static TQ3Status e3meshContour_RelinkContainerFace( TE3MeshContourData* contourPtr, void* unusedArg) { (void)unusedArg; /* Suppress compiler warning */ // Validate our parameters Q3_ASSERT_VALID_PTR(contourPtr); return(e3meshFacePtr_Relink(&contourPtr->containerFacePtr, nullptr)); } //============================================================================= // e3meshContour_SetContainerFace : Set container face. //----------------------------------------------------------------------------- static void e3meshContour_SetContainerFace( TE3MeshContourData* contourPtr, TE3MeshFaceData* containerFacePtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(contourPtr); Q3_ASSERT_VALID_PTR(containerFacePtr); contourPtr->containerFacePtr = containerFacePtr; } //============================================================================= // e3meshContour_ContainerFace : Return container face. //----------------------------------------------------------------------------- static TE3MeshFaceData* e3meshContour_ContainerFace( TE3MeshContourData* contourPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(contourPtr); return(contourPtr->containerFacePtr); } //============================================================================= // e3meshContour_RelinkVertices : Relink pointers to vertices. //----------------------------------------------------------------------------- static TQ3Status e3meshContour_RelinkVertices( TE3MeshContourData* contourPtr, void* unusedArg) { (void)unusedArg; /* Suppress compiler warning */ // Validate our parameters Q3_ASSERT_VALID_PTR(contourPtr); return(e3meshVertexPtrArray_DoForEach( &contourPtr->vertexPtrArray, &e3meshVertexPtr_Relink, nullptr)); } //============================================================================= // e3meshContour_NumVertices : Return number of vertices in contour. //----------------------------------------------------------------------------- // Note : If a particular vertex occurs multiple times, each occurrence // is counted separately. //----------------------------------------------------------------------------- static TQ3Uns32 e3meshContour_NumVertices( const TE3MeshContourData* contourPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(contourPtr); return(e3meshVertexPtrArray_Length(&contourPtr->vertexPtrArray)); } //============================================================================= // e3meshContour_HasVertex : Return if contour has vertex. //----------------------------------------------------------------------------- static TQ3Boolean e3meshContour_HasVertex( const TE3MeshContourData* contourPtr, TE3MeshVertexData* vertexPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(contourPtr); Q3_ASSERT_VALID_PTR(vertexPtr); return(e3meshVertexPtrArray_HasPtr( &contourPtr->vertexPtrArray, vertexPtr)); } //============================================================================= // e3meshContour_ExtRefInMesh : Return external reference to contour. //----------------------------------------------------------------------------- // Note : If unable to get external reference (out of memory), return nullptr. //----------------------------------------------------------------------------- static TE3MeshContourExtRef e3meshContour_ExtRefInMesh( TE3MeshContourData* contourPtr, TE3MeshData* meshPtr) { return(E3_DOWN_CAST(TE3MeshContourExtRef, e3meshPart_HandleInMesh( &contourPtr->part, meshPtr))); } //============================================================================= // e3meshContour_GetExtData : Get external data. //----------------------------------------------------------------------------- // Note : If unable to get (out of memory), return kQ3Failure. //----------------------------------------------------------------------------- static TQ3Status e3meshContour_GetExtData( const TE3MeshContourData* contourPtr, TQ3MeshContourData* contourExtDataPtr, const TE3MeshVertexDataArray* meshVertexArrayPtr) { const TE3MeshVertexData* meshVertices; TQ3Uns32 numVertices; TQ3Uns32* vertexIndices; const TE3MeshVertexPtr* vertexPtrs; TQ3Uns32 i; // Validate our parameters Q3_ASSERT_VALID_PTR(contourPtr); Q3_ASSERT_VALID_PTR(contourExtDataPtr); Q3_ASSERT_VALID_PTR(meshVertexArrayPtr); // Get mesh vertices meshVertices = e3meshVertexArray_FirstItemConst(meshVertexArrayPtr); // Allocate array of uninitialized vertex indices numVertices = e3meshContour_NumVertices(contourPtr); if (numVertices == 0) vertexIndices = nullptr; else if ((vertexIndices = (TQ3Uns32*) Q3Memory_Allocate(numVertices * sizeof(TQ3Uns32))) == nullptr) goto failure_1; contourExtDataPtr->numVertices = numVertices; contourExtDataPtr->vertexIndices = vertexIndices; // Get vertex indices vertexPtrs = e3meshVertexPtrArray_FirstItemConst(&contourPtr->vertexPtrArray); for (i = 0; i < numVertices; ++i) vertexIndices[i] = static_cast<TQ3Uns32>(vertexPtrs[i] - meshVertices); return(kQ3Success); // Dead code to reverse Q3Memory_Allocate failure_1: return(kQ3Failure); } //============================================================================= // e3meshContourExtRef_Contour : Return contour for external reference. //----------------------------------------------------------------------------- // Note : If contour deleted, return nullptr. //----------------------------------------------------------------------------- #pragma mark - static TE3MeshContourData* e3meshContourExtRef_Contour( TE3MeshContourExtRef contourExtRef) { return(E3_DOWN_CAST(TE3MeshContourData*, e3meshPartHdl_Part( E3_UP_CAST(TE3MeshPartData**, contourExtRef)))); } //============================================================================= // e3meshContourExtRef_Mesh : Return mesh for external reference. //----------------------------------------------------------------------------- static TE3MeshData* e3meshContourExtRef_Mesh( TE3MeshContourExtRef contourExtRef) { return(e3meshPartHdl_Mesh(E3_UP_CAST(TE3MeshPartData**, contourExtRef))); } //============================================================================= // e3meshContourExtData_Empty : Empty external data. //----------------------------------------------------------------------------- #pragma mark - static TQ3Status e3meshContourExtData_Empty( TQ3MeshContourData* contourExtDataPtr) { TQ3Status result = kQ3Success; TQ3Uns32 numVertices; TQ3Uns32* vertexIndices; // Validate our parameters Q3_ASSERT_VALID_PTR(contourExtDataPtr); // Validate face indices numVertices = contourExtDataPtr->numVertices; vertexIndices = contourExtDataPtr->vertexIndices; if (numVertices == 0) result = kQ3Failure; if (vertexIndices == nullptr) result = kQ3Failure; // Deallocate array of vertex indices Q3Memory_Free(&contourExtDataPtr->vertexIndices); contourExtDataPtr->numVertices = 0; return(result); } //============================================================================= // e3meshFace_CreateEmptyListOfContours : TE3MeshFaceData constructor. //----------------------------------------------------------------------------- // Note : If unable to create (out of memory), return kQ3Failure. //----------------------------------------------------------------------------- #pragma mark - static TQ3Status e3meshFace_CreateEmptyListOfContours( TE3MeshFaceData* facePtr, TE3MeshData* meshPtr, TQ3Boolean isReferenced, TQ3AttributeSet attributeSet) { // Validate our parameters Q3_ASSERT_VALID_PTR(facePtr); Q3_ASSERT_VALID_PTR(meshPtr); // Create part if (e3meshPart_Create(&facePtr->part, meshPtr, isReferenced) == kQ3Failure) goto failure_1; // Create empty list of contours if (e3meshContourList_Create(&facePtr->contourArrayOrList.list, 0, nullptr) == kQ3Failure) goto failure_2; // Initialize attribute set E3Shared_Acquire(&facePtr->attributeSet, attributeSet); return(kQ3Success); // Dead code to reverse e3meshContourList_Create failure_2: e3meshPart_ReleaseHandleInMesh(&facePtr->part, meshPtr); e3meshPart_Destroy(&facePtr->part); failure_1: return(kQ3Failure); } //============================================================================= // e3meshFace_CreateFromVertexExtRefs : TE3MeshFaceData constructor from // an array of vertex external // references. //----------------------------------------------------------------------------- // Note : If unable to create (out of memory), return kQ3Failure. //----------------------------------------------------------------------------- static TQ3Status e3meshFace_CreateFromVertexExtRefs( TE3MeshFaceData* facePtr, TE3MeshData* meshPtr, TQ3Boolean isReferenced, TQ3Uns32 numVertices, const TE3MeshVertexExtRef* vertexExtRefs, TQ3AttributeSet attributeSet) { TE3MeshContourData* contourPtr; // Validate our parameters Q3_ASSERT_VALID_PTR(facePtr); Q3_ASSERT_VALID_PTR(meshPtr); Q3_ASSERT_VALID_PTR(vertexExtRefs); // Create part if (e3meshPart_Create(&facePtr->part, meshPtr, isReferenced) == kQ3Failure) goto failure_1; // Create array of one uninitialized contour if (e3meshContourArray_Create(&facePtr->contourArrayOrList.array, 1, nullptr) == kQ3Failure) goto failure_2; // Initialize contour contourPtr = e3meshContourArray_FirstItem(&facePtr->contourArrayOrList.array); if (e3meshContour_CreateFromVertexExtRefs(contourPtr, meshPtr, kQ3False, facePtr, numVertices, vertexExtRefs) == kQ3Failure) goto failure_3; // Initialize attribute set E3Shared_Acquire(&facePtr->attributeSet, attributeSet); return(kQ3Success); // Dead code to reverse e3meshContour_CreateFromVertexExtRefs failure_3: e3meshContourArray_Destroy(&facePtr->contourArrayOrList.array, nullptr); failure_2: e3meshPart_ReleaseHandleInMesh(&facePtr->part, meshPtr); e3meshPart_Destroy(&facePtr->part); failure_1: return(kQ3Failure); } //============================================================================= // e3meshFace_CreateFromExtData : TE3MeshFaceData constructor from // external data. //----------------------------------------------------------------------------- // Note : If unable to create (out of memory), return kQ3Failure. //----------------------------------------------------------------------------- static TQ3Status e3meshFace_CreateFromExtData( TE3MeshFaceData* facePtr, const TQ3MeshFaceData* faceExtDataPtr, TE3MeshVertexDataArray* meshVertexArrayPtr) { TQ3Uns32 numContours; TQ3MeshContourData* contourExtDatas; TE3MeshContourData* contours; TQ3Uns32 iSave; // Validate our parameters Q3_ASSERT_VALID_PTR(facePtr); Q3_ASSERT_VALID_PTR(faceExtDataPtr); Q3_ASSERT_VALID_PTR(meshVertexArrayPtr); // Create part, without reference if (e3meshPart_CreateUnreferenced(&facePtr->part) == kQ3Failure) goto failure_1; // Get and validate contours numContours = faceExtDataPtr->numContours; contourExtDatas = faceExtDataPtr->contours; if (numContours == 0) goto failure_2; if (contourExtDatas == nullptr) goto failure_3; // Create array of uninitialized contours if (e3meshContourArray_Create(&facePtr->contourArrayOrList.array, numContours, nullptr) == kQ3Failure) goto failure_4; // Initialize contours contours = e3meshContourArray_FirstItem(&facePtr->contourArrayOrList.array); for (iSave = 0; iSave < numContours; ++iSave) if (e3meshContour_CreateFromExtData(&contours[iSave], facePtr, &contourExtDatas[iSave], meshVertexArrayPtr) == kQ3Failure) // Initialize attribute set E3Shared_Acquire(&facePtr->attributeSet, faceExtDataPtr->faceAttributeSet); return(kQ3Success); //failure_5: // while (iSave > 0) // e3meshContour_Destroy(&contours[--iSave]); // e3meshContourArray_Destroy(&facePtr->contourArrayOrList.array, nullptr); failure_4: failure_3: failure_2: e3meshPart_Destroy(&facePtr->part); failure_1: return(kQ3Failure); } //============================================================================= // e3meshFace_Destroy : TE3MeshFaceData destructor. //----------------------------------------------------------------------------- static void e3meshFace_Destroy( TE3MeshFaceData* facePtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(facePtr); // Release attribute set Q3Object_CleanDispose(&facePtr->attributeSet); // Destroy contour array or list e3meshContourArrayOrList_Destroy(&facePtr->contourArrayOrList, &e3meshContour_Destroy); // Destroy part e3meshPart_Destroy(&facePtr->part); } //============================================================================= // e3meshFace_Relocate : Relocate face. //----------------------------------------------------------------------------- static void e3meshFace_Relocate( TE3MeshFaceData* newFacePtr, TE3MeshFaceData* oldFacePtr) { // Relocate part e3meshPart_Relocate( &newFacePtr->part, &oldFacePtr->part); } //============================================================================= // e3meshFace_RelinkContourFaces : Relink pointers to contour faces. //----------------------------------------------------------------------------- static TQ3Status e3meshFace_RelinkContourFaces( TE3MeshFaceData* facePtr, void* unusedArg) { (void)unusedArg; /* Suppress compiler warning */ // Validate our parameters Q3_ASSERT_VALID_PTR(facePtr); return(e3meshContourArrayOrList_DoForEach( &facePtr->contourArrayOrList, &e3meshContour_RelinkContainerFace, nullptr)); } //============================================================================= // e3meshFace_UseContourArray : Use contour array. //----------------------------------------------------------------------------- // Note : If unable to convert (out of memory), return kQ3Failure. //----------------------------------------------------------------------------- static TQ3Status e3meshFace_UseContourArray( TE3MeshFaceData* facePtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(facePtr); return(e3meshContourArrayOrList_UseArray( &facePtr->contourArrayOrList, &e3meshContour_Relocate, nullptr, nullptr)); } //============================================================================= // e3meshFace_UseContourList : Use contour list. //----------------------------------------------------------------------------- // Note : If unable to convert (out of memory), return kQ3Failure. //----------------------------------------------------------------------------- static TQ3Status e3meshFace_UseContourList( TE3MeshFaceData* facePtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(facePtr); return(e3meshContourArrayOrList_UseList( &facePtr->contourArrayOrList, &e3meshContour_Relocate, nullptr, nullptr)); } //============================================================================= // e3meshFace_NumContours : Return number of contours in face. //----------------------------------------------------------------------------- static TQ3Uns32 e3meshFace_NumContours( const TE3MeshFaceData* facePtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(facePtr); return(e3meshContourArrayOrList_Length(&facePtr->contourArrayOrList)); } //============================================================================= // e3meshFace_RelinkContourVertices : Relink pointers to contour vertices. //----------------------------------------------------------------------------- static TQ3Status e3meshFace_RelinkContourVertices( TE3MeshFaceData* facePtr, void* unusedArg) { (void)unusedArg; /* Suppress compiler warning */ // Validate our parameters Q3_ASSERT_VALID_PTR(facePtr); return(e3meshContourArrayOrList_DoForEach( &facePtr->contourArrayOrList, &e3meshContour_RelinkVertices, nullptr)); } //============================================================================= // e3meshFace_NumVertices : Return number of vertices in face. //----------------------------------------------------------------------------- // Note : If a particular vertex occurs multiple times, each occurrence // is counted separately. //----------------------------------------------------------------------------- static TQ3Uns32 e3meshFace_NumVertices( const TE3MeshFaceData* facePtr) { TQ3Uns32 numVertices; const TE3MeshContourData* contourPtr; // Validate our parameters Q3_ASSERT_VALID_PTR(facePtr); // Number of vertices in face is sum of number of vertices in each contour numVertices = 0; for (contourPtr = e3meshContourArrayOrList_FirstItemConst(&facePtr->contourArrayOrList); contourPtr != nullptr; contourPtr = e3meshContourArrayOrList_NextItemConst(&facePtr->contourArrayOrList, contourPtr)) { numVertices += e3meshContour_NumVertices(contourPtr); } return(numVertices); } //============================================================================= // e3meshFace_HasVertex : Return if face has vertex. //----------------------------------------------------------------------------- static TQ3Boolean e3meshFace_HasVertex( const TE3MeshFaceData* facePtr, TE3MeshVertexData* vertexPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(facePtr); Q3_ASSERT_VALID_PTR(vertexPtr); return(e3meshContourArrayOrList_OrForEach( &facePtr->contourArrayOrList, E3_DOWN_CAST(TQ3Boolean (*)(const TE3MeshContourData*, void*), &e3meshContour_HasVertex), vertexPtr)); } //============================================================================= // e3meshFace_ExtRefInMesh : Return external reference to face. //----------------------------------------------------------------------------- // Note : If unable to get external reference (out of memory), return nullptr. //----------------------------------------------------------------------------- static TE3MeshFaceExtRef e3meshFace_ExtRefInMesh( TE3MeshFaceData* facePtr, TE3MeshData* meshPtr) { return(E3_DOWN_CAST(TE3MeshFaceExtRef, e3meshPart_HandleInMesh( &facePtr->part, meshPtr))); } //============================================================================= // e3meshFace_GetExtData : Get external data. //----------------------------------------------------------------------------- // Note : If unable to get (out of memory), return kQ3Failure. //----------------------------------------------------------------------------- static TQ3Status e3meshFace_GetExtData( const TE3MeshFaceData* facePtr, TQ3MeshFaceData* faceExtDataPtr, const TE3MeshVertexDataArray* meshVertexArrayPtr) { TQ3Uns32 iSave = 0; TE3MeshContourData* contours; // Validate our parameters Q3_ASSERT_VALID_PTR(facePtr); Q3_ASSERT_VALID_PTR(faceExtDataPtr); Q3_ASSERT_VALID_PTR(meshVertexArrayPtr); faceExtDataPtr->numContours = e3meshFace_NumContours(facePtr); if (faceExtDataPtr->numContours == 0) faceExtDataPtr->contours = nullptr; else if ((faceExtDataPtr->contours = (TQ3MeshContourData*) Q3Memory_Allocate( faceExtDataPtr->numContours * sizeof(TQ3MeshContourData))) == nullptr) goto failure_2; // Use list of contours in face (*** MAY RELOCATE CONTOURS ***) if (e3meshFace_UseContourArray((TE3MeshFaceData*)facePtr) == kQ3Failure) goto failure; contours = e3meshContourArray_FirstItem((TE3MeshContourDataArray*)&facePtr->contourArrayOrList.array); for (iSave = 0; iSave < faceExtDataPtr->numContours; ++iSave) if (e3meshContour_GetExtData(&contours[iSave], &faceExtDataPtr->contours[iSave], meshVertexArrayPtr) == kQ3Failure) goto failure; // Get attribute set E3Shared_Acquire(&faceExtDataPtr->faceAttributeSet, facePtr->attributeSet); return(kQ3Success); failure: while (iSave > 0) e3meshContourExtData_Empty(&faceExtDataPtr->contours[--iSave]); Q3Memory_Free(&faceExtDataPtr->contours); failure_2: return(kQ3Failure); } //============================================================================= // e3meshFaceExtRef_Face : Return face for external reference. //----------------------------------------------------------------------------- // Note : If face deleted, return nullptr. //----------------------------------------------------------------------------- #pragma mark - static TE3MeshFaceData* e3meshFaceExtRef_Face( TE3MeshFaceExtRef faceExtRef) { return(E3_DOWN_CAST(TE3MeshFaceData*, e3meshPartHdl_Part( E3_UP_CAST(TE3MeshPartData**, faceExtRef)))); } //============================================================================= // e3meshFaceExtRef_Mesh : Return mesh for external reference. //----------------------------------------------------------------------------- static TE3MeshData* e3meshFaceExtRef_Mesh( TE3MeshFaceExtRef faceExtRef) { return(e3meshPartHdl_Mesh(E3_UP_CAST(TE3MeshPartData**, faceExtRef))); } //============================================================================= // e3meshFaceExtData_Empty : Empty external data. //----------------------------------------------------------------------------- #pragma mark - static TQ3Status e3meshFaceExtData_Empty( TQ3MeshFaceData* faceExtDataPtr) { TQ3Status result = kQ3Success; TQ3Uns32 numContours; TQ3MeshContourData* contourExtDatas; TQ3Uns32 i; // Validate our parameters Q3_ASSERT_VALID_PTR(faceExtDataPtr); // Release attribute set Q3Object_CleanDispose(&faceExtDataPtr->faceAttributeSet); // Validate and empty contours numContours = faceExtDataPtr->numContours; contourExtDatas = faceExtDataPtr->contours; if (numContours > 0 && contourExtDatas == nullptr) result = kQ3Failure; else { // Empty contours for (i = 0; i < numContours; ++i) if (e3meshContourExtData_Empty(&contourExtDatas[i]) == kQ3Failure) result = kQ3Failure; } // Deallocate array of contours Q3Memory_Free(&faceExtDataPtr->contours); faceExtDataPtr->numContours = 0; return(result); } //============================================================================= // e3mesh_Create : TE3MeshData constructor. //----------------------------------------------------------------------------- // Note : If unable to create (out of memory), return kQ3Failure. //----------------------------------------------------------------------------- #pragma mark - static TQ3Status e3mesh_Create( TE3MeshData* meshPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(meshPtr); // Create pool of part references if (e3meshPartPtrPool_Create(&meshPtr->partPtrPool) == kQ3Failure) goto failure_1; // Initialize number of corners meshPtr->numCorners = 0; // Create empty array of vertices if (e3meshVertexArray_Create(&meshPtr->vertexArrayOrList.array, 0, nullptr) == kQ3Failure) goto failure_2; // Create empty array of faces if (e3meshFaceArray_Create(&meshPtr->faceArrayOrList.array, 0, nullptr) == kQ3Failure) goto failure_3; // Initialize attribute set meshPtr->attributeSet = nullptr; return(kQ3Success); // Dead code to reverse e3meshFaceArray_Create failure_3: e3meshVertexArray_Destroy(&meshPtr->vertexArrayOrList.array, &e3meshVertex_Destroy); failure_2: e3meshPartPtrPool_Destroy(&meshPtr->partPtrPool); failure_1: return(kQ3Failure); } //============================================================================= // e3mesh_CreateFromExtData : TE3MeshData constructor from external data. //----------------------------------------------------------------------------- // Note : If unable to create (out of memory), return kQ3Failure. //----------------------------------------------------------------------------- static TQ3Status e3mesh_CreateFromExtData( TE3MeshData* meshPtr, const TQ3MeshData* meshExtDataPtr) { TQ3Uns32 numVertices; const TQ3MeshVertexData* vertexExtDatas; TQ3Uns32 numFaces; const TQ3MeshFaceData* faceExtDatas; TE3MeshVertexData* vertices; TQ3Uns32 iSave; TE3MeshFaceData* faces; TQ3Uns32 jSave; // Validate our parameters Q3_ASSERT_VALID_PTR(meshPtr); Q3_ASSERT_VALID_PTR(meshExtDataPtr); // Create pool of part references if (e3meshPartPtrPool_Create(&meshPtr->partPtrPool) == kQ3Failure) goto failure_1; // Initialize number of corners meshPtr->numCorners = 0; // Get and validate vertices numVertices = meshExtDataPtr->numVertices; vertexExtDatas = meshExtDataPtr->vertices; if (numVertices > 0 && vertexExtDatas == nullptr) goto failure_2; // Create array of uninitialized vertices if (e3meshVertexArray_Create(&meshPtr->vertexArrayOrList.array, meshExtDataPtr->numVertices, nullptr) == kQ3Failure) goto failure_3; // Get and validate faces numFaces = meshExtDataPtr->numFaces; faceExtDatas = meshExtDataPtr->faces; if (numFaces > 0 && faceExtDatas == nullptr) goto failure_4; // Create array of uninitialized faces if (e3meshFaceArray_Create(&meshPtr->faceArrayOrList.array, meshExtDataPtr->numFaces, nullptr) == kQ3Failure) goto failure_5; // Initialize vertices vertices = e3meshVertexArray_FirstItem(&meshPtr->vertexArrayOrList.array); for (iSave = 0; iSave < numVertices; ++iSave) { if (e3meshVertex_CreateFromExtData(&vertices[iSave], &vertexExtDatas[iSave], &meshPtr->faceArrayOrList.array) == kQ3Failure) goto failure_6; meshPtr->numCorners += vertexExtDatas[iSave].numCorners; } // Initialize faces faces = e3meshFaceArray_FirstItem(&meshPtr->faceArrayOrList.array); for (jSave = 0; jSave < numFaces; ++jSave) if (e3meshFace_CreateFromExtData(&faces[jSave], &faceExtDatas[jSave], &meshPtr->vertexArrayOrList.array) == kQ3Failure) goto failure_7; // Set attribute set E3Shared_Acquire(&meshPtr->attributeSet, meshExtDataPtr->meshAttributeSet); return(kQ3Success); failure_7: while (jSave > 0) e3meshFace_Destroy(&faces[--jSave]); failure_6: while (iSave > 0) e3meshVertex_Destroy(&vertices[--iSave]); e3meshFaceArray_Destroy(&meshPtr->faceArrayOrList.array, nullptr); failure_5: failure_4: e3meshVertexArray_Destroy(&meshPtr->vertexArrayOrList.array, nullptr); failure_3: failure_2: e3meshPartPtrPool_Destroy(&meshPtr->partPtrPool); failure_1: return(kQ3Failure); } //============================================================================= // e3mesh_Destroy : TE3MeshData destructor. //----------------------------------------------------------------------------- static void e3mesh_Destroy( TE3MeshData* meshPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(meshPtr); // Release attribute set Q3Object_CleanDispose(&meshPtr->attributeSet); // Destroy face array or list e3meshFaceArrayOrList_Destroy(&meshPtr->faceArrayOrList, &e3meshFace_Destroy); // Destroy vertex array or list e3meshVertexArrayOrList_Destroy(&meshPtr->vertexArrayOrList, &e3meshVertex_Destroy); // Destroy part references pool e3meshPartPtrPool_Destroy(&meshPtr->partPtrPool); } //============================================================================= // e3mesh_NumCorners : Return number of (defined) corners in mesh. //----------------------------------------------------------------------------- static TQ3Uns32 e3mesh_NumCorners( const TE3MeshData* meshPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(meshPtr); return(meshPtr->numCorners); } //============================================================================= // e3mesh_RelinkVertices : Relink pointers to vertices. //----------------------------------------------------------------------------- static void e3mesh_RelinkVertices( TE3MeshData* meshPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(meshPtr); e3meshFaceArrayOrList_DoForEach( &meshPtr->faceArrayOrList, &e3meshFace_RelinkContourVertices, nullptr); } //============================================================================= // e3mesh_UseVertexArray : Use vertex array. //----------------------------------------------------------------------------- // Note : If unable to convert (out of memory), return kQ3Failure. //----------------------------------------------------------------------------- static TQ3Status e3mesh_UseVertexArray( TE3MeshData* meshPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(meshPtr); return(e3meshVertexArrayOrList_UseArray( &meshPtr->vertexArrayOrList, &e3meshVertex_Relocate, E3_UP_CAST(void (*)(void*), &e3mesh_RelinkVertices), meshPtr)); } //============================================================================= // e3mesh_UseVertexList : Use vertex list. //----------------------------------------------------------------------------- // Note : If unable to convert (out of memory), return kQ3Failure. //----------------------------------------------------------------------------- static TQ3Status e3mesh_UseVertexList( TE3MeshData* meshPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(meshPtr); return(e3meshVertexArrayOrList_UseList( &meshPtr->vertexArrayOrList, &e3meshVertex_Relocate, E3_UP_CAST(void (*)(void*), &e3mesh_RelinkVertices), meshPtr)); } //============================================================================= // e3mesh_NumVertices : Return number of vertices in mesh. //----------------------------------------------------------------------------- static TQ3Uns32 e3mesh_NumVertices( const TE3MeshData* meshPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(meshPtr); return(e3meshVertexArrayOrList_Length(&meshPtr->vertexArrayOrList)); } //============================================================================= // e3mesh_NumContours : Return number of contours in mesh. //----------------------------------------------------------------------------- static TQ3Uns32 e3mesh_NumContours( const TE3MeshData* meshPtr) { TQ3Uns32 numContours; const TE3MeshFaceData* facePtr; // Validate our parameters Q3_ASSERT_VALID_PTR(meshPtr); // Number of contours in mesh is sum of number of contours in each face numContours = 0; for (facePtr = e3meshFaceArrayOrList_FirstItemConst(&meshPtr->faceArrayOrList); facePtr != nullptr; facePtr = e3meshFaceArrayOrList_NextItemConst(&meshPtr->faceArrayOrList, facePtr)) { numContours += e3meshFace_NumContours(facePtr); } return(numContours); } //============================================================================= // e3mesh_RelinkFaces : Relink pointers to faces. //----------------------------------------------------------------------------- static void e3mesh_RelinkFaces( TE3MeshData* meshPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(meshPtr); e3meshVertexArrayOrList_DoForEach( &meshPtr->vertexArrayOrList, &e3meshVertex_RelinkCornerFaces, nullptr); e3meshFaceArrayOrList_DoForEach( &meshPtr->faceArrayOrList, &e3meshFace_RelinkContourFaces, nullptr); } //============================================================================= // e3mesh_UseFaceArray : Use face array. //----------------------------------------------------------------------------- // Note : If unable to convert (out of memory), return kQ3Failure. //----------------------------------------------------------------------------- static TQ3Status e3mesh_UseFaceArray( TE3MeshData* meshPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(meshPtr); return(e3meshFaceArrayOrList_UseArray( &meshPtr->faceArrayOrList, &e3meshFace_Relocate, E3_UP_CAST(void (*)(void*), &e3mesh_RelinkFaces), meshPtr)); } //============================================================================= // e3mesh_UseFaceList : Use face list. //----------------------------------------------------------------------------- // Note : If unable to convert (out of memory), return kQ3Failure. //----------------------------------------------------------------------------- static TQ3Status e3mesh_UseFaceList( TE3MeshData* meshPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(meshPtr); return(e3meshFaceArrayOrList_UseList( &meshPtr->faceArrayOrList, &e3meshFace_Relocate, E3_UP_CAST(void (*)(void*), &e3mesh_RelinkFaces), meshPtr)); } //============================================================================= // e3mesh_NumFaces : Return number of faces in mesh. //----------------------------------------------------------------------------- static TQ3Uns32 e3mesh_NumFaces( const TE3MeshData* meshPtr) { // Validate our parameters Q3_ASSERT_VALID_PTR(meshPtr); return(e3meshFaceArrayOrList_Length(&meshPtr->faceArrayOrList)); } //============================================================================= // e3mesh_SetExtData : Set mesh from external data. //----------------------------------------------------------------------------- static TQ3Status e3mesh_SetExtData( TE3MeshData* meshPtr, const TQ3MeshData* meshExtDataPtr) { TE3MeshData tempMesh; // Validate our parameters Q3_ASSERT_VALID_PTR(meshPtr); Q3_ASSERT_VALID_PTR(meshExtDataPtr); // Create new temporary mesh from data if (e3mesh_CreateFromExtData(&tempMesh, meshExtDataPtr) == kQ3Failure) goto failure; // Destroy old mesh e3mesh_Destroy(meshPtr); // Swap new temporary mesh in for old mesh *meshPtr = tempMesh; return(kQ3Success); failure: return(kQ3Failure); } //============================================================================= // e3mesh_GetExtData : Get external data from mesh. //----------------------------------------------------------------------------- static TQ3Status e3mesh_GetExtData( const TE3MeshData* meshPtr, TQ3MeshData* meshExtDataPtr) { const TE3MeshVertexData* vertices; TQ3Uns32 iSave = 0; const TE3MeshFaceData* faces; TQ3Uns32 jSave; // Validate our parameters Q3_ASSERT_VALID_PTR(meshPtr); Q3_ASSERT_VALID_PTR(meshExtDataPtr); // Use array of vertices (*** MAY RELOCATE VERTICES ***) if (e3mesh_UseVertexArray(E3_CONST_CAST(TE3MeshData*, meshPtr)) == kQ3Failure) goto failure_1; // Allocate array of uninitialized vertices meshExtDataPtr->numVertices = e3mesh_NumVertices(meshPtr); if (meshExtDataPtr->numVertices == 0) meshExtDataPtr->vertices = nullptr; else if ((meshExtDataPtr->vertices = (TQ3MeshVertexData*) Q3Memory_Allocate(meshExtDataPtr->numVertices * sizeof(TQ3MeshVertexData))) == nullptr) goto failure_2; // Use array of faces (*** MAY RELOCATE FACES ***) if (e3mesh_UseFaceArray(E3_CONST_CAST(TE3MeshData*, meshPtr)) == kQ3Failure) goto failure_3; // Get vertices for (iSave = 0, vertices = e3meshVertexArray_FirstItemConst(&meshPtr->vertexArrayOrList.array); iSave < meshExtDataPtr->numVertices; ++iSave, ++vertices) { if (e3meshVertex_GetExtData(vertices, &meshExtDataPtr->vertices[iSave], &meshPtr->faceArrayOrList.array) == kQ3Failure) goto failure_4; } // Allocate array of uninitialized faces meshExtDataPtr->numFaces = e3mesh_NumFaces(meshPtr); if (meshExtDataPtr->numFaces == 0) meshExtDataPtr->faces = nullptr; else if ((meshExtDataPtr->faces = (TQ3MeshFaceData*) Q3Memory_Allocate( meshExtDataPtr->numFaces * sizeof(TQ3MeshFaceData))) == nullptr) goto failure_5; // Get faces for (jSave = 0, faces = e3meshFaceArray_FirstItemConst(&meshPtr->faceArrayOrList.array); jSave < meshExtDataPtr->numFaces; ++jSave, ++faces) { if (e3meshFace_GetExtData(faces, &meshExtDataPtr->faces[jSave], &meshPtr->vertexArrayOrList.array) == kQ3Failure) goto failure_6; } // Get attribute set E3Shared_Acquire(&meshExtDataPtr->meshAttributeSet, meshPtr->attributeSet); return(kQ3Success); failure_6: while (jSave > 0) e3meshFaceExtData_Empty(&meshExtDataPtr->faces[--jSave]); Q3Memory_Free(&meshExtDataPtr->faces); failure_5: failure_4: failure_3: while (iSave > 0) e3meshVertexExtData_Empty(&meshExtDataPtr->vertices[--iSave]); Q3Memory_Free(&meshExtDataPtr->vertices); failure_2: failure_1: return(kQ3Failure); } //============================================================================= // e3meshExtData_Empty : Empty external data. //----------------------------------------------------------------------------- #pragma mark - static TQ3Status e3meshExtData_Empty( TQ3MeshData* meshExtDataPtr) { TQ3Status result = kQ3Success; TQ3Uns32 numFaces; TQ3MeshFaceData* faceExtDatas; TQ3Uns32 j; TQ3Uns32 numVertices; TQ3MeshVertexData* vertexExtDatas; TQ3Uns32 i; // Validate our parameters Q3_ASSERT_VALID_PTR(meshExtDataPtr); // Release attribute set Q3Object_CleanDispose(&meshExtDataPtr->meshAttributeSet); // Validate and empty faces numFaces = meshExtDataPtr->numFaces; faceExtDatas = meshExtDataPtr->faces; if (numFaces > 0 && faceExtDatas == nullptr) result = kQ3Failure; else { // Empty faces for (j = 0; j < numFaces; ++j) if (e3meshFaceExtData_Empty(&faceExtDatas[j]) == kQ3Failure) result = kQ3Failure; } // Deallocate array of faces Q3Memory_Free(&meshExtDataPtr->faces); meshExtDataPtr->numFaces = 0; // Validate and empty vertices numVertices = meshExtDataPtr->numVertices; vertexExtDatas = meshExtDataPtr->vertices; if (numVertices > 0 && vertexExtDatas == nullptr) result = kQ3Failure; else { // Empty vertices for (i = 0; i < numVertices; ++i) if (e3meshVertexExtData_Empty(&vertexExtDatas[i]) == kQ3Failure) result = kQ3Failure; } // Deallocate array of vertices Q3Memory_Free(&meshExtDataPtr->vertices); meshExtDataPtr->numVertices = 0; return(result); } //============================================================================= // e3meshIterator_Initialize : TQ3MeshIterator partial constructor. //----------------------------------------------------------------------------- #pragma mark - static void e3meshIterator_Initialize( TQ3MeshIterator* iteratorPtr, TE3MeshData* meshPtr, const char* iteratorKind) { // Save mesh iteratorPtr->var4.field1 = meshPtr; // Save iterator kind strncpy(iteratorPtr->var4.field2, iteratorKind, 4); // Initialize other fields iteratorPtr->var1 = iteratorPtr->var2 = iteratorPtr->var3 = nullptr; } //============================================================================= // e3geom_mesh_new : TE3MeshData constructor. //----------------------------------------------------------------------------- // Note : If unable to create (out of memory), return kQ3Failure. //----------------------------------------------------------------------------- #pragma mark - static TQ3Status e3geom_mesh_new( TQ3Object theObject, void *privateData, const void *paramData) { #pragma unused(theObject) #pragma unused(paramData) return(e3mesh_Create(E3_DOWN_CAST(TE3MeshData*, privateData))); } //============================================================================= // e3geom_mesh_delete : TE3MeshData destructor. //----------------------------------------------------------------------------- static void e3geom_mesh_delete( TQ3Object theObject, void *privateData) { #pragma unused(theObject) e3mesh_Destroy(E3_DOWN_CAST(TE3MeshData*, privateData)); } //============================================================================= // e3geom_mesh_duplicate : Mesh duplicate method. //----------------------------------------------------------------------------- static TQ3Status e3geom_mesh_duplicate( TQ3Object fromObject, const void *fromPrivateData, TQ3Object toObject, void *toPrivateData) { const TE3MeshData* fromInstanceData = (const TE3MeshData*) fromPrivateData; TE3MeshData* toInstanceData = (TE3MeshData*) toPrivateData; TQ3Status qd3dStatus; // Validate our parameters Q3_REQUIRE_OR_RESULT(Q3_VALID_PTR(fromObject), kQ3Failure); Q3_REQUIRE_OR_RESULT(Q3_VALID_PTR(fromPrivateData), kQ3Failure); Q3_REQUIRE_OR_RESULT(Q3_VALID_PTR(toObject), kQ3Failure); Q3_REQUIRE_OR_RESULT(Q3_VALID_PTR(toPrivateData), kQ3Failure); // Initialise the instance data of the new object qd3dStatus = kQ3Success; // Handle failure //if (qd3dStatus != kQ3Success) // nullptr; return(qd3dStatus); } //============================================================================= // e3geom_mesh_cache_new_as_polys : Mesh cache new method. //----------------------------------------------------------------------------- static TQ3GroupObject e3geom_mesh_cache_new_as_polys(const TE3MeshData * meshPtr) { #define _MESH_AS_POLYS_OBJECTS_TO_DELETE_GROW 16 const TE3MeshFaceData* facePtr; const TE3MeshContourData* contourPtr; const TE3MeshVertexPtr* vertexHdl; const TE3MeshCornerData* cornerPtr; TQ3GroupObject thePolysGroup = nullptr; TQ3GeneralPolygonData polyData; TQ3Object *objectsToDelete; TQ3Uns32 numObjectsToDelete; TQ3Uns32 allocatedObjectsToDelete; TQ3Vertex3D *currentVertex; TQ3Object thePoly; TQ3Uns32 i,j; polyData.contours = nullptr; polyData.shapeHint = kQ3GeneralPolygonShapeHintComplex; polyData.generalPolygonAttributeSet = nullptr; thePolysGroup = Q3OrderedDisplayGroup_New (); if(thePolysGroup == nullptr) return nullptr; objectsToDelete = (TQ3Object*) Q3Memory_Allocate(_MESH_AS_POLYS_OBJECTS_TO_DELETE_GROW * sizeof(TQ3Object)); if(objectsToDelete == nullptr) return thePolysGroup; allocatedObjectsToDelete = _MESH_AS_POLYS_OBJECTS_TO_DELETE_GROW; // add the mesh attribute Set to the group if(meshPtr->attributeSet != nullptr) Q3Group_AddObject(thePolysGroup,meshPtr->attributeSet); numObjectsToDelete = 0; for (facePtr = e3meshFaceArrayOrList_FirstItemConst(&meshPtr->faceArrayOrList); facePtr != nullptr; facePtr = e3meshFaceArrayOrList_NextItemConst(&meshPtr->faceArrayOrList, facePtr)) { numObjectsToDelete = 0; polyData.numContours = e3meshFace_NumContours(facePtr); polyData.contours = (TQ3GeneralPolygonContourData*) Q3Memory_AllocateClear( polyData.numContours * sizeof(TQ3GeneralPolygonContourData)); if(polyData.contours == nullptr) goto cleanup; polyData.generalPolygonAttributeSet = facePtr->attributeSet; for (contourPtr = e3meshContourArrayOrList_FirstItemConst(&facePtr->contourArrayOrList), i = 0; contourPtr != nullptr; contourPtr = e3meshContourArrayOrList_NextItemConst(&facePtr->contourArrayOrList, contourPtr), ++i) { polyData.contours[i].numVertices = e3meshContour_NumVertices(contourPtr); polyData.contours[i].vertices = (TQ3Vertex3D*) Q3Memory_Allocate(polyData.contours[i].numVertices * sizeof(TQ3Vertex3D)); if(polyData.contours == nullptr) goto cleanup; for (vertexHdl = e3meshVertexPtrArray_FirstItemConst(&contourPtr->vertexPtrArray), j = 0; vertexHdl != nullptr; vertexHdl = e3meshVertexPtrArray_NextItemConst(&contourPtr->vertexPtrArray, vertexHdl), ++j) { currentVertex = &polyData.contours[i].vertices[j]; currentVertex->point = (*vertexHdl)->point; currentVertex->attributeSet = (*vertexHdl)->attributeSet; cornerPtr = e3meshVertex_FaceCorner(*vertexHdl, facePtr); if(cornerPtr != nullptr) { if(cornerPtr->attributeSet != nullptr) { if(currentVertex->attributeSet != nullptr) { currentVertex->attributeSet = Q3AttributeSet_New(); if (currentVertex->attributeSet == nullptr) { currentVertex->attributeSet = (*vertexHdl)->attributeSet; } else { TQ3AttributeSet curVertAtts = currentVertex->attributeSet; if((1 + numObjectsToDelete) > allocatedObjectsToDelete) { if(Q3Memory_Reallocate(&objectsToDelete, (allocatedObjectsToDelete + _MESH_AS_POLYS_OBJECTS_TO_DELETE_GROW)*sizeof(TQ3Object)) != kQ3Success) goto cleanup; allocatedObjectsToDelete += _MESH_AS_POLYS_OBJECTS_TO_DELETE_GROW; } objectsToDelete[numObjectsToDelete] = currentVertex->attributeSet; numObjectsToDelete++; Q3AttributeSet_Inherit((*vertexHdl)->attributeSet, cornerPtr->attributeSet, curVertAtts); } } else { currentVertex->attributeSet = cornerPtr->attributeSet; } } } } } thePoly = Q3GeneralPolygon_New(&polyData); if(thePoly != nullptr){ Q3Group_AddObject(thePolysGroup,thePoly); Q3Object_Dispose(thePoly); } while(numObjectsToDelete > 0) { numObjectsToDelete --; Q3Object_Dispose(objectsToDelete[numObjectsToDelete]); } if(polyData.contours != nullptr) { for(i = 0; i < polyData.numContours; i++) { if(polyData.contours[i].vertices != nullptr) Q3Memory_Free(&polyData.contours[i].vertices); } Q3Memory_Free(&polyData.contours); } } cleanup: while(numObjectsToDelete > 0) { numObjectsToDelete --; Q3Object_Dispose(objectsToDelete[numObjectsToDelete]); } if(objectsToDelete != nullptr) Q3Memory_Free(&objectsToDelete); if(polyData.contours != nullptr) { for(i = 0; i < polyData.numContours; i++) { if(polyData.contours[i].vertices != nullptr) Q3Memory_Free(&polyData.contours[i].vertices); } Q3Memory_Free(&polyData.contours); } return thePolysGroup; #undef _MESH_AS_POLYS_OBJECTS_TO_DELETE_GROW } //============================================================================= // e3geom_mesh_cache_new : Mesh cache new method. //----------------------------------------------------------------------------- static TQ3Object e3geom_mesh_cache_new(TQ3ViewObject view, TQ3GeometryObject meshObject, const void *geomData) { const TE3MeshData* meshPtr = (const TE3MeshData*) geomData; #pragma unused(meshObject) #pragma unused(view) // Check for an empty mesh if (e3mesh_NumFaces(meshPtr) == 0) return nullptr; // Create an appropriate representation TQ3Object theGroup = e3geom_mesh_cache_new_as_polys(meshPtr); return(theGroup); } //============================================================================= // e3geom_mesh_pick : Mesh picking method. //----------------------------------------------------------------------------- static TQ3Status e3geom_mesh_pick( TQ3ViewObject theView, TQ3ObjectType objectType, TQ3Object theObject, const void *objectData) { #pragma unused(objectType) // To be implemented... return(kQ3Failure); } //============================================================================= // e3geom_mesh_bounds : Mesh bounds method. //----------------------------------------------------------------------------- static TQ3Status e3geom_mesh_bounds( TQ3ViewObject theView, TQ3ObjectType objectType, E3Mesh* mesh, const void *objectData) { #pragma unused(objectType) // Use array of vertices in mesh (*** MAY RELOCATE VERTICES ***) if (e3mesh_UseVertexArray(E3_CONST_CAST(TE3MeshData*, & mesh->instanceData )) == kQ3Failure) goto failure; // Update the bounds E3View_UpdateBounds(theView, e3mesh_NumVertices(& mesh->instanceData), sizeof(TE3MeshVertexData), &e3meshVertexArray_FirstItemConst(& mesh->instanceData.vertexArrayOrList.array)->point); return(kQ3Success); failure: return(kQ3Failure); } //============================================================================= // e3geom_mesh_get_attribute : Mesh get attribute set pointer. //----------------------------------------------------------------------------- static TQ3AttributeSet* e3geom_mesh_get_attribute( TQ3GeometryObject mesh ) { // Return the address of the geometry attribute set return & ((E3Mesh*)mesh)->instanceData.attributeSet ; } //============================================================================= // e3geom_mesh_metahandler : Mesh metahandler. //----------------------------------------------------------------------------- static TQ3XFunctionPointer e3geom_mesh_metahandler( TQ3XMethodType methodType) { TQ3XFunctionPointer theMethod = nullptr; // Return our methods switch (methodType) { case kQ3XMethodTypeObjectNew: theMethod = (TQ3XFunctionPointer) e3geom_mesh_new; break; case kQ3XMethodTypeObjectDelete: theMethod = (TQ3XFunctionPointer) e3geom_mesh_delete; break; case kQ3XMethodTypeObjectDuplicate: theMethod = (TQ3XFunctionPointer) e3geom_mesh_duplicate; break; case kQ3XMethodTypeGeomCacheNew: theMethod = (TQ3XFunctionPointer) e3geom_mesh_cache_new; break; case kQ3XMethodTypeObjectSubmitBounds: theMethod = (TQ3XFunctionPointer) e3geom_mesh_bounds; break; case kQ3XMethodTypeGeomGetAttribute: theMethod = (TQ3XFunctionPointer) e3geom_mesh_get_attribute; break; } return(theMethod); } //============================================================================= // Public functions //----------------------------------------------------------------------------- // E3GeometryMesh_RegisterClass : Register the class. //----------------------------------------------------------------------------- #pragma mark - TQ3Status E3GeometryMesh_RegisterClass(void) { // Register the class return Q3_REGISTER_CLASS ( kQ3ClassNameGeometryMesh, e3geom_mesh_metahandler, E3Mesh ) ; } //============================================================================= // E3GeometryMesh_UnregisterClass : Unregister the class. //----------------------------------------------------------------------------- TQ3Status E3GeometryMesh_UnregisterClass(void) { TQ3Status qd3dStatus; // Unregister the class qd3dStatus = E3ClassTree::UnregisterClass(kQ3GeometryTypeMesh, kQ3True); return(qd3dStatus); } //============================================================================= // E3Mesh_New : Create new mesh object. //----------------------------------------------------------------------------- #pragma mark - TQ3GeometryObject E3Mesh_New(void) { TQ3Object theObject; // Create the object theObject = E3ClassTree::CreateInstance ( kQ3GeometryTypeMesh, kQ3False, nullptr); return(theObject); } //============================================================================= // E3Mesh_SetData : Set the data for a mesh object. //----------------------------------------------------------------------------- TQ3Status E3Mesh_SetData(TQ3GeometryObject meshObject, const TQ3MeshData *meshData) { if (e3mesh_SetExtData( & ( (E3Mesh*) meshObject )->instanceData, meshData) == kQ3Failure) goto failure; Q3Shared_Edited(meshObject); return(kQ3Success); failure: return(kQ3Failure); } //============================================================================= // E3Mesh_GetData : Get the data for a mesh object. //----------------------------------------------------------------------------- TQ3Status E3Mesh_GetData(TQ3GeometryObject meshObject, TQ3MeshData *meshData) { return e3mesh_GetExtData ( & ( (E3Mesh*) meshObject )->instanceData, meshData ) ; } //============================================================================= // E3Mesh_EmptyData : Empty the data for a mesh object. //----------------------------------------------------------------------------- TQ3Status E3Mesh_EmptyData(TQ3MeshData *meshData) { if (e3meshExtData_Empty(meshData) == kQ3Failure) goto failure; return(kQ3Success); failure: return(kQ3Failure); } //============================================================================= // E3Mesh_DelayUpdates : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TQ3Status E3Mesh_DelayUpdates( TQ3GeometryObject meshObject) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; // To be implemented... return(kQ3Success); } //============================================================================= // E3Mesh_ResumeUpdates : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TQ3Status E3Mesh_ResumeUpdates( TQ3GeometryObject meshObject) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; // To be implemented... return(kQ3Success); } //============================================================================= // E3Mesh_FaceNew : Add new face created from vertices and attribute set. //----------------------------------------------------------------------------- // Note : If unable to use list of faces, if unable to insert face item, // or if unable to create face, return nullptr. //----------------------------------------------------------------------------- TE3MeshFaceExtRef E3Mesh_FaceNew( TQ3GeometryObject meshObject, TQ3Uns32 numVertices, const TE3MeshVertexExtRef* vertexExtRefs, TQ3AttributeSet attributeSet) { TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; TE3MeshFaceData* facePtr; // Use list of faces in mesh (*** MAY RELOCATE FACES ***) if (e3mesh_UseFaceList(meshPtr) == kQ3Failure) goto failure_1; // Push back new uninitialized face if ((facePtr = e3meshFaceList_PushBackItem(&meshPtr->faceArrayOrList.list, nullptr)) == nullptr) goto failure_2; // Create face, with reference if (e3meshFace_CreateFromVertexExtRefs(facePtr, meshPtr, kQ3True, numVertices, vertexExtRefs, attributeSet) == kQ3Failure) goto failure_3; Q3Shared_Edited(meshObject); return(e3meshFace_ExtRefInMesh(facePtr, meshPtr)); // Dead code to reverse e3meshFace_Create failure_3: e3meshFaceList_EraseItem(&meshPtr->faceArrayOrList.list, nullptr, facePtr); failure_2: failure_1: return(nullptr); } //============================================================================= // E3Mesh_FaceDelete : Delete face from mesh. //----------------------------------------------------------------------------- // Note : If unable to use list of faces, return kQ3Failure. //----------------------------------------------------------------------------- TQ3Status E3Mesh_FaceDelete( TQ3GeometryObject meshObject, TE3MeshFaceExtRef faceExtRef) { TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; TE3MeshFaceData* facePtr; // Check face; if face already deleted, return kQ3Success facePtr = e3meshFaceExtRef_Face(faceExtRef); if (facePtr == nullptr) goto success; // Use list of faces in mesh (*** MAY RELOCATE FACES ***) if (e3mesh_UseFaceList(meshPtr) == kQ3Failure) goto failure; // Recheck face (in case relocated) facePtr = e3meshFaceExtRef_Face(faceExtRef); // Erase face e3meshFaceList_EraseItem(&meshPtr->faceArrayOrList.list, &e3meshFace_Destroy, facePtr); Q3Shared_Edited(meshObject); success: return(kQ3Success); failure: return(kQ3Failure); } //============================================================================= // E3Mesh_FaceToContour : Append face's contours to container face's, and // delete face. //----------------------------------------------------------------------------- // Note : If container face deleted, face deleted, unable to relocate // faces, or unable to relocate contours, return nullptr. //----------------------------------------------------------------------------- TE3MeshContourExtRef E3Mesh_FaceToContour( TQ3GeometryObject meshObject, TE3MeshFaceExtRef containerFaceExtRef, TE3MeshFaceExtRef faceExtRef) { TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; TE3MeshFaceData* containerFacePtr; TE3MeshFaceData* facePtr; TE3MeshContourData* contourPtr; TE3MeshContourExtRef contourExtRef; // Check container face containerFacePtr = e3meshFaceExtRef_Face(containerFaceExtRef); if (containerFacePtr == nullptr) goto failure; // Check face facePtr = e3meshFaceExtRef_Face(faceExtRef); if (facePtr == nullptr) goto failure; // Use list of faces in mesh (*** MAY RELOCATE FACES ***) if (e3mesh_UseFaceList(meshPtr) == kQ3Failure) goto failure; // Recheck container face (in case relocated) containerFacePtr = e3meshFaceExtRef_Face(containerFaceExtRef); // Recheck face (in case relocated) facePtr = e3meshFaceExtRef_Face(faceExtRef); // Use list of contours in container face (*** MAY RELOCATE CONTOURS ***) if (e3meshFace_UseContourList(containerFacePtr) == kQ3Failure) goto failure; // Use list of contours in face (*** MAY RELOCATE CONTOURS ***) if (e3meshFace_UseContourList(facePtr) == kQ3Failure) goto failure; // Get first contour in face if ((contourPtr = e3meshContourList_FirstItem(&facePtr->contourArrayOrList.list)) == nullptr) goto failure; if ((contourExtRef = e3meshContour_ExtRefInMesh(contourPtr, meshPtr)) == nullptr) goto failure; // For each contour in face, reset container face for (contourPtr = e3meshContourList_FirstItem(&facePtr->contourArrayOrList.list); contourPtr != nullptr; contourPtr = e3meshContourList_NextItem(&facePtr->contourArrayOrList.list, contourPtr)) { // Reset container face e3meshContour_SetContainerFace(contourPtr, containerFacePtr); } // Splice contours from face into container face e3meshContourList_SpliceBackList(&containerFacePtr->contourArrayOrList.list, &facePtr->contourArrayOrList.list); // Erase face from mesh e3meshFaceList_EraseItem(&meshPtr->faceArrayOrList.list, &e3meshFace_Destroy, facePtr); Q3Shared_Edited(meshObject); // Return contour return(contourExtRef); failure: return(nullptr); } //============================================================================= // E3Mesh_ContourToFace : Add new face with contour. //----------------------------------------------------------------------------- // Note : If contour deleted, unable to relocate faces, unable to // insert face item, or unable to relocate contours, return nullptr. //----------------------------------------------------------------------------- // Note : If the specified contour is the only contour in its container // face, then this function merely returns that container face. //----------------------------------------------------------------------------- TE3MeshFaceExtRef E3Mesh_ContourToFace( TQ3GeometryObject meshObject, TE3MeshContourExtRef contourExtRef) { TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; TE3MeshContourData* contourPtr; TE3MeshFaceData* containerFacePtr; TE3MeshFaceData* facePtr = nullptr; // Check contour if ((contourPtr = e3meshContourExtRef_Contour(contourExtRef)) == nullptr) goto failure_1; // Get and check container face containerFacePtr = e3meshContour_ContainerFace(contourPtr); if (e3meshFace_NumContours(containerFacePtr) == 1) goto success; // Use list of faces in mesh (*** MAY RELOCATE FACES ***) if (e3mesh_UseFaceList(meshPtr) == kQ3Failure) goto failure_2; // Recheck container face (in case relocated) containerFacePtr = e3meshContour_ContainerFace(contourPtr); // Push back new uninitialized face if ((facePtr = e3meshFaceList_PushBackItem(&meshPtr->faceArrayOrList.list, nullptr)) == nullptr) goto failure_3; // Create face with empty list of contours, with reference if (e3meshFace_CreateEmptyListOfContours(facePtr, meshPtr, kQ3True, nullptr) == kQ3Failure) goto failure_4; // Use list of contours in container face (*** MAY RELOCATE CONTOURS ***) if (e3meshFace_UseContourList(containerFacePtr) == kQ3Failure) goto failure_5; // Use list of contours in face (*** MAY RELOCATE CONTOURS ***) if (e3meshFace_UseContourList(facePtr) == kQ3Failure) goto failure_6; // Splice contour from container face into new face e3meshContourList_SpliceBackList(&containerFacePtr->contourArrayOrList.list, &facePtr->contourArrayOrList.list); Q3Shared_Edited(meshObject); success: // Return face return(e3meshFace_ExtRefInMesh(facePtr, meshPtr)); // Dead code to reverse e3meshContourArrayOrList_UseList failure_6: failure_5: e3meshFace_Destroy(facePtr); failure_4: e3meshFaceList_EraseItem(&meshPtr->faceArrayOrList.list, nullptr, facePtr); failure_3: failure_2: failure_1: return(nullptr); } //============================================================================= // E3Mesh_VertexNew : Add new vertex created from coordinates and attribute set. //----------------------------------------------------------------------------- // Note : If unable to use list of vertices, if unable to insert vertex // item, or if unable to create vertex, return nullptr. //----------------------------------------------------------------------------- TE3MeshVertexExtRef E3Mesh_VertexNew( TQ3GeometryObject meshObject, const TQ3Vertex3D* vertexExtDataPtr) { TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; TE3MeshVertexData* vertexPtr; // Use list of vertices in mesh (*** MAY RELOCATE VERTICES ***) if (e3mesh_UseVertexList(meshPtr) == kQ3Failure) goto failure_1; // Push back new uninitialized vertex if ((vertexPtr = e3meshVertexList_PushBackItem(&meshPtr->vertexArrayOrList.list, nullptr)) == nullptr) goto failure_2; // Create vertex, with reference if (e3meshVertex_CreateEmptyArrayOfCorners(vertexPtr, meshPtr, kQ3True, vertexExtDataPtr) == kQ3Failure) goto failure_3; Q3Shared_Edited(meshObject); return(e3meshVertex_ExtRefInMesh(vertexPtr, meshPtr)); // Dead code to reverse e3meshVertex_CreateEmptyArrayOfCorners failure_3: e3meshVertexList_EraseItem(&meshPtr->vertexArrayOrList.list, nullptr, vertexPtr); failure_2: failure_1: return(nullptr); } //============================================================================= // E3Mesh_VertexDelete : Delete vertex from mesh. //----------------------------------------------------------------------------- // Note : If unable to use list of vertices, return kQ3Failure. //----------------------------------------------------------------------------- TQ3Status E3Mesh_VertexDelete( TQ3GeometryObject meshObject, TE3MeshVertexExtRef vertexExtRef) { TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; TE3MeshVertexData* vertexPtr; TE3MeshFaceData* facePtr; // Check vertex; if vertex already deleted, return kQ3Success vertexPtr = e3meshVertexExtRef_Vertex(vertexExtRef); if (vertexPtr == nullptr) goto success; // Use list of vertices in mesh (*** MAY RELOCATE VERTICES ***) if (e3mesh_UseVertexList(meshPtr) == kQ3Failure) goto failure; // Recheck vertex (in case relocated) vertexPtr = e3meshVertexExtRef_Vertex(vertexExtRef); // Get first face in mesh facePtr = e3meshFaceArrayOrList_FirstItem(&meshPtr->faceArrayOrList); // Delete each face having vertex while (facePtr != nullptr) { TE3MeshFaceData* markedMeshFacePtr = nullptr; // Check if face has vertex if (e3meshFace_HasVertex(facePtr, vertexPtr)) { TE3MeshFaceExtRef faceExtRef = nullptr; // Save face if ((faceExtRef = e3meshFace_ExtRefInMesh(facePtr, meshPtr)) == nullptr) goto failure; // Use list of faces in mesh (*** MAY RELOCATE FACES ***) if (e3mesh_UseFaceList(meshPtr) == kQ3Failure) goto failure; // Restore face (in case relocated) if ((facePtr = e3meshFaceExtRef_Face(faceExtRef)) == nullptr) goto failure; // Mark face for erasure markedMeshFacePtr = facePtr; } // Get next face in mesh facePtr = e3meshFaceArrayOrList_NextItem(&meshPtr->faceArrayOrList, facePtr); // If face marked for erasure, erase face if (markedMeshFacePtr) e3meshFaceList_EraseItem(&meshPtr->faceArrayOrList.list, &e3meshFace_Destroy, markedMeshFacePtr); } // Erase vertex from mesh e3meshVertexList_EraseItem(&meshPtr->vertexArrayOrList.list, &e3meshVertex_Destroy, vertexPtr); Q3Shared_Edited(meshObject); success: return(kQ3Success); failure: return(kQ3Failure); } //============================================================================= // E3Mesh_GetOrientable : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- #pragma mark - TQ3Status E3Mesh_GetOrientable( TQ3GeometryObject meshObject, TQ3Boolean* orientablePtr) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; // To be implemented... return(kQ3Failure); } //============================================================================= // E3Mesh_GetNumComponents : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- #pragma mark - TQ3Status E3Mesh_GetNumComponents( TQ3GeometryObject meshObject, TQ3Uns32* numComponentsPtr) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; // To be implemented... return(kQ3Failure); } //============================================================================= // E3Mesh_FirstMeshComponent : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TE3MeshComponentExtRef E3Mesh_FirstMeshComponent( TQ3GeometryObject meshObject, TQ3MeshIterator* iteratorPtr) { // To be implemented... return(nullptr); } //============================================================================= // E3Mesh_NextMeshComponent : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TE3MeshComponentExtRef E3Mesh_NextMeshComponent( TQ3MeshIterator* iteratorPtr) { // To be implemented... return(nullptr); } //============================================================================= // E3Mesh_GetNumFaces : Get number of faces in mesh. //----------------------------------------------------------------------------- TQ3Status E3Mesh_GetNumFaces( TQ3GeometryObject meshObject, TQ3Uns32* numFacesPtr) { TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; // Get number of faces in mesh *numFacesPtr = e3mesh_NumFaces(meshPtr); return(kQ3Success); } //============================================================================= // E3Mesh_FirstMeshFace : Get first face in mesh. //----------------------------------------------------------------------------- // Note : If no first face or unable to create external reference to // face, return nullptr. //----------------------------------------------------------------------------- TE3MeshFaceExtRef E3Mesh_FirstMeshFace( TQ3GeometryObject meshObject, TQ3MeshIterator* iteratorPtr) { TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; TE3MeshFaceData* facePtr; TE3MeshFaceExtRef faceExtRef; // Initialize iterator e3meshIterator_Initialize(iteratorPtr, meshPtr, "mefa"); // Get and save first face in mesh if ((facePtr = e3meshFaceArrayOrList_FirstItem(&meshPtr->faceArrayOrList)) == nullptr) goto failure; if ((faceExtRef = e3meshFace_ExtRefInMesh(facePtr, meshPtr)) == nullptr) goto failure; iteratorPtr->var1 = faceExtRef; // Return first face in mesh return(faceExtRef); failure: iteratorPtr->var1 = nullptr; return(nullptr); } //============================================================================= // E3Mesh_NextMeshFace : Get next face in mesh. //----------------------------------------------------------------------------- // Note : If iterator ended, current face deleted, no next face or // unable to create external reference to face, return nullptr. //----------------------------------------------------------------------------- TE3MeshFaceExtRef E3Mesh_NextMeshFace( TQ3MeshIterator* iteratorPtr) { TE3MeshData* meshPtr = (TE3MeshData*) iteratorPtr->var4.field1; TE3MeshFaceExtRef faceExtRef; TE3MeshFaceData* facePtr; // Restore and check current face in mesh if ((faceExtRef = (TE3MeshFaceExtRef) iteratorPtr->var1) == nullptr) goto failure; if ((facePtr = e3meshFaceExtRef_Face(faceExtRef)) == nullptr) goto failure; // Get and save next face in mesh if ((facePtr = e3meshFaceArrayOrList_NextItem(&meshPtr->faceArrayOrList, facePtr)) == nullptr) goto failure; if ((faceExtRef = e3meshFace_ExtRefInMesh(facePtr, meshPtr)) == nullptr) goto failure; iteratorPtr->var1 = faceExtRef; // Return next face in mesh return(faceExtRef); failure: iteratorPtr->var1 = nullptr; return(nullptr); } //============================================================================= // E3Mesh_GetNumEdges : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TQ3Status E3Mesh_GetNumEdges( TQ3GeometryObject meshObject, TQ3Uns32* numEdgesPtr) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; // To be implemented... return(kQ3Failure); } //============================================================================= // E3Mesh_FirstMeshEdge : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TE3MeshEdgeExtRef E3Mesh_FirstMeshEdge( TQ3GeometryObject meshObject, TQ3MeshIterator* iteratorPtr) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; // To be implemented... return(nullptr); } //============================================================================= // E3Mesh_NextMeshEdge : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TE3MeshEdgeExtRef E3Mesh_NextMeshEdge( TQ3MeshIterator* iteratorPtr) { // To be implemented... return(nullptr); } //============================================================================= // E3Mesh_GetNumVertices : Get number of vertices in mesh. //----------------------------------------------------------------------------- TQ3Status E3Mesh_GetNumVertices( TQ3GeometryObject meshObject, TQ3Uns32* numVerticesPtr) { TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; // Get number of vertices in mesh *numVerticesPtr = e3mesh_NumVertices(meshPtr); return(kQ3Success); } //============================================================================= // E3Mesh_FirstMeshVertex : Get first vertex in mesh. //----------------------------------------------------------------------------- // Note : If no first vertex or unable to create external reference // to vertex, return nullptr. //----------------------------------------------------------------------------- TE3MeshVertexExtRef E3Mesh_FirstMeshVertex( TQ3GeometryObject meshObject, TQ3MeshIterator* iteratorPtr) { TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; TE3MeshVertexData* vertexPtr; TE3MeshVertexExtRef vertexExtRef; // Initialize iterator e3meshIterator_Initialize(iteratorPtr, meshPtr, "meve"); // Get and save first vertex in mesh if ((vertexPtr = e3meshVertexArrayOrList_FirstItem(&meshPtr->vertexArrayOrList)) == nullptr) goto failure; if ((vertexExtRef = e3meshVertex_ExtRefInMesh(vertexPtr, meshPtr)) == nullptr) goto failure; iteratorPtr->var1 = vertexExtRef; // Return first vertex in mesh return(vertexExtRef); failure: iteratorPtr->var1 = nullptr; return(nullptr); } //============================================================================= // E3Mesh_NextMeshVertex : Get next vertex in mesh. //----------------------------------------------------------------------------- // Note : If iterator ended, current vertex deleted, no next vertex or // unable to create external reference to vertex, return nullptr. //----------------------------------------------------------------------------- TE3MeshVertexExtRef E3Mesh_NextMeshVertex( TQ3MeshIterator* iteratorPtr) { TE3MeshData* meshPtr = (TE3MeshData*) iteratorPtr->var4.field1; TE3MeshVertexExtRef vertexExtRef; TE3MeshVertexData* vertexPtr; // Restore and check current vertex in mesh if ((vertexExtRef = (TE3MeshVertexExtRef) iteratorPtr->var1) == nullptr) goto failure; if ((vertexPtr = e3meshVertexExtRef_Vertex(vertexExtRef)) == nullptr) goto failure; // Get and save next vertex in mesh if ((vertexPtr = e3meshVertexArrayOrList_NextItem(&meshPtr->vertexArrayOrList, vertexPtr)) == nullptr) goto failure; if ((vertexExtRef = e3meshVertex_ExtRefInMesh(vertexPtr, meshPtr)) == nullptr) goto failure; iteratorPtr->var1 = vertexExtRef; // Return next vertex in mesh return(vertexExtRef); failure: iteratorPtr->var1 = nullptr; return(nullptr); } //============================================================================= // E3Mesh_GetNumCorners : Get number of (distinct, defined) corners in mesh. //----------------------------------------------------------------------------- TQ3Status E3Mesh_GetNumCorners( TQ3GeometryObject meshObject, TQ3Uns32* numCornersPtr) { TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; // Get number of corners in mesh *numCornersPtr = e3mesh_NumCorners(meshPtr); return(kQ3Success); } //============================================================================= // E3Mesh_GetComponentOrientable : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- #pragma mark - TQ3Status E3Mesh_GetComponentOrientable( TQ3GeometryObject meshObject, TE3MeshComponentExtRef componentExtRef, TQ3Boolean* orientablePtr) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; // To be implemented... return(kQ3Failure); } //============================================================================= // E3Mesh_GetComponentBoundingBox : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TQ3Status E3Mesh_GetComponentBoundingBox( TQ3GeometryObject meshObject, TE3MeshComponentExtRef componentExtRef, TQ3BoundingBox* boundingBoxPtr) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; // To be implemented... return(kQ3Failure); } //============================================================================= // E3Mesh_GetComponentNumEdges : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- #pragma mark - TQ3Status E3Mesh_GetComponentNumEdges( TQ3GeometryObject meshObject, TE3MeshComponentExtRef componentExtRef, TQ3Uns32* numEdgesPtr) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; // To be implemented... return(kQ3Failure); } //============================================================================= // E3Mesh_FirstComponentEdge : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TE3MeshEdgeExtRef E3Mesh_FirstComponentEdge( TE3MeshComponentExtRef componentExtRef, TQ3MeshIterator* iteratorPtr) { // To be implemented... return(nullptr); } //============================================================================= // E3Mesh_NextComponentEdge : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TE3MeshEdgeExtRef E3Mesh_NextComponentEdge( TQ3MeshIterator* iteratorPtr) { // To be implemented... return(nullptr); } //============================================================================= // E3Mesh_GetComponentNumVertices : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TQ3Status E3Mesh_GetComponentNumVertices( TQ3GeometryObject meshObject, TE3MeshComponentExtRef componentExtRef, TQ3Uns32* numVerticesPtr) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; // To be implemented... return(kQ3Failure); } //============================================================================= // E3Mesh_FirstComponentVertex : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TE3MeshVertexExtRef E3Mesh_FirstComponentVertex( TE3MeshComponentExtRef componentExtRef, TQ3MeshIterator* iteratorPtr) { // To be implemented... return(nullptr); } //============================================================================= // E3Mesh_NextComponentVertex : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TE3MeshVertexExtRef E3Mesh_NextComponentVertex( TQ3MeshIterator* iteratorPtr) { // To be implemented... return(nullptr); } //============================================================================= // E3Mesh_GetFaceIndex : Get index (0..N-1) of face in mesh. //----------------------------------------------------------------------------- // Note : If unable to use array of faces or if face deleted, return // kQ3Failure. //----------------------------------------------------------------------------- #pragma mark - TQ3Status E3Mesh_GetFaceIndex( TQ3GeometryObject meshObject, TE3MeshFaceExtRef faceExtRef, TQ3Uns32* indexPtr) { TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; TE3MeshFaceData* facePtr; // Check face facePtr = e3meshFaceExtRef_Face(faceExtRef); if (facePtr == nullptr) goto failure; // Use array of faces in mesh (*** MAY RELOCATE FACES ***) if (e3mesh_UseFaceArray(meshPtr) == kQ3Failure) goto failure; // Recheck face (in case relocated) facePtr = e3meshFaceExtRef_Face(faceExtRef); // Get index of face *indexPtr = e3meshFaceArray_ItemIndex(&meshPtr->faceArrayOrList.array, facePtr); return(kQ3Success); failure: return(kQ3Failure); } //============================================================================= // E3Mesh_GetFacePlaneEquation : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TQ3Status E3Mesh_GetFacePlaneEquation( TQ3GeometryObject meshObject, TE3MeshFaceExtRef faceExtRef, TQ3PlaneEquation* planeEquationPtr) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; // To be implemented... return(kQ3Failure); } //============================================================================= // E3Mesh_GetFaceAttributeSet : Get attribute set for face. //----------------------------------------------------------------------------- // Note : If face deleted, return kQ3Failure. //----------------------------------------------------------------------------- TQ3Status E3Mesh_GetFaceAttributeSet( TQ3GeometryObject meshObject, TE3MeshFaceExtRef faceExtRef, TQ3AttributeSet* attributeSetPtr) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; TE3MeshFaceData* facePtr; // Check face if ((facePtr = e3meshFaceExtRef_Face(faceExtRef)) == nullptr) goto failure; // Get attribute set E3Shared_Acquire(attributeSetPtr, facePtr->attributeSet); return(kQ3Success); failure: return(kQ3Failure); } //============================================================================= // E3Mesh_SetFaceAttributeSet : Set attribute set for face. //----------------------------------------------------------------------------- // Note : If face deleted, return kQ3Failure. //----------------------------------------------------------------------------- TQ3Status E3Mesh_SetFaceAttributeSet( TQ3GeometryObject meshObject, TE3MeshFaceExtRef faceExtRef, TQ3AttributeSet attributeSet) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; TE3MeshFaceData* facePtr; // Check face if ((facePtr = e3meshFaceExtRef_Face(faceExtRef)) == nullptr) goto failure; // Set attribute set E3Shared_Replace(&facePtr->attributeSet, attributeSet); Q3Shared_Edited(meshObject); return(kQ3Success); failure: return(kQ3Failure); } //============================================================================= // E3Mesh_GetFaceComponent : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- #pragma mark - TQ3Status E3Mesh_GetFaceComponent( TQ3GeometryObject meshObject, TE3MeshFaceExtRef faceExtRef, TE3MeshComponentExtRef* componentExtRefPtr) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; // To be implemented... return(kQ3Failure); } //============================================================================= // E3Mesh_FirstFaceFace : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TE3MeshFaceExtRef E3Mesh_FirstFaceFace( TE3MeshFaceExtRef faceExtRef, TQ3MeshIterator* iteratorPtr) { // To be implemented... return(nullptr); } //============================================================================= // E3Mesh_NextFaceFace : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TE3MeshFaceExtRef E3Mesh_NextFaceFace( TQ3MeshIterator* iteratorPtr) { // To be implemented... return(nullptr); } //============================================================================= // E3Mesh_GetFaceNumContours : Get number of contours in face. //----------------------------------------------------------------------------- // Note : If face deleted, return kQ3Failure. //----------------------------------------------------------------------------- TQ3Status E3Mesh_GetFaceNumContours( TQ3GeometryObject meshObject, TE3MeshFaceExtRef faceExtRef, TQ3Uns32* numContoursPtr) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; TE3MeshFaceData* facePtr; // Check face if ((facePtr = e3meshFaceExtRef_Face(faceExtRef)) == nullptr) goto failure; // Get number of contours in face *numContoursPtr = e3meshFace_NumContours(facePtr); return(kQ3Success); failure: return(kQ3Failure); } //============================================================================= // E3Mesh_FirstFaceContour : Get first contour in face. //----------------------------------------------------------------------------- // Note : If face deleted, no first contour or unable to create // external reference to contour, return nullptr. //----------------------------------------------------------------------------- TE3MeshContourExtRef E3Mesh_FirstFaceContour( TE3MeshFaceExtRef faceExtRef, TQ3MeshIterator* iteratorPtr) { TE3MeshData* meshPtr; TE3MeshFaceData* facePtr; TE3MeshContourData* contourPtr; TE3MeshContourExtRef contourExtRef; // Get mesh for face if ((meshPtr = e3meshFaceExtRef_Mesh(faceExtRef)) == nullptr) goto failure; // Initialize iterator e3meshIterator_Initialize(iteratorPtr, meshPtr, "fact"); // Check and save face if ((facePtr = e3meshFaceExtRef_Face(faceExtRef)) == nullptr) goto failure; iteratorPtr->var2 = faceExtRef; // Get and save first contour in face if ((contourPtr = e3meshContourArrayOrList_FirstItem(&facePtr->contourArrayOrList)) == nullptr) goto failure; if ((contourExtRef = e3meshContour_ExtRefInMesh(contourPtr, meshPtr)) == nullptr) goto failure; iteratorPtr->var1 = contourExtRef; // Return first contour in face return(contourExtRef); failure: iteratorPtr->var2 = nullptr; iteratorPtr->var1 = nullptr; return(nullptr); } //============================================================================= // E3Mesh_NextFaceContour : Get next contour in face. //----------------------------------------------------------------------------- // Note : If iterator ended, face deleted, current contour deleted, // no next contour or unable to create external reference to // contour, return nullptr. //----------------------------------------------------------------------------- TE3MeshContourExtRef E3Mesh_NextFaceContour( TQ3MeshIterator* iteratorPtr) { TE3MeshData* meshPtr = (TE3MeshData*) iteratorPtr->var4.field1; TE3MeshFaceExtRef faceExtRef; TE3MeshFaceData* facePtr; TE3MeshContourExtRef contourExtRef; TE3MeshContourData* contourPtr; // Restore and check face if ((faceExtRef = (TE3MeshFaceExtRef) iteratorPtr->var2) == nullptr) goto failure; if ((facePtr = e3meshFaceExtRef_Face(faceExtRef)) == nullptr) goto failure; // Restore and check current contour in face if ((contourExtRef = (TE3MeshContourExtRef) iteratorPtr->var1) == nullptr) goto failure; if ((contourPtr = e3meshContourExtRef_Contour(contourExtRef)) == nullptr) goto failure; // Get and save next contour in face if ((contourPtr = e3meshContourArrayOrList_NextItem(&facePtr->contourArrayOrList, contourPtr)) == nullptr) goto failure; if ((contourExtRef = e3meshContour_ExtRefInMesh(contourPtr, meshPtr)) == nullptr) goto failure; iteratorPtr->var1 = contourExtRef; // Return next contour in face return(contourExtRef); failure: iteratorPtr->var2 = nullptr; iteratorPtr->var1 = nullptr; return(nullptr); } //============================================================================= // E3Mesh_FirstFaceEdge : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TE3MeshEdgeExtRef E3Mesh_FirstFaceEdge( TE3MeshFaceExtRef faceExtRef, TQ3MeshIterator* iteratorPtr) { // To be implemented... return(nullptr); } //============================================================================= // E3Mesh_NextFaceEdge : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TE3MeshEdgeExtRef E3Mesh_NextFaceEdge(TQ3MeshIterator* iteratorPtr) { // To be implemented... return(nullptr); } //============================================================================= // E3Mesh_GetFaceNumVertices : Get number of vertices in face. //----------------------------------------------------------------------------- // Note : If face deleted, return kQ3Failure. //----------------------------------------------------------------------------- // Note : If a particular vertex occurs multiple times, each occurrence // is counted separately. //----------------------------------------------------------------------------- TQ3Status E3Mesh_GetFaceNumVertices( TQ3GeometryObject meshObject, TE3MeshFaceExtRef faceExtRef, TQ3Uns32* numVerticesPtr) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; TE3MeshFaceData* facePtr; // Check face if ((facePtr = e3meshFaceExtRef_Face(faceExtRef)) == nullptr) goto failure; *numVerticesPtr = e3meshFace_NumVertices(facePtr); return(kQ3Success); failure: return(kQ3Failure); } //============================================================================= // E3Mesh_FirstFaceVertex : Get first vertex in face. //----------------------------------------------------------------------------- // Note : If face deleted, no first vertex or unable to create // external reference to vertex, return nullptr. //----------------------------------------------------------------------------- // Note : If a particular vertex occurs multiple times, each occurrence // is iterated separately. //----------------------------------------------------------------------------- TE3MeshVertexExtRef E3Mesh_FirstFaceVertex( TE3MeshFaceExtRef faceExtRef, TQ3MeshIterator* iteratorPtr) { TE3MeshData* meshPtr; TE3MeshFaceData* facePtr; TE3MeshContourData* contourPtr; TE3MeshContourExtRef contourExtRef; TE3MeshVertexData** vertexHdl; TE3MeshVertexExtRef vertexExtRef; // Get mesh for face if ((meshPtr = e3meshFaceExtRef_Mesh(faceExtRef)) == nullptr) goto failure; // Initialize iterator e3meshIterator_Initialize(iteratorPtr, meshPtr, "fave"); // Check and save face if ((facePtr = e3meshFaceExtRef_Face(faceExtRef)) == nullptr) goto failure; iteratorPtr->var3 = faceExtRef; // Get first contour in face if ((contourPtr = e3meshContourArrayOrList_FirstItem(&facePtr->contourArrayOrList)) == nullptr) goto failure; // Get first vertex in face for (;;) { // If first vertex in current contour exists, break if ((vertexHdl = e3meshVertexPtrArray_FirstItem(&contourPtr->vertexPtrArray)) != nullptr) break; // Otherwise, get next contour in face if ((contourPtr = e3meshContourArrayOrList_NextItem(&facePtr->contourArrayOrList, contourPtr)) == nullptr) goto failure; } // Save current contour in face if ((contourExtRef = e3meshContour_ExtRefInMesh(contourPtr, meshPtr)) == nullptr) goto failure; iteratorPtr->var2 = contourExtRef; // Save first vertex in face if ((vertexExtRef = e3meshVertex_ExtRefInMesh(*vertexHdl, meshPtr)) == nullptr) goto failure; iteratorPtr->var1 = vertexHdl; // Return first vertex in face return(vertexExtRef); failure: iteratorPtr->var3 = nullptr; iteratorPtr->var2 = nullptr; iteratorPtr->var1 = nullptr; return(nullptr); } //============================================================================= // E3Mesh_NextFaceVertex : Get next vertex in face. //----------------------------------------------------------------------------- // Note : If iterator ended, face deleted, current vertex deleted, // no next vertex or unable to create external reference to // vertex, return nullptr. //----------------------------------------------------------------------------- // Note : If a particular vertex occurs multiple times, each occurrence // is iterated separately. //----------------------------------------------------------------------------- TE3MeshVertexExtRef E3Mesh_NextFaceVertex( TQ3MeshIterator* iteratorPtr) { TE3MeshData* meshPtr = (TE3MeshData*) iteratorPtr->var4.field1; TE3MeshFaceExtRef faceExtRef; TE3MeshFaceData* facePtr; TE3MeshContourExtRef contourExtRef; TE3MeshContourData* contourPtr; TE3MeshVertexData** vertexHdl; TE3MeshVertexExtRef vertexExtRef; // Restore and check face if ((faceExtRef = (TE3MeshFaceExtRef) iteratorPtr->var3) == nullptr) goto failure; if ((facePtr = e3meshFaceExtRef_Face(faceExtRef)) == nullptr) goto failure; // Restore and check current contour if ((contourExtRef = (TE3MeshContourExtRef) iteratorPtr->var2) == nullptr) goto failure; if ((contourPtr = e3meshContourExtRef_Contour(contourExtRef)) == nullptr) goto failure; // ??? check that contour still belongs to face ??? // Restore and check current vertex if ((vertexHdl = (TE3MeshVertexData**) iteratorPtr->var1) == nullptr) goto failure; // If next vertex in current contour exists, break if ((vertexHdl = e3meshVertexPtrArray_NextItem(&contourPtr->vertexPtrArray, vertexHdl)) != nullptr) ; // Otherwise, get next vertex in face else { for (;;) { // Get next contour in face if ((contourPtr = e3meshContourArrayOrList_NextItem(&facePtr->contourArrayOrList, contourPtr)) == nullptr) goto failure; // If first vertex in current contour exists, break if ((vertexHdl = e3meshVertexPtrArray_FirstItem(&contourPtr->vertexPtrArray)) != nullptr) break; } } // Save current contour in face if ((contourExtRef = e3meshContour_ExtRefInMesh(contourPtr, meshPtr)) == nullptr) goto failure; iteratorPtr->var2 = contourExtRef; // Save next vertex in face if ((vertexExtRef = e3meshVertex_ExtRefInMesh(*vertexHdl, meshPtr)) == nullptr) goto failure; iteratorPtr->var1 = vertexHdl; // Return next vertex in face return(vertexExtRef); failure: iteratorPtr->var3 = nullptr; iteratorPtr->var2 = nullptr; iteratorPtr->var1 = nullptr; return(nullptr); } //============================================================================= // E3Mesh_GetContourFace : Get face containing contour. //----------------------------------------------------------------------------- // Note : If contour deleted or If unable to get external reference // (out of memory), return kQ3Failure. //----------------------------------------------------------------------------- #pragma mark - TQ3Status E3Mesh_GetContourFace( TQ3GeometryObject meshObject, TE3MeshContourExtRef contourExtRef, TE3MeshFaceExtRef* containerFaceExtRefPtr) { TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; TE3MeshContourData* contourPtr; TE3MeshFaceData* containerFacePtr; // Check contour if ((contourPtr = e3meshContourExtRef_Contour(contourExtRef)) == nullptr) goto failure; // Get external reference to container face containerFacePtr = e3meshContour_ContainerFace(contourPtr); if ((*containerFaceExtRefPtr = e3meshFace_ExtRefInMesh(containerFacePtr, meshPtr)) == nullptr) goto failure; return(kQ3Success); failure: return(kQ3Failure); } //============================================================================= // E3Mesh_FirstContourFace : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TE3MeshFaceExtRef E3Mesh_FirstContourFace( TE3MeshContourExtRef contourExtRef, TQ3MeshIterator* iteratorPtr) { // To be implemented... return(nullptr); } //============================================================================= // E3Mesh_NextContourFace : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TE3MeshFaceExtRef E3Mesh_NextContourFace( TQ3MeshIterator* iteratorPtr) { // To be implemented... return(nullptr); } //============================================================================= // E3Mesh_FirstContourEdge : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TE3MeshEdgeExtRef E3Mesh_FirstContourEdge( TE3MeshContourExtRef contourExtRef, TQ3MeshIterator* iteratorPtr) { // To be implemented... return(nullptr); } //============================================================================= // E3Mesh_NextContourEdge : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TE3MeshEdgeExtRef E3Mesh_NextContourEdge( TQ3MeshIterator* iteratorPtr) { // To be implemented... return(nullptr); } //============================================================================= // E3Mesh_GetContourNumVertices : Get number of vertices in contour. //----------------------------------------------------------------------------- // Note : If contour deleted, return kQ3Failure. //----------------------------------------------------------------------------- // Note : If a particular vertex occurs multiple times, each occurrence // is counted separately. //----------------------------------------------------------------------------- TQ3Status E3Mesh_GetContourNumVertices( TQ3GeometryObject meshObject, TE3MeshContourExtRef contourExtRef, TQ3Uns32* numVerticesPtr) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; TE3MeshContourData* contourPtr; // Check contour if ((contourPtr = e3meshContourExtRef_Contour(contourExtRef)) == nullptr) goto failure; // Get number of vertices in contour *numVerticesPtr = e3meshContour_NumVertices(contourPtr); return(kQ3Success); failure: return(kQ3Failure); } //============================================================================= // E3Mesh_FirstContourVertex : Get first vertex in contour. //----------------------------------------------------------------------------- // Note : If contour deleted, no first vertex or unable to create // external reference to vertex, return nullptr. //----------------------------------------------------------------------------- // Note : If a particular vertex occurs multiple times, each occurrence is // iterated separately. //----------------------------------------------------------------------------- TE3MeshVertexExtRef E3Mesh_FirstContourVertex( TE3MeshContourExtRef contourExtRef, TQ3MeshIterator* iteratorPtr) { TE3MeshData* meshPtr; TE3MeshContourData* contourPtr; TE3MeshVertexData** vertexHdl; TE3MeshVertexExtRef vertexExtRef; // Get mesh for contour if ((meshPtr = e3meshContourExtRef_Mesh(contourExtRef)) == nullptr) goto failure; // Initialize iterator e3meshIterator_Initialize(iteratorPtr, meshPtr, "ctve"); // Check and save contour if ((contourPtr = e3meshContourExtRef_Contour(contourExtRef)) == nullptr) goto failure; iteratorPtr->var2 = contourExtRef; // Get and save first vertex in contour if ((vertexHdl = e3meshVertexPtrArray_FirstItem(&contourPtr->vertexPtrArray)) == nullptr) goto failure; if ((vertexExtRef = e3meshVertex_ExtRefInMesh(*vertexHdl, meshPtr)) == nullptr) goto failure; iteratorPtr->var1 = vertexHdl; // Return first vertex in contour return(vertexExtRef); failure: iteratorPtr->var2 = nullptr; iteratorPtr->var1 = nullptr; return(nullptr); } //============================================================================= // E3Mesh_NextContourVertex : Get next vertex in contour. //----------------------------------------------------------------------------- // Note : If iterator ended, contour deleted, current vertex deleted, // no next vertex or unable to create external reference to // vertex, return nullptr. //----------------------------------------------------------------------------- // Note : If a particular vertex occurs multiple times, each occurrence is // iterated separately. //----------------------------------------------------------------------------- TE3MeshVertexExtRef E3Mesh_NextContourVertex( TQ3MeshIterator* iteratorPtr) { TE3MeshData* meshPtr = (TE3MeshData*) iteratorPtr->var4.field1; TE3MeshContourExtRef contourExtRef; TE3MeshContourData* contourPtr; TE3MeshVertexData** vertexHdl; TE3MeshVertexExtRef vertexExtRef; // Restore and check contour if ((contourExtRef = (TE3MeshContourExtRef) iteratorPtr->var2) == nullptr) goto failure; if ((contourPtr = e3meshContourExtRef_Contour(contourExtRef)) == nullptr) goto failure; // Restore and check current vertex in contour if ((vertexHdl = (TE3MeshVertexData**) iteratorPtr->var1) == nullptr) goto failure; // Get and save next vertex in contour if ((vertexHdl = e3meshVertexPtrArray_NextItem(&contourPtr->vertexPtrArray, vertexHdl)) == nullptr) goto failure; if ((vertexExtRef = e3meshVertex_ExtRefInMesh(*vertexHdl, meshPtr)) == nullptr) goto failure; iteratorPtr->var1 = vertexHdl; // Return next vertex in contour return(vertexExtRef); failure: iteratorPtr->var2 = nullptr; iteratorPtr->var1 = nullptr; return(nullptr); } //============================================================================= // E3Mesh_GetEdgeOnBoundary : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- #pragma mark - TQ3Status E3Mesh_GetEdgeOnBoundary( TQ3GeometryObject meshObject, TE3MeshEdgeExtRef edgeExtRef, TQ3Boolean* onBoundaryPtr) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; // To be implemented... return(kQ3Failure); } //============================================================================= // E3Mesh_GetEdgeAttributeSet : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TQ3Status E3Mesh_GetEdgeAttributeSet( TQ3GeometryObject meshObject, TE3MeshEdgeExtRef edgeExtRef, TQ3AttributeSet* attributeSetPtr) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; // To be implemented... return(kQ3Failure); } //============================================================================= // E3Mesh_SetEdgeAttributeSet : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TQ3Status E3Mesh_SetEdgeAttributeSet( TQ3GeometryObject meshObject, TE3MeshEdgeExtRef edgeExtRef, TQ3AttributeSet attributeSet) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; // To be implemented... Q3Shared_Edited(meshObject); return(kQ3Failure); } //============================================================================= // E3Mesh_GetEdgeComponent : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- #pragma mark - TQ3Status E3Mesh_GetEdgeComponent( TQ3GeometryObject meshObject, TE3MeshEdgeExtRef edgeExtRef, TE3MeshComponentExtRef* componentExtRefPtr) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; // To be implemented... return(kQ3Failure); } //============================================================================= // E3Mesh_GetEdgeFaces : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TQ3Status E3Mesh_GetEdgeFaces( TQ3GeometryObject meshObject, TE3MeshEdgeExtRef edgeExtRef, TE3MeshFaceExtRef* faceExtRefPtr1, TE3MeshFaceExtRef* faceExtRefPtr2) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; // To be implemented... return(kQ3Failure); } //============================================================================= // E3Mesh_GetEdgeVertices : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TQ3Status E3Mesh_GetEdgeVertices( TQ3GeometryObject meshObject, TE3MeshEdgeExtRef edgeExtRef, TE3MeshVertexExtRef* vertexExtRefPtr1, TE3MeshVertexExtRef* vertexExtRefPtr2) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; // To be implemented... return(kQ3Failure); } //============================================================================= // E3Mesh_GetVertexIndex : Get index (0..N-1) of vertex in mesh. //----------------------------------------------------------------------------- // Note : If unable to use array of vertices or if vertex deleted, return // kQ3Failure. //----------------------------------------------------------------------------- #pragma mark - TQ3Status E3Mesh_GetVertexIndex( TQ3GeometryObject meshObject, TE3MeshVertexExtRef vertexExtRef, TQ3Uns32* indexPtr) { TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; TE3MeshVertexData* vertexPtr; // Check vertex vertexPtr = e3meshVertexExtRef_Vertex(vertexExtRef); if (vertexPtr == nullptr) goto failure; // Use array of vertices in mesh (*** MAY RELOCATE VERTICES ***) if (e3mesh_UseVertexArray(meshPtr) == kQ3Failure) goto failure; // Recheck vertex (in case relocated) vertexPtr = e3meshVertexExtRef_Vertex(vertexExtRef); // Get index of vertex *indexPtr = e3meshVertexArray_ItemIndex(&meshPtr->vertexArrayOrList.array, vertexPtr); return(kQ3Success); failure: return(kQ3Failure); } //============================================================================= // E3Mesh_GetVertexOnBoundary : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TQ3Status E3Mesh_GetVertexOnBoundary( TQ3GeometryObject meshObject, TE3MeshVertexExtRef vertexExtRef, TQ3Boolean* onBoundaryPtr) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; // To be implemented... return(kQ3Failure); } //============================================================================= // E3Mesh_GetVertexCoordinates : Get vertex coordinates. //----------------------------------------------------------------------------- // Note : If vertex deleted, return kQ3Failure. //----------------------------------------------------------------------------- TQ3Status E3Mesh_GetVertexCoordinates( TQ3GeometryObject meshObject, TE3MeshVertexExtRef vertexExtRef, TQ3Point3D* coordinatesPtr) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; TE3MeshVertexData* vertexPtr; // Check vertex if ((vertexPtr = e3meshVertexExtRef_Vertex(vertexExtRef)) == nullptr) goto failure; // Get vertex coordinates *coordinatesPtr = vertexPtr->point; return(kQ3Success); failure: return(kQ3Failure); } //============================================================================= // E3Mesh_SetVertexCoordinates : Set vertex coordinates. //----------------------------------------------------------------------------- // Note : If vertex deleted, return kQ3Failure. //----------------------------------------------------------------------------- TQ3Status E3Mesh_SetVertexCoordinates( TQ3GeometryObject meshObject, TE3MeshVertexExtRef vertexExtRef, const TQ3Point3D* coordinates) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; TE3MeshVertexData* vertexPtr; // Check vertex if ((vertexPtr = e3meshVertexExtRef_Vertex(vertexExtRef)) == nullptr) goto failure; // Set vertex coordinates vertexPtr->point = *coordinates; Q3Shared_Edited(meshObject); return(kQ3Success); failure: return(kQ3Failure); } //============================================================================= // E3Mesh_GetVertexAttributeSet : Get vertex attribute set. //----------------------------------------------------------------------------- // Note : If vertex deleted, return kQ3Failure. //----------------------------------------------------------------------------- TQ3Status E3Mesh_GetVertexAttributeSet( TQ3GeometryObject meshObject, TE3MeshVertexExtRef vertexExtRef, TQ3AttributeSet* attributeSetPtr) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; TE3MeshVertexData* vertexPtr; // Check vertex if ((vertexPtr = e3meshVertexExtRef_Vertex(vertexExtRef)) == nullptr) goto failure; // Get vertex attribute set E3Shared_Acquire(attributeSetPtr, vertexPtr->attributeSet); return(kQ3Success); failure: return(kQ3Failure); } //============================================================================= // E3Mesh_SetVertexAttributeSet : Set vertex attribute set. //----------------------------------------------------------------------------- // Note : If vertex deleted, return kQ3Failure. //----------------------------------------------------------------------------- TQ3Status E3Mesh_SetVertexAttributeSet( TQ3GeometryObject meshObject, TE3MeshVertexExtRef vertexExtRef, TQ3AttributeSet attributeSet) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; TE3MeshVertexData* vertexPtr; // Check vertex if ((vertexPtr = e3meshVertexExtRef_Vertex(vertexExtRef)) == nullptr) goto failure; // Set vertex attribute set E3Shared_Replace(&vertexPtr->attributeSet, attributeSet); Q3Shared_Edited(meshObject); return(kQ3Success); failure: return(kQ3Failure); } //============================================================================= // E3Mesh_GetVertexComponent : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- #pragma mark - TQ3Status E3Mesh_GetVertexComponent( TQ3GeometryObject meshObject, TE3MeshVertexExtRef vertexExtRef, TE3MeshComponentExtRef* componentExtRefPtr) { //TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; // To be implemented... return(kQ3Failure); } //============================================================================= // E3Mesh_FirstVertexFace : Get first face having vertex. //----------------------------------------------------------------------------- // Note : If vertex deleted, no first face or unable to create // external reference to face, return nullptr. //----------------------------------------------------------------------------- TE3MeshFaceExtRef E3Mesh_FirstVertexFace( TE3MeshVertexExtRef vertexExtRef, TQ3MeshIterator* iteratorPtr) { TE3MeshData* meshPtr; TE3MeshVertexData* vertexPtr; TE3MeshFaceData* facePtr; TE3MeshFaceExtRef faceExtRef; // Get mesh for vertex if ((meshPtr = e3meshVertexExtRef_Mesh(vertexExtRef)) == nullptr) goto failure; // Initialize iterator e3meshIterator_Initialize(iteratorPtr, meshPtr, "vefa"); // Check and save vertex if ((vertexPtr = e3meshVertexExtRef_Vertex(vertexExtRef)) == nullptr) goto failure; iteratorPtr->var2 = vertexExtRef; // Get first face in mesh if ((facePtr = e3meshFaceArrayOrList_FirstItem(&meshPtr->faceArrayOrList)) == nullptr) goto failure; // Get first face having vertex for (;;) { // If face has vertex, break if (e3meshFace_HasVertex(facePtr, vertexPtr)) break; // Otherwise, get next face in mesh if ((facePtr = e3meshFaceArrayOrList_NextItem(&meshPtr->faceArrayOrList, facePtr)) == nullptr) goto failure; } // Save first face having vertex if ((faceExtRef = e3meshFace_ExtRefInMesh(facePtr, meshPtr)) == nullptr) goto failure; iteratorPtr->var1 = faceExtRef; // Return first face having vertex return(faceExtRef); failure: iteratorPtr->var2 = nullptr; iteratorPtr->var1 = nullptr; return(nullptr); } //============================================================================= // E3Mesh_NextVertexFace : Get next face having vertex. //----------------------------------------------------------------------------- // Note : If iterator ended, vertex deleted, current face deleted, // no next face or unable to create external reference to face, // return nullptr. //----------------------------------------------------------------------------- TE3MeshFaceExtRef E3Mesh_NextVertexFace( TQ3MeshIterator* iteratorPtr) { TE3MeshData* meshPtr = (TE3MeshData*) iteratorPtr->var4.field1; TE3MeshVertexExtRef vertexExtRef; TE3MeshVertexData* vertexPtr; TE3MeshFaceExtRef faceExtRef; TE3MeshFaceData* facePtr; // Restore and check vertex if ((vertexExtRef = (TE3MeshVertexExtRef) iteratorPtr->var2) == nullptr) goto failure; if ((vertexPtr = e3meshVertexExtRef_Vertex(vertexExtRef)) == nullptr) goto failure; // Restore and check current face having vertex if ((faceExtRef = (TE3MeshFaceExtRef) iteratorPtr->var1) == nullptr) goto failure; if ((facePtr = e3meshFaceExtRef_Face(faceExtRef)) == nullptr) goto failure; // Get next face having vertex for (;;) { // Get next face in mesh if ((facePtr = e3meshFaceArrayOrList_NextItem(&meshPtr->faceArrayOrList, facePtr)) == nullptr) goto failure; // If face has vertex, break if (e3meshFace_HasVertex(facePtr, vertexPtr)) break; } // Save next face having vertex if ((faceExtRef = e3meshFace_ExtRefInMesh(facePtr, meshPtr)) == nullptr) goto failure; iteratorPtr->var1 = faceExtRef; // Return next face having vertex return(faceExtRef); failure: iteratorPtr->var2 = nullptr; iteratorPtr->var1 = nullptr; return(nullptr); } //============================================================================= // E3Mesh_FirstVertexEdge : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TE3MeshEdgeExtRef E3Mesh_FirstVertexEdge( TE3MeshVertexExtRef vertexExtRef, TQ3MeshIterator* iteratorPtr) { // To be implemented... return(nullptr); } //============================================================================= // E3Mesh_NextVertexEdge : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TE3MeshEdgeExtRef E3Mesh_NextVertexEdge( TQ3MeshIterator* iteratorPtr) { // To be implemented... return(nullptr); } //============================================================================= // E3Mesh_FirstVertexVertex : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TE3MeshVertexExtRef E3Mesh_FirstVertexVertex( TE3MeshVertexExtRef vertexExtRef, TQ3MeshIterator* iteratorPtr) { // To be implemented... return(nullptr); } //============================================================================= // E3Mesh_NextVertexVertex : One-line description of the method. //----------------------------------------------------------------------------- // Note : More detailed comments can be placed here if required. //----------------------------------------------------------------------------- TE3MeshVertexExtRef E3Mesh_NextVertexVertex( TQ3MeshIterator* iteratorPtr) { // To be implemented... return(nullptr); } //============================================================================= // E3Mesh_GetCornerAttributeSet : Get attribute set for corner. //----------------------------------------------------------------------------- // Note : If vertex or face deleted, return kQ3Failure. //----------------------------------------------------------------------------- #pragma mark - TQ3Status E3Mesh_GetCornerAttributeSet( TQ3GeometryObject meshObject, TE3MeshVertexExtRef vertexExtRef, TE3MeshFaceExtRef faceExtRef, TQ3AttributeSet* attributeSetPtr) { TE3MeshVertexData* vertexPtr; TE3MeshFaceData* facePtr; TE3MeshCornerData* cornerPtr; // Check vertex if ((vertexPtr = e3meshVertexExtRef_Vertex(vertexExtRef)) == nullptr) goto failure; // Check face if ((facePtr = e3meshFaceExtRef_Face(faceExtRef)) == nullptr) goto failure; // Get corner cornerPtr = e3meshVertex_FaceCorner(vertexPtr, facePtr); // Get attribute set if (cornerPtr == nullptr) *attributeSetPtr = nullptr; else E3Shared_Acquire(attributeSetPtr, cornerPtr->attributeSet); return(kQ3Success); failure: return(kQ3Failure); } //============================================================================= // E3Mesh_SetCornerAttributeSet : Set attribute set for corner. //----------------------------------------------------------------------------- // Note : If vertex or face deleted, return kQ3Failure. //----------------------------------------------------------------------------- TQ3Status E3Mesh_SetCornerAttributeSet( TQ3GeometryObject meshObject, TE3MeshVertexExtRef vertexExtRef, TE3MeshFaceExtRef faceExtRef, TQ3AttributeSet newAttributeSet) { TE3MeshData* meshPtr = & ( (E3Mesh*) meshObject )->instanceData ; TE3MeshVertexData* vertexPtr; TE3MeshFaceData* facePtr; TE3MeshCornerData* oldCornerPtr; TQ3AttributeSet oldAttributeSet; TQ3Uns32 oldFaceCount; // Check vertex if ((vertexPtr = e3meshVertexExtRef_Vertex(vertexExtRef)) == nullptr) goto failure; // Check face if ((facePtr = e3meshFaceExtRef_Face(faceExtRef)) == nullptr) goto failure; // Get old corner, attribute set and face count if ((oldCornerPtr = e3meshVertex_FaceCorner(vertexPtr, facePtr)) == nullptr) { oldAttributeSet = nullptr; oldFaceCount = 0; } else { oldAttributeSet = oldCornerPtr->attributeSet; oldFaceCount = e3meshFacePtrArrayOrList_Length(&oldCornerPtr->facePtrArrayOrList); } // If changing attribute set if (oldAttributeSet != newAttributeSet) { TE3MeshCornerData* newCornerPtr; if (newAttributeSet == nullptr) { // ? -> nullptr switch (oldFaceCount) { case 0: // nullptr -> nullptr Q3_ASSERT(0); break; case 1: // x -> nullptr // Delete corner (*** MAY RELOCATE CORNERS ***) if (e3meshVertex_DeleteCorner(vertexPtr, meshPtr, oldCornerPtr) == kQ3Failure) goto failure; break; default: // x+ -> nullptr if (e3meshCorner_DetachFace(oldCornerPtr, facePtr) == kQ3Failure) goto failure; break; } } else if ((newCornerPtr = e3meshVertex_AttributeSetCorner(vertexPtr, meshPtr, newAttributeSet)) == nullptr) { // ? -> y switch (oldFaceCount) { case 0: // nullptr -> y // New corner (*** MAY RELOCATE CORNERS ***) if ((newCornerPtr = e3meshVertex_NewCorner(vertexPtr, meshPtr, newAttributeSet)) == nullptr) goto failure; if (e3meshCorner_AttachFace(newCornerPtr, facePtr) == kQ3Failure) { // e3meshVertex_DeleteCorner can't fail, as e3meshVertex_NewCorner uses list of corners e3meshVertex_DeleteCorner(vertexPtr, meshPtr, newCornerPtr); goto failure; } break; case 1: // x -> y E3Shared_Replace(&oldCornerPtr->attributeSet, newAttributeSet); break; default: // x+ -> y // New corner (*** MAY RELOCATE CORNERS ***) if ((newCornerPtr = e3meshVertex_NewCorner(vertexPtr, meshPtr, newAttributeSet)) == nullptr) goto failure; if (e3meshCorner_SpliceFace(newCornerPtr, oldCornerPtr, facePtr) == kQ3Failure) { // e3meshVertex_DeleteCorner can't fail, as e3meshVertex_NewCorner uses list of corners e3meshVertex_DeleteCorner(vertexPtr, meshPtr, newCornerPtr); goto failure; } break; } } else { // ? -> y+ switch (oldFaceCount) { case 0: // nullptr -> y+ if (e3meshCorner_AttachFace(newCornerPtr, facePtr) == kQ3Failure) goto failure; break; case 1: // x -> y+ if (e3meshCorner_SpliceFace(newCornerPtr, oldCornerPtr, facePtr) == kQ3Failure) goto failure; if (e3meshVertex_DeleteCorner(vertexPtr, meshPtr, oldCornerPtr) == kQ3Failure) { // e3meshCorner_SpliceFace can't fail, as previous call already uses lists of face pointers e3meshCorner_SpliceFace(oldCornerPtr, newCornerPtr, facePtr); goto failure; } break; default: // x+ -> y+ if (e3meshCorner_SpliceFace(newCornerPtr, oldCornerPtr, facePtr) == kQ3Failure) goto failure; break; } } Q3Shared_Edited(meshObject); } return(kQ3Success); failure: return(kQ3Failure); }
834b05fbf4d3e181fbfaec41dbd0638c4cd55b29
dfbf881a7419f35c344e5d271d112a2d3e9fd525
/ExperPortHLabTrainingBoxes/RTLinuxServer/LynxTWO-RT/LynxTWO/HalSampleClock.h
f52e5cddb8a38504e8b765c6b70255c38513c5b3
[]
no_license
jonathansy/BControl_Primary
13ea066fd16c55a30774a68b73f50d63b2a25b94
057039f984741107e37d768889aaf3321188e6d7
refs/heads/master
2016-09-02T01:19:48.312376
2015-02-28T00:02:13
2015-02-28T00:02:13
31,345,565
0
1
null
null
null
null
WINDOWS-1252
C++
false
false
2,569
h
HalSampleClock.h
/**************************************************************************** HalSampleClock.h Description: Interface for the HalSampleClock class. Created: David A. Hoatson, September 2000 Copyright © 2000 Lynx Studio Technology, Inc. This software contains the valuable TRADE SECRETS and CONFIDENTIAL INFORMATION of Lynx Studio Technology, Inc. The software is protected under copyright laws as an unpublished work of Lynx Studio Technology, Inc. Notice is for informational purposes only and does not imply publication. The user of this software may make copies of the software for use with products manufactured by Lynx Studio Technology, Inc. or under license from Lynx Studio Technology, Inc. and for no other use. THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. Environment: 4 spaces per tab Revision History When Who Description --------- --- ------------------------------------------------------------ ****************************************************************************/ #ifndef _HALSAMPLECLOCK_H #define _HALSAMPLECLOCK_H #include "Hal.h" typedef struct { ULONG ulM; ULONG ulBypassM; ULONG ulN; ULONG ulP; ULONG ulClkSrc; ULONG ulWord; ULONG ulSpeed; } PLLCLOCKINFO, *PPLLCLOCKINFO; typedef struct { long lSRate; USHORT usM; USHORT usN; USHORT usP; } SRREGS, *PSRREGS; class CHalSampleClock { public: CHalSampleClock() {} ~CHalSampleClock() {} void operator= (long lRate) { Set( lRate ); } operator long() { return( m_lRate ); } USHORT Open( PHALADAPTER pHalAdapter ); USHORT Close(); USHORT Get( long *plRate, long *plSource, long *plReference ); USHORT Get( long *plRate ); USHORT Set( long lRate, long lSource, long lReference, BOOLEAN bForce = FALSE ); USHORT Set( long lRate, BOOLEAN bForce = FALSE ); USHORT GetClockRate( long *plRate, long *plSource, long *plReference ); USHORT GetMinMax( long *plMin, long *plMax ); private: USHORT GetClockInfo( long *plRate, PSRREGS pSRRegs, PPLLCLOCKINFO pClockInfo, int ulNumberOfEntires ); PHALADAPTER m_pHalAdapter; CHalRegister m_RegPLLCTL; long m_lRate; long m_lSource; long m_lReference; ULONG m_ulSpeed; ULONG m_ulP; }; #endif // _HALSAMPLECLOCK_H
b18ec48ac2b46a9ee0b8fb20c49085fa9d20d670
2c70f9fce1d94f1a434b48b8f725bc577d631072
/CPRGame/cpr_model.h
cedb173e3760a5acc7c391f65fa1618480acfa13
[]
no_license
truongtrain/CPR-Trainer
bee2528bb788806d4db09c695c0f51ebaf9e6fdc
92e9d87ef7fa7dbeca2185214671e86d69e7d18c
refs/heads/master
2020-04-18T06:29:47.467032
2018-12-08T22:13:32
2018-12-08T22:13:32
167,323,292
0
0
null
null
null
null
UTF-8
C++
false
false
3,524
h
cpr_model.h
#ifndef CPR_MODEL_H #define CPR_MODEL_H #include <QObject> #include <iostream> #include <QTimer> #include "metronome.h" #include <QMediaPlayer> #include <QMediaPlaylist> using namespace std; /** * This is the CPR model class. The model interprets the actions sent from the * GUI and sends a result back to the GUI. This class handles the current state * of the game. */ class CPR_Model : public QObject { Q_OBJECT public: /** * CPR constructor that simply initializes a few of our fields for the game. */ CPR_Model(); /** * Constant integers that keeps track of scenarios. */ enum GameState { CHECK_RESPONSIVENESS = 0, CALL_FOR_911_AND_AED = 1, CHECK_PULSE_AND_BREATHING = 2, GIVE_BREATH = 3, PLACE_HANDS = 4, GIVE_COMPRESSION = 5, TURN_ON_AED = 6, APPLY_PADS = 7, SHOUT_CLEAR_FOR_ANALYZE = 8, PRESS_ANALYZE = 9, SHOUT_CLEAR_FOR_SHOCK = 10, PRESS_SHOCK = 11, GAME_OVER = 12, SHOUT_CLEAR = 13}; private: /** * Keeps track of the current scenario in our game. */ int currentState; QMediaPlayer *stayinAlive; /** * Boolean flags to help keep track if certain conditions have been met * in our game (consciousness, pulse, and breathing). */ bool isPatientConscious; bool doesPatientHavePulse; bool isPatientBreathing; /** * Is true when user clicks Pro Mode in our title screen. */ bool isProMode; /** * Keeps track of the number of compressions and breaths given. */ int compressionsGiven; int badCompressionsRateCount; int breathsGiven; /** * Keeps track of the number of cycles completed of compressions and * breaths. */ int cyclesCompleted; /** * This is used for pro mode. When the time runs out, you lose the game. */ int timeLeft; /* Used when monitoring compressions rate. */ Metronome metronome; /** * Advances the current scenario if an action from the GUI was correct. */ void advanceSuccessfully(); /** * If pro mode is on, ends the game if the user selects the wrong action * in a given scenario. */ void actionFailed(); /** * Calculates how much time is left and sends it to the GUI */ void displayTimeLeft(); public slots: /** * This is a slot that listens to the CPR actions performed from the view, * and decides if they were correct. */ void actionPerformed(int); /** * Initializes a new game for our CPR game. */ void newGame(bool); signals: /** * Emits a signal to the GUI of the current scenario of our game. */ void changeStatusBoxSignal(string message); /** * Emits a signal to the GUI of a hint to display. */ void changeTutorialBoxSignal(string message); /** * Emits a signal to the GUI that the user has won the game. */ void gameOverWinSignal(string message); /** * Emits a signal to the GUI that the user has lost the game. */ void gameOverLoseSignal(string message); /** * Emits a signal to the GUI to change the time left indicator */ void changeTimeLeftSignal(int time); void cursorChange(); void isMoveCorrect(bool isCorrect); /** * Emits a signal to the GUI when the AED is activated in the game. */ void toggleAEDSignal(bool toggle); void updateLcdSignal(int rate); }; #endif // CPR_MODEL_H
c04351f5fd619042d0ad13f194f249d657703620
6b5cd466b6ebb7d52e3016bd998660d46ca185bd
/SPOj/Catapult that ball.cpp
9cbcf12bad6d4320232211282e0172bad2fe25aa
[]
no_license
SaqlainAveiro/Competitive-Programming-Solves
5e3154be7b6beaf36b165e10698e4b018bf46d63
f8e5b0a9ed7ee7be3216ff2438d3053a9c9892af
refs/heads/main
2023-05-10T06:12:22.524375
2021-06-06T09:36:01
2021-06-06T09:36:01
373,970,266
0
0
null
null
null
null
UTF-8
C++
false
false
1,482
cpp
Catapult that ball.cpp
#include<bits/stdc++.h> using namespace std; typedef long long int lli ; lli i,j,k,l,m,n,t,a,b,c,d,x,y,sum=0,total=0; const lli MAXN = 105000; const lli MAXLOG = 20; lli ar[MAXN]; lli table[MAXLOG][MAXN]; lli logs[MAXN]; // logs[i] means such maximum p that 2^p <= i void computeLogs() { logs[1] = 0; for (i = 2; i <= n; i++) { logs[i] = logs[i / 2] + 1; } } void buildSparseTable() { for (lli i = 0 ; i <= logs[n] ; i++) { lli curLen = 1 << i; // 2^i for (lli j = 0 ; j + curLen <= n ; j++) { if (curLen == 1) { table[i][j] = ar[j]; } else { table[i][j] = max(table[i - 1][j] , table[i - 1][j + (curLen / 2)]); } } } } lli getMax(lli l, lli r) { lli p = logs[r - l + 1]; lli pLen = 1 << p; // 2^p return max(table[p][l] , table[p][r - pLen + 1]); } int main() { ios_base :: sync_with_stdio(false); cin.tie(0); //freopen("Input.txt","r",stdin); cin>>n>>m; for(i=0 ; i<n ; i++) { cin>>ar[i]; } computeLogs(); buildSparseTable(); sum=0; for(i=1 ; i<=m ; i++) { cin>>x>>y; total=getMax(x-1,y-2); if(abs(x-y)<=1 || ar[x-1]>=total) { sum++; } } cout<<sum<<"\n"; }
c5f7c705c4c51c17e5da3c3d6bb220b9e2b2b001
2702a05a71e8d061b3101f468188c7a7082a2ff6
/Project3/RayTracer.cpp
40a8f5df57fbc31a9c894cb0957511e310b52a29
[]
no_license
lameya17/RayTracer
7487dd733004af45e7afc8e2f1643e2802dc5b90
ecfa933abaac259ccff4460f11f687d104bc3498
refs/heads/master
2019-08-04T06:29:47.908854
2017-11-07T20:16:34
2017-11-07T20:16:34
73,140,481
0
0
null
null
null
null
UTF-8
C++
false
false
19,296
cpp
RayTracer.cpp
#include "Camera.h" #include "Sphere.h" #include "Triangle.h" #include <iostream> #include <conio.h> #include <stdio.h> #include "Light.h" #include<cstdlib> #include<ctime> #include "Mesh.h" double screenHeight; double screenWidth; double La = 0.9; double air = 1.0; Color background = Color(0.27f, 0.54f, 0.83f); Object *obj[4]; int objCount = 4; int fileSize = (int)screenHeight*(int)screenWidth; Color *pixels = new Color[fileSize]; //double *Lum = new double[fileSize]; Light *yagami[2]; int lightCount = 1; bool insideSphere = false; double r_index; double randGen() { double hi = -2.1; double lo = -3.0; double randNum = 0.0; randNum = (double)rand() / (double)RAND_MAX; return lo + randNum * (hi - lo); return randNum; } void savebmp(const char *filename, int w, int h, int dpi, Color *data) { double sf; double R; double G; double B; double delta = 0.001; double Lwa = 0.0; double Ldmax = 100; double Lmax = 100; int whichTR = 0; // 0 for ward, 1 for reinhard, 2 for adaptive logarithmic FILE *f; int k = w*h; int s = 4 * k; int filesize = 54 + s; //const int size = 640 * 480; double L; double factor = 39.375; int m = static_cast<int>(factor); int ppm = dpi*m; unsigned char bmpfileheader[14] = { 'B', 'M', 0, 0, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0 }; unsigned char bmpinfoheader[40] = { 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 24, 0 }; bmpfileheader[2] = (unsigned char)(filesize); bmpfileheader[3] = (unsigned char)(filesize >> 8); bmpfileheader[4] = (unsigned char)(filesize >> 16); bmpfileheader[5] = (unsigned char)(filesize >> 24); bmpinfoheader[4] = (unsigned char)(w); bmpinfoheader[5] = (unsigned char)(w >> 8); bmpinfoheader[6] = (unsigned char)(w >> 16); bmpinfoheader[7] = (unsigned char)(w >> 24); bmpinfoheader[8] = (unsigned char)(h); bmpinfoheader[9] = (unsigned char)(h >> 8); bmpinfoheader[10] = (unsigned char)(h >> 16); bmpinfoheader[11] = (unsigned char)(h >> 24); bmpinfoheader[21] = (unsigned char)(s); bmpinfoheader[22] = (unsigned char)(s >> 8); bmpinfoheader[23] = (unsigned char)(s >> 16); bmpinfoheader[24] = (unsigned char)(s >> 24); bmpinfoheader[25] = (unsigned char)(ppm); bmpinfoheader[26] = (unsigned char)(ppm >> 8); bmpinfoheader[27] = (unsigned char)(ppm >> 16); bmpinfoheader[28] = (unsigned char)(ppm >> 24); bmpinfoheader[29] = (unsigned char)(ppm); bmpinfoheader[30] = (unsigned char)(ppm >> 8); bmpinfoheader[31] = (unsigned char)(ppm >> 16); bmpinfoheader[32] = (unsigned char)(ppm >> 24); f = fopen(filename, "wb"); fwrite(bmpfileheader, 1, 14, f); fwrite(bmpinfoheader, 1, 40, f); for (int i = 0; i < k; i++) { Color rgb = data[i]; double temp = data[i].getR(); if (temp < data[i].getG()) temp = data[i].getG(); if (temp < data[i].getB()) temp = data[i].getB(); double maximum = temp; /*if (maximum > 1.0) { data[i].setR(data[i].getR() / maximum); data[i].setG(data[i].getG() / maximum); data[i].setB(data[i].getB() / maximum); }*/ R = data[i].getR() * Lmax; G = data[i].getG() * Lmax; B = data[i].getB() * Lmax; //if (i = 1579) // std::cout << "pizdec"; L = 0.27*R + 0.67*G + 0.06*B; Lwa = Lwa + log(delta + L); } Lwa = exp(Lwa/k); sf = pow((1.219 + pow(Ldmax / 2, 0.4)) / (1.219 + pow(Lwa, 0.4)), 2.5) / Ldmax; for (int i = 0; i < k; i++) { // Overall luminance //L(x, y) = 0.27R(x, y) + 0.67G(x, y) + 0.06B(x, y) R = data[i].getR() * Lmax; G = data[i].getG() * Lmax; B = data[i].getB() * Lmax; if (whichTR == 0) // Ward { double red = sf * R; double green = sf * G; double blue = sf * B; double t = red; if (t < green) t = green; if (t < blue) t = blue; double max = t; if (max > 1.0) { red = red / max; green = green / max; blue = blue / max; } red = red * 255; blue = blue * 255; green = green * 255; unsigned char color[3] = { (int)floor(blue), (int)floor(green), (int)floor(red) }; fwrite(color, 1, 3, f); } else if (whichTR == 1) // Reinhard { double a = 0.18; double Rs = R * a / Lwa; double Gs = G * a / Lwa; double Bs = B * a / Lwa; double Rr = Rs / (1 + Rs); double Gr = Gs / (1 + Gs); double Br = Bs / (1 + Bs); double red = Rr * Ldmax; double green = Gr * Ldmax; double blue = Br * Ldmax; //double red = Rr * 255; //double green = Gr * 255; //double blue = Br * 255; double t = red; if (t < green) t = green; if (t < blue) t = blue; double max = t; if (max > 1.0) { red = red / max; green = green / max; blue = blue / max; } red = red * 255; blue = blue * 255; green = green * 255; unsigned char color[3] = { (int)floor(blue), (int)floor(green), (int)floor(red) }; fwrite(color, 1, 3, f); } else if (whichTR == 2) // logarithmic(advanced) { L = 0.2999 * R + 0.587 * G + 0.114 * B; double Lwmax = Lmax / Lwa; L = L / Lwa; double b = 0.85; double biasexpo = log(b) / log(0.5); double term2 = pow(L / Lwmax, biasexpo) * 0.8; double term1 = 1 / log10(Lwmax + 1); double Ld = Ldmax * 0.01 * log(L + 1) / log(2 + term2); double red = Ld * R; double green = Ld * G; double blue = Ld * B; double t = red; if (t < green) t = green; if (t < blue) t = blue; double max = t; if (max > 1.0) { red = red / max; green = green / max; blue = blue / max; } red = red * 255; blue = blue * 255; green = green * 255; unsigned char color[3] = { (int)floor(blue), (int)floor(green), (int)floor(red) }; fwrite(color, 1, 3, f); } } fclose(f); } Ray TransmitRay(Ray revI, Vector Normal, bool insideSphere, Vector insp, double ni, double nr) { double ri = ni/nr; //Vector revdir = Vector(-1*incident.getDirection().getVectX(), -1*incident.getDirection().getVectY(), -1*incident.getDirection().getVectZ()); //Ray revI = Ray(insp, revdir, incident.getRI()); double temp1 = 1 - (ri*ri)*(1 - pow(Normal.dotProduct(revI.getDirection()), 2)); double temp2 = ri * (Normal.dotProduct(revI.getDirection())) - sqrt(temp1); Vector v1 = Vector(temp2*Normal.getVectX(), temp2*Normal.getVectY(), temp2*Normal.getVectZ()); Vector v2 = Vector(ri*revI.getDirection().getVectX(), ri*revI.getDirection().getVectY(), ri*revI.getDirection().getVectZ()); if (insideSphere) ri = air; else ri = ni; return Ray(insp, v1.subtract(v2), ri); } //Color background = Color(0.0f, 0.0f, 0.0f); Color illuminate(Ray r, int depth) { //r_index = r.getRI(); Ray transmit; Ray reflect; Color retcolor; double lowest = 1000000; int lowestIndex = -1; //int count = 0; for (int count = 0; count < objCount; count++) { double insp = obj[count]->Intersection(r); if (insp == -1) { continue; } else { if (lowest > insp) { lowestIndex = count; lowest = insp; } } } if (lowestIndex == -1) { //set background color retcolor.setR(background.getR()); retcolor.setG(background.getG()); retcolor.setB(background.getB()); return retcolor; } else { bool tileFlag = false; double shadowScale = 1; bool shadows = false; Color diffuse = Color(0.0f, 0.0f, 0.0f); Color ambient = Color(0.0f, 0.0f, 0.0f); Color specular = Color(0.0f, 0.0f, 0.0f); Vector intersection = Vector(r.getOrigin().getVectX() + r.getDirection().getVectX() * lowest, r.getOrigin().getVectY() + r.getDirection().getVectY() * lowest, r.getOrigin().getVectZ() + r.getDirection().getVectZ() * lowest); for (int l = 0; l < lightCount; l++) { shadows = false; Vector N1 = obj[lowestIndex]->getNormalAt(intersection); Vector N = obj[lowestIndex]->getNormalAt(intersection); N = N.normalize(); //Vector RayDir = intersection.subtract(r.getOrigin()); Ray shadowRay = Ray(intersection, yagami[l]->getPosition().subtract(intersection).normalize(), obj[lowestIndex]->transI); Vector V = (intersection.subtract(yagami[l]->getPosition())).normalize(); // S - 2 S.n/|n^2| n Vector R = shadowRay.getDirection().subtract( Vector(2 * N.dotProduct(shadowRay.getDirection()) * N.getVectX(), 2 * N.dotProduct(shadowRay.getDirection()) * N.getVectY(), 2 * N.dotProduct(shadowRay.getDirection()) * N.getVectZ())); double temp = 2 * (r.getDirection().dotProduct(N)); R = R.normalize(); // double temp = 2 * (r.getDirection().dotProduct(N)); // reflect = incident ray - (normal * temp); Vector ref = r.getDirection().subtract(Vector(N.getVectX() * temp, N.getVectY() * temp, N.getVectZ() * temp)); reflect = Ray(intersection, ref, r.getRI()); Vector revdir = Vector(-1*r.getDirection().getVectX(), -1*r.getDirection().getVectY(), -1*r.getDirection().getVectZ()); Ray revI = Ray(intersection, revdir, r.getRI()); Vector Ni = N; double ratio = revI.getRI() / obj[lowestIndex]->transI;; double ni = revI.getRI(); double nr = obj[lowestIndex]->transI; if (revI.getDirection().dotProduct(N) > 0) { insideSphere = false; ratio = revI.getRI() / obj[lowestIndex]->transI; } else if (lowestIndex == 0) { insideSphere = true; Ni = Vector(-1 * N1.getVectX(), -1 * N1.getVectY(), -1 * N1.getVectZ()); ratio = obj[lowestIndex]->transI/air; ni = obj[lowestIndex]->transI; nr = air; } N1 = N1.normalize(); Ni = Ni.normalize(); double temp1 = 1 - (ratio*ratio)*(1 - pow(Ni.dotProduct(r.getDirection()), 2)); if (temp1 < 0) transmit = reflect; else transmit = TransmitRay(revI, Ni, insideSphere, intersection, ni, nr); if (insideSphere == true) { // insideSphere = false; } // shadows for (int i = 0; i < objCount; i++) { if (obj[i]->Intersection(shadowRay) > 0.0001) { if (obj[i]->Kt > 0) { shadowScale = shadowScale - obj[i]->Kt; } shadowScale += 1; shadows = true; break; } } if (lowestIndex > 1) { int tile = (int)floor(intersection.getVectX() / 1.35) + (int)floor(intersection.getVectZ() / 1.35); if (tile % 2 == 0) { tileFlag = false; if (N.dotProduct(shadowRay.getDirection()) > 0.0001) { diffuse.setR(diffuse.getR() + (N.dotProduct(shadowRay.getDirection())*yagami[l]->getColor().getR() * obj[lowestIndex]->getColor(1).getR())); diffuse.setG(diffuse.getG() + (N.dotProduct(shadowRay.getDirection())*yagami[l]->getColor().getG() * obj[lowestIndex]->getColor(1).getG())); diffuse.setB(diffuse.getB() + (N.dotProduct(shadowRay.getDirection())*yagami[l]->getColor().getB() * obj[lowestIndex]->getColor(1).getB())); } if (V.dotProduct(R) > 0.0001) { //Specular = Ks * (DOT(V, 2 * DOT(N, L) * N - L))^roughness * Od * Ld specular.setR(specular.getR() + (pow(V.dotProduct(R), obj[lowestIndex]->Ke) * (yagami[l]->getColor().getR()))); specular.setG(specular.getG() + (pow(V.dotProduct(R), obj[lowestIndex]->Ke) * (yagami[l]->getColor().getG()))); specular.setB(specular.getB() + (pow(V.dotProduct(R), obj[lowestIndex]->Ke) * (yagami[l]->getColor().getB()))); } continue; } else { tileFlag = true; if (N.dotProduct(shadowRay.getDirection()) > 0.0001) { diffuse.setR(diffuse.getR() + (N.dotProduct(shadowRay.getDirection())*yagami[l]->getColor().getR() * obj[lowestIndex]->getColor(2).getR())); diffuse.setG(diffuse.getG() + (N.dotProduct(shadowRay.getDirection())*yagami[l]->getColor().getG() * obj[lowestIndex]->getColor(2).getG())); diffuse.setB(diffuse.getB() + (N.dotProduct(shadowRay.getDirection())*yagami[l]->getColor().getB() * obj[lowestIndex]->getColor(2).getB())); } if (V.dotProduct(R) > 0.0001) { //Specular = Ks * (DOT(V, 2 * DOT(N, L) * N - L))^roughness * Od * Ld specular.setR(specular.getR() + (pow(V.dotProduct(R), obj[lowestIndex]->Ke) * (yagami[l]->getColor().getR()))); specular.setG(specular.getG() + (pow(V.dotProduct(R), obj[lowestIndex]->Ke) * (yagami[l]->getColor().getG()))); specular.setB(specular.getB() + (pow(V.dotProduct(R), obj[lowestIndex]->Ke) * (yagami[l]->getColor().getB()))); } continue; } } if (N.dotProduct(shadowRay.getDirection()) > 0.0001) { diffuse.setR(diffuse.getR() + (N.dotProduct(shadowRay.getDirection())*yagami[l]->getColor().getR() * obj[lowestIndex]->getColor(1).getR())); diffuse.setG(diffuse.getG() + (N.dotProduct(shadowRay.getDirection())*yagami[l]->getColor().getG() * obj[lowestIndex]->getColor(1).getG())); diffuse.setB(diffuse.getB() + (N.dotProduct(shadowRay.getDirection())*yagami[l]->getColor().getB() * obj[lowestIndex]->getColor(1).getB())); } if (V.dotProduct(R) > 0.0001) { specular.setR(specular.getR() + (pow(V.dotProduct(R), obj[lowestIndex]->Ke) * (yagami[l]->getColor().getR()))); specular.setG(specular.getG() + (pow(V.dotProduct(R), obj[lowestIndex]->Ke) * (yagami[l]->getColor().getG()))); specular.setB(specular.getB() + (pow(V.dotProduct(R), obj[lowestIndex]->Ke) * (yagami[l]->getColor().getB()))); } } if (tileFlag == false) { ambient.setR(obj[lowestIndex]->Ka * obj[lowestIndex]->getColor(1).getR() * La); // shadowScale); ambient.setG(obj[lowestIndex]->Ka * obj[lowestIndex]->getColor(1).getG() * La); // shadowScale); ambient.setB(obj[lowestIndex]->Ka * obj[lowestIndex]->getColor(1).getB() * La); // shadowScale); } else { ambient.setR(obj[lowestIndex]->Ka * obj[lowestIndex]->getColor(2).getR() * La / shadowScale); ambient.setG(obj[lowestIndex]->Ka * obj[lowestIndex]->getColor(2).getG() * La / shadowScale); ambient.setB(obj[lowestIndex]->Ka * obj[lowestIndex]->getColor(2).getB() * La / shadowScale); } // final specular claculation specular.setR(obj[lowestIndex]->Ks * specular.getR()); specular.setG(obj[lowestIndex]->Ks * specular.getG()); specular.setB(obj[lowestIndex]->Ks * specular.getB()); // diffuse final calculation diffuse.setR(obj[lowestIndex]->Kd * diffuse.getR()); diffuse.setG(obj[lowestIndex]->Kd * diffuse.getG()); diffuse.setB(obj[lowestIndex]->Kd * diffuse.getB()); retcolor.setR((diffuse.getR() + ambient.getR() + specular.getR()) / shadowScale); retcolor.setG((diffuse.getG() + ambient.getG() + specular.getG()) / shadowScale); retcolor.setB((diffuse.getB() + ambient.getB() + specular.getB()) / shadowScale); if (insideSphere) { //retcolor.setR(0.0f); //retcolor.setG(0.0f); //retcolor.setB(0.0f); } if (insideSphere) insideSphere = false; //return retcolor; if (depth < 6) { if (obj[lowestIndex]->Kr > 0) { retcolor.setR(retcolor.getR() + obj[lowestIndex]->Kr * illuminate(reflect, depth + 1).getR()); retcolor.setG(retcolor.getG() + obj[lowestIndex]->Kr * illuminate(reflect, depth + 1).getG()); retcolor.setB(retcolor.getB() + obj[lowestIndex]->Kr * illuminate(reflect, depth + 1).getB()); } if (obj[lowestIndex]->Kt > 0) { retcolor.setR(retcolor.getR() + obj[lowestIndex]->Kt * illuminate(transmit, depth + 1).getR()); retcolor.setG(retcolor.getG() + obj[lowestIndex]->Kt * illuminate(transmit, depth + 1).getG()); retcolor.setB(retcolor.getB() + obj[lowestIndex]->Kt * illuminate(transmit, depth + 1).getB()); } } return retcolor; } } int main() { srand(time(NULL)); Camera camera = Camera(); Vector cameraU, cameraV, cameraN; Vector center; screenWidth = 640.0; screenHeight = 480.0; double aspectratio = screenWidth / screenHeight; yagami[0] = new Light(Vector(2.0, 2.0, 0.0), Color(1.0f, 1.0f, 1.0f)); yagami[1] = new Light(Vector(0.0, 0.0, 0.0), Color(1.0f, 1.0f, 1.0f)); /* //Mesh *mesh[9]; int x_rows = 31; int z_rows = 31; Mesh *mesh[31][31]; int meshCount = 0; double X = -5; double xval = 0.5; double Z = 2.0; double zval = 0.5; for(int z = 0; z < z_rows; z++) { X = -5; for(int x = 0; x <x_rows; x++) { mesh[z][x] = new Mesh(X, randGen(), Z); X += xval; } Z += zval; } int tmp = 0; int x = 0; int z = 0; while (z < z_rows - 1) { std ::cout << z; x = 0; while (x < x_rows - 1) { obj[tmp++] = new Triangle(mesh[z][x]->V, mesh[z][x+1]->V, mesh[z+1][x+1]->V, Illumination(Color(0.2f, 0.3f, 1.0f), Color(0.2f, 0.3f, 1.0f)), 0.6, 0.2, 0.6, 5, 0.0, 0.0); obj[tmp++] = new Triangle(mesh[z][x]->V, mesh[z+1][x+1]->V, mesh[z+1][x]->V, Illumination(Color(0.2f, 0.3f, 1.0f), Color(0.2f, 0.3f, 1.0f)), 0.6, 0.2, 0.6, 5, 0.0, 0.0); x++; } z++; } */ obj[0] = new Sphere(Vector(-0.8, 0.22, 5.1), 1.4, Color(0.2f, 0.2f, 0.2f), 0.3, 0.5, 0.3, 5, 0.8, 0.0, 1.0); obj[1] = new Sphere(Vector( 1.5, -0.20, 8.5), 2.0, Color(0.0f, 0.0f, 0.4f), 0.3, 0.6, 0.3, 5, 0.0, 0.3, 1.0); obj[2] = new Triangle(Vector(4.0, -2.69, 2.68), Vector(4.0, -2.69, 16.61), Vector(-4.0, -2.69, 16.61), Illumination(Color(0.4f, 0.0f, 0.0f), Color(0.5f, 0.5f, 0.1f)), 0.6, 0.4, 0.9, 5, 0.0, 0.0, 1.0); obj[3] = new Triangle(Vector(4.0, -2.69, 2.68), Vector(-4.0, -2.69, 16.61), Vector(-4.0, -2.69, 2.68), Illumination(Color(0.4f, 0.0f, 0.0f), Color(0.5f, 0.5f, 0.1f)), 0.6, 0.4, 0.9, 5, 0.0, 0.0, 1.0); cameraN = camera.getCameraPosition().subtract(camera.getCameraLookAt()); cameraN = cameraN.normalize(); cameraU = cameraN.crossProduct(camera.getCameraUp()); cameraU = cameraU.normalize(); cameraV = cameraU.crossProduct(cameraN); double focalLength = 1; // + for maya && - for unity center = Vector(camera.getCameraPosition().getVectX() - focalLength * cameraN.getVectX(), camera.getCameraPosition().getVectY() - focalLength * cameraN.getVectY(), camera.getCameraPosition().getVectZ() - focalLength * cameraN.getVectZ()); double worldWidth = 2; double worldHeight = worldWidth / aspectratio; // W = H* aspect ratio double pixelDx = worldWidth/screenWidth; double pixelDy = worldHeight/screenHeight; //starting pixel double startX = center.getVectX() - (worldWidth * cameraU.getVectX() + (worldHeight * cameraV.getVectX())) / 2.0; double startY = center.getVectY() - (worldWidth * cameraU.getVectY() + (worldHeight * cameraV.getVectY())) / 2.0; double startZ = center.getVectZ() - (worldWidth * cameraU.getVectZ() + (worldHeight * cameraV.getVectZ())) / 2.0; Vector start = Vector(startX, startY, startZ); int fileSize = (int)screenHeight*(int)screenWidth; Color *pixels = new Color[fileSize]; int position = 0; Color retcolor; for (int i = 0; i < screenHeight; i++) { for (int j = 0; j < screenWidth; j++) { Vector temp = Vector(start.getVectX() + cameraU.getVectX() * (j + 0.5) * pixelDx + cameraV.getVectX() * (i + 0.5) * pixelDy, start.getVectY() + cameraU.getVectY() * (j + 0.5) * pixelDx + cameraV.getVectY() * (i + 0.5) * pixelDy, start.getVectZ() + cameraU.getVectZ() * (j + 0.5) * pixelDx + cameraV.getVectZ() * (i + 0.5) * pixelDy); Vector d = temp.subtract(camera.getCameraPosition()); d = d.normalize(); insideSphere = false; Ray r(camera.getCameraPosition(),d, air); retcolor = illuminate(r, 0); pixels[position].setR(retcolor.getR()); pixels[position].setG(retcolor.getG()); pixels[position].setB(retcolor.getB()); //Lum[position] = 0.0; //} position++; } } savebmp("scene.bmp", screenWidth, screenHeight, 72, pixels); return 0; }
4a4ff3acc9dbe325635927f8adc0c0e998bb6e68
907991827e27a82d886dc9eba71db9726c42bde6
/Sspider1.0/Conn.cc
2dcb0e1947bbc8a8d74f12cf473325ab16b3b28c
[]
no_license
tkasozi/webSpider1.0
a8141950ee0fa7603e18d0d6ea31449fb2680c76
ef00436d7d2af7ad8cc5318b78c43e4e61374271
refs/heads/master
2020-12-31T05:55:32.230809
2016-05-01T04:05:41
2016-05-01T04:05:41
57,477,355
0
0
null
null
null
null
UTF-8
C++
false
false
1,470
cc
Conn.cc
/* * File: Conn.cc * Author: Talik Kasozi * * Created on March 14, 2015, 11:36 PM */ #include "Conn.h" #include "Globals.h" #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <iostream> using namespace std; //get rid of this //Constructor TCPStream * Conn::Connect(const char* str, int p, struct sockaddr_in * serv_addr, int sockfd) { resolveHostName(str, serv_addr, p, sockfd); return new TCPStream(sockfd, serv_addr); } void Conn::resolveHostName(const char* hostname, struct sockaddr_in * serv_addr, int p, int sockfd) { int portno = p, err = -1; struct hostent *hp = NULL; if ((hp = gethostbyname(hostname)) == NULL) { //error("Couldn't get an address.\n"); std::cout << "Couldn't get an address.Trying again please check connection ..\n"; } while (hp == NULL) { hp = gethostbyname(hostname); } ::memcpy((char*) &serv_addr->sin_addr.s_addr, (char*) hp->h_addr_list[0], hp->h_length); serv_addr->sin_port = htons(portno); serv_addr->sin_family = AF_INET; //while (err < 0) { //try until connection if ((err = ::connect(sockfd, (struct sockaddr *) serv_addr, sizeof (struct sockaddr))) < 0) { //error("ERROR connecting"); std::cout << "ERROR connecting.. " << err << "\n"; } std::cout<<"Connection established.\n"; } Conn::~Conn() { }
aeb3ce49f65c686fb5ade22d9d1d9ceea1b6b618
9eb162946527920b784245135887dad8854c6ac3
/WAM-C++-Codes/Sliding-Mode-Controller/dummy_system.hpp
316ac00d8b98e6a309e61ca839f1a59285098d1e
[]
no_license
wlwsjl/Model-based-control-of-4-DOF-Barrett-Wam
1b0317f980ca4d8c5ab36d082aa5126bbc2d8db9
ee9c9c401b5ca8bf62229e4f7b35ac93feb64db6
refs/heads/master
2020-05-27T09:06:27.447741
2015-07-02T04:54:14
2015-07-02T04:54:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,216
hpp
dummy_system.hpp
/* * dummy_system.hpp * * Created on: 06-Feb-2015 * Author: nilxwam */ #ifndef DUMMY_SYSTEM_HPP_ #define DUMMY_SYSTEM_HPP_ #include <iostream> #include <string> #include <barrett/units.h> #include <barrett/systems.h> #include <barrett/products/product_manager.h> #include <barrett/detail/stl_utils.h> #include <barrett/log.h> #include <barrett/standard_main_function.h> using namespace barrett; template<size_t DOF> class Dummy: public System { BARRETT_UNITS_TEMPLATE_TYPEDEFS(DOF); public: Input<jt_type> ControllerInput; Input<jt_type> CompensatorInput; public: Output<jt_type> Total_torque; protected: typename Output<jt_type>::Value* Total_torqueOutputValue; public: Dummy(const std::string& sysName = "Dummy") : System(sysName), ControllerInput(this), CompensatorInput(this),Total_torque(this, &Total_torqueOutputValue) { } virtual ~Dummy() { this->mandatoryCleanUp(); } protected: jt_type ipT1, ipT2 ,TipT; virtual void operate() { ipT1 = this->ControllerInput.getValue(); ipT2 = this->CompensatorInput.getValue(); TipT = ipT1 + ipT2; this->Total_torqueOutputValue->setData(&TipT); } private: DISALLOW_COPY_AND_ASSIGN(Dummy); }; #endif /* DUMMY_SYSTEM_HPP_ */
fe767f58ec011d50b95bde66efb82d52083cd443
e27657ce045037d7f3556ad1e804b7b2e795b657
/FactorItpp.Specs/GivenKeyedContainer.cpp
dda75b4de5c6c7d3ae4a3ff1c5336984008bcc12
[ "MIT" ]
permissive
FurryBuilder/FactorItpp
8b369d15acf227b12bfd1ae5c3cff25c32960fd1
87ac4d00b47016b8bad7d4ee90c8fbd813a78614
refs/heads/master
2021-01-15T23:02:09.583182
2015-03-16T02:23:51
2015-03-16T02:23:51
19,823,811
2
0
null
null
null
null
UTF-8
C++
false
false
3,973
cpp
GivenKeyedContainer.cpp
#include <bandit/bandit.h> #include "Container.h" #include "Stubs.h" using namespace bandit; using namespace FurryBuilder::FactorIt; go_bandit([]() { describe("a FactorIt++ container with one registered service using an exteneded key", []() { std::shared_ptr<Contracts::IContainer> _container = Container::CreateRoot(); _container ->Bind<Stubs::IStubService>("test") ->To<Stubs::StubService>(); it("can check for resolving existing services", [=]() { AssertThat(_container->CanResolve<Stubs::IStubService>("test"), Equals(true)); }); it("can check for resolving non-existing services", [=]() { AssertThat(_container->CanResolve<Stubs::IStubService>(), Equals(false)); AssertThat(_container->CanResolve<Contracts::IServiceLocator>("test"), Equals(false)); }); it("can resolve existing services", [=]() { auto s = _container->Resolve<Stubs::IStubService>("test"); AssertThat((bool)s, Equals(true)); }); it("cannot resolve non-existing services", [=]() { AssertThrows(std::runtime_error, _container->Resolve<Stubs::IStubService>()); }); it("can resolve existing services twice to the same instance", [=]() { auto s1 = _container->Resolve<Stubs::IStubService>("test"); auto s2 = _container->Resolve<Stubs::IStubService>("test"); AssertThat(s1.get(), Equals(s2.get())); }); it("can resolve non-existing services through default value", [=]() { auto s = _container->ResolveOrDefault<Stubs::IStubService>("test", []() { return std::make_shared<Stubs::StubService>(); }); AssertThat((bool)s, Equals(true)); }); it("will execute postponed actions on already registered service instantly", [&]() { bool sentinel = false; _container->Postpone<Stubs::IStubService>("test", [&sentinel](Contracts::ContractStrong<Stubs::IStubService>::type c) { sentinel = true; }); AssertThat(sentinel, Equals(true)); }); it("can postpone actions more than once on an already registered service", [&]() { bool sentinelA = false; bool sentinelB = false; _container->Postpone<Stubs::IStubService>("test", [&sentinelA](Contracts::ContractStrong<Stubs::IStubService>::type c) { sentinelA = true; }); _container->Postpone<Stubs::IStubService>("test", [&sentinelB](Contracts::ContractStrong<Stubs::IStubService>::type c) { sentinelB = true; }); AssertThat(sentinelA, Equals(true)); AssertThat(sentinelB, Equals(true)); }); it("will execute postponed actions on following services as they are registered", [&]() { std::shared_ptr<Contracts::IContainer> container = Container::CreateRoot(); container ->Bind<Stubs::IStubService>() ->To<Stubs::StubService>(); bool sentinel = false; container->Postpone<Stubs::ILateStubService>("test", [&sentinel](Contracts::ContractStrong<Stubs::ILateStubService>::type c) { sentinel = true; }); AssertThat(sentinel, Equals(false)); container ->Bind<Stubs::ILateStubService>("test") ->To<Stubs::LateStubService>(); AssertThat(sentinel, Equals(true)); }); it("can postpone actions more than once on an upcoming service", [&]() { std::shared_ptr<Contracts::IContainer> container = Container::CreateRoot(); container ->Bind<Stubs::IStubService>() ->To<Stubs::StubService>(); bool sentinelA = false; bool sentinelB = false; container->Postpone<Stubs::ILateStubService>("test", [&sentinelA](Contracts::ContractStrong<Stubs::ILateStubService>::type c) { sentinelA = true; }); container->Postpone<Stubs::ILateStubService>("test", [&sentinelB](Contracts::ContractStrong<Stubs::ILateStubService>::type c) { sentinelB = true; }); AssertThat(sentinelA, Equals(false)); AssertThat(sentinelB, Equals(false)); container ->Bind<Stubs::ILateStubService>("test") ->To<Stubs::LateStubService>(); AssertThat(sentinelA, Equals(true)); AssertThat(sentinelB, Equals(true)); }); }); });
b19739f68b091c656cfcf1ed201eb8642adb66d7
81b117c0df564b3d36fdfd6004e68a1e540e948f
/moses/parameters/ContextParameters.h
aff7783e4941bb9391c427499cdfa6dbf0377fc5
[]
no_license
kevinduh/mosesdecoder
6aa2f449173f6a6e7e1e48c42d90323174c24a55
490755459ff73d7c8e6e9bf07dcc069878ae218e
refs/heads/master
2021-01-18T12:31:14.212515
2015-08-11T18:34:29
2015-08-11T18:34:29
39,024,965
1
0
null
2015-07-13T16:50:37
2015-07-13T16:50:37
null
UTF-8
C++
false
false
482
h
ContextParameters.h
// -*- c++ -*- #pragma once #include <string> #include "moses/Parameter.h" #include "moses/TypeDef.h" #include "moses/Util.h" namespace Moses { class ContextParameters { public: ContextParameters(); void init(Parameter& params); size_t look_ahead; // # of words to look ahead for context-sensitive decoding size_t look_back; // # of works to look back for context-sensitive decoding std::string context_string; // fixed context string specified on command line }; }
4ee80bb7635963109d44ef81da23770e36ea6c7f
ea401c3e792a50364fe11f7cea0f35f99e8f4bde
/hackathon/PengXie/NeuronStructNavigator/cmake-3.6.2/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp
1c969cd2fc1bd743db51501c6fed914bc34438c9
[ "MIT", "BSD-3-Clause" ]
permissive
Vaa3D/vaa3d_tools
edb696aa3b9b59acaf83d6d27c6ae0a14bf75fe9
e6974d5223ae70474efaa85e1253f5df1814fae8
refs/heads/master
2023-08-03T06:12:01.013752
2023-08-02T07:26:01
2023-08-02T07:26:01
50,527,925
107
86
MIT
2023-05-22T23:43:48
2016-01-27T18:19:17
C++
UTF-8
C++
false
false
6,219
cpp
CubeRenderer.cpp
#include "pch.h" #include "CubeRenderer.h" using namespace DirectX; using namespace Microsoft::WRL; using namespace Windows::Foundation; using namespace Windows::UI::Core; CubeRenderer::CubeRenderer() : m_loadingComplete(false) , m_indexCount(0) { } void CubeRenderer::CreateDeviceResources() { Direct3DBase::CreateDeviceResources(); auto loadVSTask = DX::ReadDataAsync("SimpleVertexShader.cso"); auto loadPSTask = DX::ReadDataAsync("SimplePixelShader.cso"); auto createVSTask = loadVSTask.then([this](Platform::Array<byte> ^ fileData) { DX::ThrowIfFailed(m_d3dDevice->CreateVertexShader( fileData->Data, fileData->Length, nullptr, &m_vertexShader)); const D3D11_INPUT_ELEMENT_DESC vertexDesc[] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "COLOR", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, }; DX::ThrowIfFailed(m_d3dDevice->CreateInputLayout( vertexDesc, ARRAYSIZE(vertexDesc), fileData->Data, fileData->Length, &m_inputLayout)); }); auto createPSTask = loadPSTask.then([this](Platform::Array<byte> ^ fileData) { DX::ThrowIfFailed(m_d3dDevice->CreatePixelShader( fileData->Data, fileData->Length, nullptr, &m_pixelShader)); CD3D11_BUFFER_DESC constantBufferDesc( sizeof(ModelViewProjectionConstantBuffer), D3D11_BIND_CONSTANT_BUFFER); DX::ThrowIfFailed(m_d3dDevice->CreateBuffer(&constantBufferDesc, nullptr, &m_constantBuffer)); }); auto createCubeTask = (createPSTask && createVSTask).then([this]() { VertexPositionColor cubeVertices[] = { { XMFLOAT3(-0.5f, -0.5f, -0.5f), XMFLOAT3(0.0f, 0.0f, 0.0f) }, { XMFLOAT3(-0.5f, -0.5f, 0.5f), XMFLOAT3(0.0f, 0.0f, 1.0f) }, { XMFLOAT3(-0.5f, 0.5f, -0.5f), XMFLOAT3(0.0f, 1.0f, 0.0f) }, { XMFLOAT3(-0.5f, 0.5f, 0.5f), XMFLOAT3(0.0f, 1.0f, 1.0f) }, { XMFLOAT3(0.5f, -0.5f, -0.5f), XMFLOAT3(1.0f, 0.0f, 0.0f) }, { XMFLOAT3(0.5f, -0.5f, 0.5f), XMFLOAT3(1.0f, 0.0f, 1.0f) }, { XMFLOAT3(0.5f, 0.5f, -0.5f), XMFLOAT3(1.0f, 1.0f, 0.0f) }, { XMFLOAT3(0.5f, 0.5f, 0.5f), XMFLOAT3(1.0f, 1.0f, 1.0f) }, }; D3D11_SUBRESOURCE_DATA vertexBufferData = { 0 }; vertexBufferData.pSysMem = cubeVertices; vertexBufferData.SysMemPitch = 0; vertexBufferData.SysMemSlicePitch = 0; CD3D11_BUFFER_DESC vertexBufferDesc(sizeof(cubeVertices), D3D11_BIND_VERTEX_BUFFER); DX::ThrowIfFailed(m_d3dDevice->CreateBuffer( &vertexBufferDesc, &vertexBufferData, &m_vertexBuffer)); unsigned short cubeIndices[] = { 0, 2, 1, // -x 1, 2, 3, 4, 5, 6, // +x 5, 7, 6, 0, 1, 5, // -y 0, 5, 4, 2, 6, 7, // +y 2, 7, 3, 0, 4, 6, // -z 0, 6, 2, 1, 3, 7, // +z 1, 7, 5, }; m_indexCount = ARRAYSIZE(cubeIndices); D3D11_SUBRESOURCE_DATA indexBufferData = { 0 }; indexBufferData.pSysMem = cubeIndices; indexBufferData.SysMemPitch = 0; indexBufferData.SysMemSlicePitch = 0; CD3D11_BUFFER_DESC indexBufferDesc(sizeof(cubeIndices), D3D11_BIND_INDEX_BUFFER); DX::ThrowIfFailed(m_d3dDevice->CreateBuffer( &indexBufferDesc, &indexBufferData, &m_indexBuffer)); }); createCubeTask.then([this]() { m_loadingComplete = true; }); } void CubeRenderer::CreateWindowSizeDependentResources() { Direct3DBase::CreateWindowSizeDependentResources(); float aspectRatio = m_windowBounds.Width / m_windowBounds.Height; float fovAngleY = 70.0f * XM_PI / 180.0f; if (aspectRatio < 1.0f) { fovAngleY /= aspectRatio; } // Note that the m_orientationTransform3D matrix is post-multiplied here // in order to correctly orient the scene to match the display orientation. // This post-multiplication step is required for any draw calls that are // made to the swap chain render target. For draw calls to other targets, // this transform should not be applied. XMStoreFloat4x4( &m_constantBufferData.projection, XMMatrixTranspose(XMMatrixMultiply( XMMatrixPerspectiveFovRH(fovAngleY, aspectRatio, 0.01f, 100.0f), XMLoadFloat4x4(&m_orientationTransform3D)))); } void CubeRenderer::Update(float timeTotal, float timeDelta) { (void)timeDelta; // Unused parameter. XMVECTOR eye = XMVectorSet(0.0f, 0.7f, 1.5f, 0.0f); XMVECTOR at = XMVectorSet(0.0f, -0.1f, 0.0f, 0.0f); XMVECTOR up = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f); XMStoreFloat4x4(&m_constantBufferData.view, XMMatrixTranspose(XMMatrixLookAtRH(eye, at, up))); XMStoreFloat4x4(&m_constantBufferData.model, XMMatrixTranspose(XMMatrixRotationY(timeTotal * XM_PIDIV4))); } void CubeRenderer::Render() { const float midnightBlue[] = { 0.098f, 0.098f, 0.439f, 1.000f }; m_d3dContext->ClearRenderTargetView(m_renderTargetView.Get(), midnightBlue); m_d3dContext->ClearDepthStencilView(m_depthStencilView.Get(), D3D11_CLEAR_DEPTH, 1.0f, 0); // Only draw the cube once it is loaded (loading is asynchronous). if (!m_loadingComplete) { return; } m_d3dContext->OMSetRenderTargets(1, m_renderTargetView.GetAddressOf(), m_depthStencilView.Get()); m_d3dContext->UpdateSubresource(m_constantBuffer.Get(), 0, NULL, &m_constantBufferData, 0, 0); UINT stride = sizeof(VertexPositionColor); UINT offset = 0; m_d3dContext->IASetVertexBuffers(0, 1, m_vertexBuffer.GetAddressOf(), &stride, &offset); m_d3dContext->IASetIndexBuffer(m_indexBuffer.Get(), DXGI_FORMAT_R16_UINT, 0); m_d3dContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); m_d3dContext->IASetInputLayout(m_inputLayout.Get()); m_d3dContext->VSSetShader(m_vertexShader.Get(), nullptr, 0); m_d3dContext->VSSetConstantBuffers(0, 1, m_constantBuffer.GetAddressOf()); m_d3dContext->PSSetShader(m_pixelShader.Get(), nullptr, 0); m_d3dContext->DrawIndexed(m_indexCount, 0, 0); }
00c1469d60a63cf0adb41008ec2d920fa51da771
3722de54dbee0fbfbc59a8f0e77b49cb66b3f4f1
/LowerMastOperation.h
665f947ae1b9b3adb848b9f4834fac2d3b4ad27a
[]
no_license
jiangtaojiang/ForkliftSimulation
e9d1a93ecd54c4d7619f0f06f2e98db363ec1072
c97814692e200e68f6d8888b09dfa34ac3c09834
refs/heads/master
2022-10-19T22:26:16.784408
2020-06-15T06:48:25
2020-06-15T06:48:25
null
0
0
null
null
null
null
UTF-8
C++
false
false
387
h
LowerMastOperation.h
#pragma once #include "Operation.h" class LowerMastOperation : public Operation { private: const float LOWERING_STEP = 0.02f; const float MIN_MAST_HEIGHT = -4.5f; const float MIN_FORKS_HEIGHT = -4.5f; public: LowerMastOperation() = default; bool is_finished(Forklift* forklift) override; void do_single_action_step(Forklift* forklift) override; void modify_matrix() override; };
824af410ec41fb3f88dbb120d26dc55f33f8e690
029110f650d0376aed050dd3fc760b89b96cb779
/cpp/837/dialog_setvalue.cpp
a9d3c5278c8e71a6239c2d6aae9362e12f3a79f5
[]
no_license
huayunfly/goiot
a03f24618f4fe9455c02847c3734233b9a955b6e
e2094dfd2b74231fd4d244553e8f1dbdda39505d
refs/heads/master
2023-08-31T07:58:07.179832
2023-08-29T08:41:21
2023-08-29T08:41:21
79,292,620
0
0
null
2021-12-26T16:11:49
2017-01-18T01:54:52
C++
UTF-8
C++
false
false
2,765
cpp
dialog_setvalue.cpp
#include <QRegExpValidator> #include <qevent.h> #include "dialog_setvalue.h" #include "ui_dialog_setvalue.h" DialogSetValue::DialogSetValue(QWidget *parent, const QString& current, MeasurementUnit unit, int high_limit, int low_limit) : QDialog(parent), ui(new Ui::DialogSetValue), new_value_(0.0), high_limit_(high_limit), low_limit_(low_limit) { ui->setupUi(this); Qt::WindowFlags flags= this->windowFlags(); this->setWindowFlags(flags&~Qt::WindowContextHelpButtonHint); // get controls auto text_current_sv = this->findChild<QTextEdit*>("textEditCurrentSV"); assert(text_current_sv != nullptr); auto text_sv = this->findChild<QLineEdit*>("lineEditSV"); assert(text_sv != nullptr); auto text_unit = this->findChild<QTextEdit*>("textEditUnit"); assert(text_unit != nullptr); // set properties text_current_sv->setStyleSheet("background-color:lightyellow"); QRegExp float_regex("100|([0-9]{0,4}[\\.][0-9]{1})"); text_sv->setValidator(new QRegExpValidator(float_regex, this)); text_sv->setFocus(); text_unit->setStyleSheet("background:transparent;border-width:0;border-style:outset"); // set values bool is_numeric = false; current.toFloat(&is_numeric); if (is_numeric) { text_current_sv->setText(current); text_sv->setText(current); } switch (unit) { case MeasurementUnit::BARA: text_unit->setText("bara"); break; case MeasurementUnit::BARG: text_unit->setText("barg"); break; case MeasurementUnit::SCCM: text_unit->setText("sccm"); break; case MeasurementUnit::DEGREE: text_unit->setText(u8"°C"); break; case MeasurementUnit::MLM: text_unit->setText("mlm"); break; case MeasurementUnit::MM: text_unit->setText("mm"); break; case MeasurementUnit::MPA: text_unit->setText("mpa"); break; case MeasurementUnit::ML: text_unit->setText("ml"); break; default: text_unit->setText("-"); break; } } DialogSetValue::~DialogSetValue() { delete ui; } void DialogSetValue::keyPressEvent(QKeyEvent* e) { assert(e != nullptr); if( e->key() == Qt::Key_Return) { this->accept(); } else if (e->key() == Qt::Key_Escape) { this->reject(); } else { QDialog::keyPressEvent(e); } } void DialogSetValue::on_lineEditSV_textChanged(const QString &arg1) { bool is_numeric = false; float f = arg1.toFloat(&is_numeric); if (is_numeric) { if (f <= high_limit_ && f >= low_limit_) // Check value range { new_value_ = f; } } }
100bf8c3495dbf5b08d8aab5eb1929ef24e566d4
04462e43a083ef37c1e126c40fdf1d38ca81f586
/FlexEngine/include/Cameras/DebugCamera.hpp
3b142c63bfee7e64ee99f1a8761bf08292b86ed3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
ajweeks/FlexEngine
adb5aa135b3541e6f8189b88cf432896505d1118
fe7d4b165de8260dd9d6be4d20be7c2f9ba1ffe5
refs/heads/master
2023-08-31T14:04:17.224754
2023-08-28T23:41:27
2023-08-29T17:37:55
82,951,590
969
56
MIT
2021-05-18T18:35:27
2017-02-23T17:14:25
C++
UTF-8
C++
false
false
1,178
hpp
DebugCamera.hpp
#pragma once #include "BaseCamera.hpp" #include "Callbacks/InputCallbacks.hpp" #include "Histogram.hpp" namespace flex { class DebugCamera final : public BaseCamera { public: explicit DebugCamera(real FOV = glm::radians(45.0f)); virtual ~DebugCamera(); virtual void Initialize() override; virtual void Update() override; virtual void Destroy() override; virtual void DrawImGuiObjects() override; private: EventReply OnMouseButtonEvent(MouseButton button, KeyAction action); MouseButtonCallback<DebugCamera> mouseButtonCallback; EventReply OnMouseMovedEvent(const glm::vec2& dMousePos); MouseMovedCallback<DebugCamera> mouseMovedCallback; real m_RollOnTurnAmount; glm::vec2 m_MouseDragDist; bool m_bDraggingLMB = false; bool m_bDraggingMMB = false; bool m_bOrbiting = false; glm::vec3 m_DragStartPosition; // [0, 1) 0 = no lag, higher values give smoother movement real m_MoveLag = 0.5f; // TODO: Remove turn lag entirely? real m_TurnLag = 0.1f; glm::vec3 m_MoveVel; glm::vec2 m_TurnVel; // Contains amount pitch and yaw changed last frame glm::vec3 m_OrbitCenter; Histogram m_DragHistory; }; } // namespace flex
f737b6db07598475f3cbd897e4cb7938e0af3fc8
d87661218848d981de80d48d7142b95a29b63b4c
/newton-interpolation/main.cpp
53447987749894b1dd5c050d44a19adf739e3b31
[ "MIT" ]
permissive
IonicaBizau/C-plus-plus-Exercises
c691bbc99bcd0323b25e1744a042c7902e86c425
89f21315b604cb121e9b5d4a58f87b2b46152c86
refs/heads/master
2020-12-24T16:07:14.731218
2020-08-09T10:24:08
2020-08-09T10:24:08
9,621,132
3
1
MIT
2020-08-09T10:24:22
2013-04-23T10:59:51
C++
UTF-8
C++
false
false
787
cpp
main.cpp
#include<iostream> using namespace std; int main() { int n = 0; float x[10] , y[10] , a , sum = 0 , mult ; cout << "n = "; cin >> n; for(int i = 0; i <= n; ++i) { cout << "x[" << i << "] = "; cin >> x[i]; cout << "y[" << i << "] = "; cin >> y[i]; } cout << "a = "; cin >> a; for(int j = 0; j < n - 1; ++j) { for(int i = n - 1; i > j; --i) { y[i] = (y[i] - y[i - 1]) / (x[i] - x[i - j - 1]); } } int ii = 0; for(int i= n - 1; i >= 0; --i) { mult = 1; for(ii = 0; ii < i; ++ii) { mult *= (a - x[ii]); } mult *= y[ii]; sum += mult; } cout << "Sum: " << sum; return 0; }
a40ed4b0591baceb4264e5bb491acb16ca28a901
c7d454d97347cb99d82ad05dbacc3c60ea3dbc63
/cs375/assignments/ward_austin1/lenLCS.cpp
125322180704477c7f67498e049b7acfa268c16e
[]
no_license
award28/Binghamton_Course_Work
4854b774311956e8d29535838df4b8ee637afde0
a3a7448fcd7425394762a9fd866b1a18e545fecf
refs/heads/master
2020-03-21T11:47:23.227763
2018-06-25T02:31:48
2018-06-25T02:31:48
138,521,691
0
0
null
null
null
null
UTF-8
C++
false
false
1,792
cpp
lenLCS.cpp
#include <string> #include <ctime> #include "lcs.hpp" using namespace std; void LenLCS::execute(const string &x, const string &y, const string &outfile) { int lenx = x.length(); int leny = y.length(); int c[lenx + 1][leny + 1]; char b[lenx + 1][leny + 1]; string subseq = ""; ofstream fout(outfile); clock_t begin = clock(); c[0][0] = 0; for(int i = 1; i < lenx + 1; i++) { c[i][0] = 0; b[i][0] = 'X'; } for(int i = 0; i < leny + 1; i++) { c[0][i] = 0; b[0][i] = 'X'; } for(int i = 0; i < lenx; i++) { for(int j = 0; j < leny; j++) { if(x[i] == y[j]) { c[i+ 1][j + 1] = c[i][j] + 1; b[i + 1][j + 1] = 'T'; } else if(c[i][j + 1] >= c[i+ 1][j]) { c[i + 1][j + 1] = c[i][j + 1]; b[i + 1][j + 1] = '^'; } else { c[i + 1][j + 1] = c[i + 1][j]; b[i + 1][j + 1] = '<'; } } } clock_t end = clock(); double time = double(end - begin) / CLOCKS_PER_SEC; if(lenx < 11 && leny < 11) { for(int i = 0; i < lenx + 1; i++) { for(int j = 0; j < leny + 1; j++) { fout << c[i][j] << " "; } fout << endl; } while(b[lenx][leny] != 'X') { if(b[lenx][leny] == 'T') { subseq = x[lenx - 1] + subseq; lenx--; leny--; } else if(b[lenx][leny] == '<') leny--; else lenx--; } fout << subseq << endl;; } else fout << c[lenx][leny] << endl; fout << time << " seconds"; fout.close(); }
42cb8459df70e10fa51427cbdae85464e32bf0b0
6cb6851ee4826ff183b641e5bf000265f4c926f4
/njust_homework/Visualcpp_1/实验7/S7_4.cpp
1dabeb99fe6b5dfbc73ea72c996e1650a8aeefe2
[ "ICU" ]
permissive
lerogo/shareCode
900098c88dce00a1cc6e17131265d3123343e986
3538bf25c4fcf469e66141ff897d66c6ee9b30e9
refs/heads/main
2023-08-28T23:35:08.725508
2022-01-05T00:12:02
2022-01-05T00:12:02
209,968,283
22
14
null
2023-08-14T22:32:51
2019-09-21T10:46:30
C
GB18030
C++
false
false
388
cpp
S7_4.cpp
#include<iostream> using namespace std; int main(){ int fun(int n); int n,mul; cout<<"输入整数(输入0结束)"<<endl; cin>>n; while(n){ mul=fun(n); cout<<n<<"的各个位数积为:"<<mul<<endl; cout<<"输入整数(输入0结束)"<<endl; cin>>n; } return 0; } int fun(int n){ int sum=1; while(n){ sum*=n%10; n/=10; } return sum; }
26021592e958c6826ad9e905b0d49816b07cc48a
083f92a70099b96de7e22a0995c3cd1ada599119
/ui/ChipModuleControl.h
88196260bb7fcacdda3b083002b615ceae63cf3b
[]
no_license
dnhushak/chipophone
8c75f2d49366d09458c75ad2bfc6bf6ebdd9bdb9
0c74ece50d44bc547dea153dfea0216daa399228
refs/heads/master
2021-01-20T02:16:59.226743
2014-05-03T21:10:39
2014-05-03T21:10:39
9,348,580
0
0
null
null
null
null
UTF-8
C++
false
false
2,603
h
ChipModuleControl.h
#ifndef CHIPMODULECONTROL_H_ #define CHIPMODULECONTROL_H_ #include "Button.h" #include "Encoder.h" #include "MIDIUtils.h" #include "LED.h" #include "RGBLED.h" #include "ArduinoMIDIHandler.h" #include "ChipScreenControl.h" namespace chip { typedef struct ModuleControlPins { // Module Selector Buttons int redButtonPin; int yelButtonPin; int grnButtonPin; int bluButtonPin; int whtButtonPin; // Module Selector LEDs int redLEDPin; int yelLEDPin; int grnLEDPin; int bluLEDPin; int whtLEDPin; // Arpeggiator button, encoder and LEDs int arpButtonPin; int arpRedLEDPin; int arpGrnLEDPin; int arpBluLEDPin; int arpEncoderPinA; int arpEncoderPinB; // Glissando button, encoder and LEDs int glissButtonPin; int glissRedLEDPin; int glissGrnLEDPin; int glissBluLEDPin; int glissEncoderPinA; int glissEncoderPinB; // Volume encoder int volEncoderPinA; int volEncoderPinB; } ModuleControlPins; enum moduleState { RED, YEL, GRN, BLU, WHT }; class ChipModuleControl { public: ChipModuleControl(ModuleControlPins* pinout, synth::ArduinoMIDIHandler * initAMHandler, chip::ChipScreenControl * initScreenController); virtual ~ChipModuleControl(); void begin(); void poll(); int getCurrentModule(); private: enum paramState { OFF, ON }; enum ChipCCNums { ARPTOGGLE = 66, GLISSTOGGLE = 65, GLISSTIME = 5, VOLUME = 7, ARPTIME = 12 }; void updateLED(); void calcArpTime(); void calcGlissTime(); // Module Selection ArduinoUI::Button * redButton; ArduinoUI::Button * yelButton; ArduinoUI::Button * grnButton; ArduinoUI::Button * bluButton; ArduinoUI::Button * whtButton; ArduinoUI::LED * redLED; ArduinoUI::LED * yelLED; ArduinoUI::LED * grnLED; ArduinoUI::LED * bluLED; ArduinoUI::LED * whtLED; // Arpeggio ArduinoUI::Button * arpButton; ArduinoUI::RGBLED * arpLED; ArduinoUI::Encoder * arpEncoder; // Glissando ArduinoUI::Button * glissButton; ArduinoUI::RGBLED * glissLED; ArduinoUI::Encoder * glissEncoder; // Volume ArduinoUI::Encoder * volumeEncoder; //MIDI Handling synth::ArduinoMIDIHandler * AMHandler; synth::MIDIMessage * message; // Screen Handler ChipScreenControl * screenController; char buf[10]; // State tracking (lastLEDModule is used to keep track of LED updates) int currentModule, lastLEDModule; int arpState[5]; int glissState[5]; int arpTime[5]; int glissTime[5]; int volume[5]; } ; } #endif /* CHIPMODULECONTROL_H_ */
b7e4b32f39002ccee90d299d538cc726de80fa81
1d6788f3ff60142b273ce690291efa97cca81e38
/QtPluginManagerTest/pluginmanager/plugins/logplugin/logplugin.h
e261dd7fb95020e1bc722d168999e6097a8a276d
[]
no_license
keiler2018/QtPluginManagerTest
f013b62a94a7433de2c84ab234dd2314ee4a1d88
e0a8abf2aeed50bec521615a9d84244c67faa473
refs/heads/master
2020-05-21T06:26:50.004259
2019-05-10T08:03:46
2019-05-10T08:03:46
185,945,027
7
6
null
null
null
null
UTF-8
C++
false
false
406
h
logplugin.h
#ifndef LOGPLUGIN_H #define LOGPLUGIN_H #include <loginterface.h> class LogPlugin : public QObject,public LogInterface { Q_OBJECT #if QT_VERSION >= 0x050000 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.LogPlugin" FILE "logplugin.json") #endif // QT_VERSION >= 0x050000 Q_INTERFACES(PluginInterface) public: LogPlugin(QObject *parent = 0); void log(QString); }; #endif // LOGPLUGIN_H
03adef21a35736c901ec0838a63076d21068fce5
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
/lib/libcxx/src/support/runtime/new_handler_fallback.ipp
2ec408327d64d4668f260aca013b3de641293288
[ "MIT", "NCSA", "LLVM-exception", "Apache-2.0" ]
permissive
ziglang/zig
4aa75d8d3bcc9e39bf61d265fd84b7f005623fc5
f4c9e19bc3213c2bc7e03d7b06d7129882f39f6c
refs/heads/master
2023-08-31T13:16:45.980913
2023-08-31T05:50:29
2023-08-31T05:50:29
40,276,274
25,560
2,399
MIT
2023-09-14T21:09:50
2015-08-06T00:51:28
Zig
UTF-8
C++
false
false
699
ipp
new_handler_fallback.ipp
// -*- C++ -*- //===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// namespace std { static constinit std::new_handler __new_handler = nullptr; new_handler set_new_handler(new_handler handler) noexcept { return __libcpp_atomic_exchange(&__new_handler, handler); } new_handler get_new_handler() noexcept { return __libcpp_atomic_load(&__new_handler); } } // namespace std
21888947685f73dcdcefaed0cec41ad13cbfe539
10fc504ae17abb5532bdc501092cefe07ee37c4e
/GaussSeidel/main.cpp
b390274c23d0877e949def930ec9cdd31c9aa286
[]
no_license
Gravity-I-Pull-You-Down/Numerical_Methords
4dfd629e4e66475f2ac33e11e7543f3d29a0a0ce
9a40f4871167deee4a774563bdb7532407f952e3
refs/heads/master
2022-07-31T10:33:26.177061
2020-05-25T11:57:21
2020-05-25T11:57:21
266,569,260
0
0
null
null
null
null
UTF-8
C++
false
false
815
cpp
main.cpp
#include <iostream> #include <vector> using namespace std; int main() { vector<vector<double>> Base = {{20, 1, -2}, {3, 20, -1}, {2, -3, 20}}; vector<double> Resultant = {17, -18, 25}, m = {0, 0, 0}, n = {0,0,0}; int iterations = 100; while (iterations > 0) { for (int i = 0; i < 3; i++) { n[i] = (Resultant[i] / Base[i][i]); for (int j = 0; j < 3; j++) { if (j == i) continue; n[i] = n[i] - ((Base[i][j] / Base[i][i]) * m[j]); m[i] = n[i]; } } iterations--; } for (int k = 0; k < 3; ++k) { cout << "x" << k + 1 << "=" << n[k] << " "; cout << "\n"; } return 0; }
ef00b1047253cb09f0df244eafc7cf0892ee99d8
196f7a76d086145ee5343834e4d1b4a4264b4be1
/code/SegmentAndRender/dynamicsegment.h
4470b017dbedbb0eefb5fe089430699e6478015f
[]
no_license
lizhaodong/DynamicStereo
37466fd169aa77dce3aa95906c985419312e6afe
0abc24889d52ff825a1d7688cf07eb41cec94a7f
refs/heads/master
2020-07-27T23:55:07.391294
2016-11-20T23:08:36
2016-11-20T23:08:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,038
h
dynamicsegment.h
// // Created by yanhang on 4/10/16. // #ifndef DYNAMICSTEREO_DYNAMICSEGMENT_H #define DYNAMICSTEREO_DYNAMICSEGMENT_H #include <iostream> #include <string> #include <memory> #include <opencv2/opencv.hpp> #include <Eigen/Eigen> #include <glog/logging.h> #include "../base/file_io.h" #include "../base/depth.h" namespace dynamic_stereo { void computeFrequencyConfidence(const std::vector<cv::Mat>& input, const float threshold, Depth& result, cv::Mat& frq_range); void segmentFlashy(const FileIO& file_io, const int anchor, const std::vector<cv::Mat>& input, std::vector<std::vector<Eigen::Vector2i> >& segments_flashy, std::vector<Eigen::Vector2i>& ranges); void segmentDisplay(const FileIO& file_io, const int anchor, const std::vector<cv::Mat>& input, const std::string& classifierPath, const std::string& codebookPath, cv::Mat& result); void groupPixel(const cv::Mat& labels, std::vector<std::vector<Eigen::Vector2i> >& segments); }//namespace dynamic_stereo #endif //DYNAMICSTEREO_DYNAMICSEGMENT_H
e634f81c8d541bde47c3ec8860ded34e75999c3b
d0fb746f1be49b7c0de6b9b6c15d034329cd23dc
/Game Engine Esqueleto/EventList.h
5a2ad78eb49c7bc736adbadcb7b450aa0aaa7380
[]
no_license
EdgarSAE/Game-Engine-Esqueleto
23b471eacef9fd217af743c8acf1038c7dcb3e1f
501a8c1de748159b6630c5d13f57ac8b4c6a8be0
refs/heads/master
2021-01-11T03:35:28.088813
2016-09-23T06:24:28
2016-09-23T06:24:28
68,940,999
0
0
null
2016-09-23T06:24:29
2016-09-22T16:33:35
C++
UTF-8
C++
false
false
152
h
EventList.h
#pragma once #include <iostream> class EventList { public: int type; bool exit_ = false; EventList(int Itype); bool Callback(); bool Exit(); };
4a3abc25c71ee2a8cfe592c82272f78fe007dc27
d0e89f5016a0650918684cbb511d60cf0a36b0fd
/Example/Src/User.h
cc94cd8c624e361c72c7b52fa5e428ce7bb40cf5
[ "MIT" ]
permissive
apulverizer/Kinect-Recording
a5e9b3d157138a8b66273143838bf1fa4edd1d53
70a543daa469ef8c62909500062bf694bdab1495
refs/heads/master
2020-04-27T07:51:15.784319
2017-12-16T15:33:35
2017-12-16T15:33:35
19,957,839
2
1
null
null
null
null
UTF-8
C++
false
false
1,480
h
User.h
///////////////////////////////////////////////////////////////// // User.h // // This is a class which stores the joint positions of a user // and performs basic functions such as finding the angle, // direction, and any gestures being performed. // // Author: Aaron Pulver // Date: 5/18/14 /////////////////////////////////////////////////////////////// #ifndef USER_h #define USER_h #include <deque> #include <XnOpenNI.h> #include <cmath> #include "GlobalDefs.h" #include "../../Src/GestureRecognizer.h" class User { private: static const int QUEUE_SIZE = 60; static const int MIN_VARIANCE = 75; static const int THRESHOLD_SIZE = 30; GestureRecognizer gestureRecognizer; /* * The unique id of the user [1-15] */ int id; /** * A queue of positions */ std::deque<XnVector3D> torsoPositions; public: User(int id); User(const User& other); User(); ~User(); int getId() const; void setId(int id); void addPosition(XnVector3D torso, XnVector3D leftShoulder, XnVector3D rightShoulder, XnVector3D leftElbow, XnVector3D rightElbow, XnVector3D leftHand, XnVector3D rightHand , XnUInt64 newTime); XnVector3D getCurrentPosition(); XnFloat getCurrentAngle(); XnFloat getCurrentDirection(int framesBack); bool isInFrame(); Gesture getCurrentGesture(); XnFloat getCurrentDistance(); bool operator== (const User &other) const; bool operator!= (const User &other) const; User operator=(const User & rhs); }; #endif
158e450e6f3d0af39048deabd8b3f7b2b1a982f2
ba2d87e13eda7e4d28bcb02af47fab76aeb6b26a
/Fonction.h
0ba3990c580a0e2522b05693557c4fd2dfe1dc49
[]
no_license
Cocoltxed/Jeu-du-Pendu
2a0a5c827b84b67cd0df2d668c3f053b9ccc628b
c4641328ff77c1d3120f6de76a37abf368041dca
refs/heads/main
2023-03-31T03:56:04.850936
2021-04-14T00:03:35
2021-04-14T00:03:35
357,715,979
0
0
null
null
null
null
UTF-8
C++
false
false
403
h
Fonction.h
#pragma once #include <iostream> #include <string> #include <ctime> using namespace std; #ifndef FONCTION_H #define FONCTION_h char GetCaractere(); int GetNombreAleatoire(); string ChoisirMot(string dico[]); void InitEtoile(string& mot); bool TestCaractere(char lettre, string mot, string& motCache); bool TestGagne(string mot); void DessinePendu(int i); //string ChoisirMot(); #endif //!FONCTION_H
bb1980c8bc6ba79ad715679e10dbd70159b6ee09
f6672a809c5bbdf50f11fd498ada28286c9d7a74
/CPipeServer.h
d204d74b63c5aa2ae95d5b9c16fd92ccd8c9c5a7
[ "Unlicense" ]
permissive
clayne/CPipes
d72af1754322514c0f7d9dedf21c9215e99242a2
6eed75cc4c1c870faca79789b5defa4fc5d40840
refs/heads/main
2023-03-20T23:55:23.417115
2021-03-14T02:25:03
2021-03-14T02:25:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
509
h
CPipeServer.h
#pragma once #include <Windows.h> #include <iostream> #include <string> #include "CPipeCommon.h" // Single instance one-way inbound server class CPipeServer { HANDLE m_hPipe; BOOL read(); // Please override this function virtual void processPacket(); public: DWORD m_BytesRead; DWORD m_TotalBytesRead; BYTE* m_pBuffer; DWORD m_BufferSize; std::string m_pipeName; CPipeServer(LPCSTR pipeName, DWORD pipeSize); ~CPipeServer(); BOOL listen(); void serverLoop(); };
0e9dd4d18a26515d33c9e5864441ca90a3d12b98
fe1edb72f6d3828309dfcd8b452c53d0e9ee5ad9
/floor.cc
d281f2f76bd25ec480f9124c648fa74b25802fdd
[]
no_license
gc-archer/cc3k
3993326a1a708380a34b2a138245a059345aaff6
ed5687f91c1ee233bb5711e1269b19e1f4d3cf8c
refs/heads/master
2020-05-05T06:50:48.149804
2018-09-03T01:40:46
2018-09-03T01:40:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
17,133
cc
floor.cc
#include "floor.h" #include "display.h" #include "factory.h" #include "npc.h" #include "pc.h" #include "potion.h" #include "gold.h" #include "chamber.h" #include "tile.h" #include "basictile.h" #include "basicpotion.h" #include "tiledecorator.h" #include "passage.h" #include "stairs.h" #include "door.h" #include "wall.h" #include "none.h" #include "dungeon.h" #include "humanNPC.h" #include "dwarfNPC.h" #include "elfNPC.h" #include "orcNPC.h" #include "dragonNPC.h" #include "merchantNPC.h" #include "halflingNPC.h" #include "shadePC.h" #include "restorehealth.h" #include "poisonhealth.h" #include "boostatk.h" #include "woundatk.h" #include "boostdef.h" #include "wounddef.h" using namespace std; // constructor and destructors Floor::Floor(int position, Dungeon *dungeon) : dungeon{dungeon}, position{position}, numChambers{5}, d{make_shared<Display>()}, f{make_shared<Factory> (*d)}, maxPotion{10}, numPotion{0}, maxTreasure{10}, numTreasure{0}, maxEnemy{20}, numEnemy{0} { d->setFloor(this); d->setFloorNum(this); } Floor::~Floor() {} // accessors and mutators shared_ptr<Chamber> & Floor::getChamber(int index) { return chambers[index]; } shared_ptr<Tile> & Floor::getTile(int x, int y) { return tiles[x][y]; } shared_ptr<Stairs> & Floor::getStairs(int index) { return st; } shared_ptr<NPC> & Floor::getNPC(int index) { return enemies[index]; } shared_ptr<Potion> & Floor::getPotion(int index) { return potions[index]; } shared_ptr<Gold> & Floor::getGold(int index) { return treasure[index]; } shared_ptr<PC> & Floor::getPlayer() { return player; } int Floor::getPosition() { return position; } Display & Floor::getDisplay() const { return *d; } Factory & Floor::getFactory() const { return *f; } int Floor::getMaxPotion() { return maxPotion; } int Floor::getNumPotion() { return numPotion; } int Floor::getMaxTreasure() { return maxTreasure; } int Floor::getNumTreasure() { return numTreasure; } int Floor::getMaxEnemy() { return maxEnemy; } int Floor::getNumEnemy() { return numEnemy; } // all spawning functions void Floor::spawnPC(string race, PC *existing) { if (position == 1 && hasPlayer == false) { int whichChamber = f->randInt(5); chambers[whichChamber]->spawnPC(f.get(), race); chambers[whichChamber]->setHas_Player(true); //cout << "player successfully spawned" << endl; int number_tiles = chambers[whichChamber]->getNumTiles(); for (int i = 0; i < number_tiles; ++i) { if ((chambers[whichChamber]->getTile(i))->getPC() != nullptr) { player = (chambers[whichChamber]->getTile(i))->getPC(); (chambers[whichChamber]->getTile(i))->setOccupy(true); } } hasPlayer = true; } else if (position == 1 && hasPlayer == false) { int whichChamber = f->randInt(5); chambers[whichChamber]->spawnPC(f.get(), race); chambers[whichChamber]->setHas_Player(true); //cout << "player successfully spawned" << endl; int number_tiles = chambers[whichChamber]->getNumTiles(); for (int i = 0; i < number_tiles; ++i) { if ((chambers[whichChamber]->getTile(i))->getPC() != nullptr) { player = (chambers[whichChamber]->getTile(i))->getPC(); (chambers[whichChamber]->getTile(i))->setOccupy(true); } } hasPlayer = true; int baseAtk = player->getAtk(); int baseDef = player->getDef(); player->setStats(existing->getHP(), baseAtk, baseDef); player->addMoney(existing->getMoney()); } player->setDungeon(dungeon); } void Floor::spawnStairs() { int whichChamber = 0; while (true) { whichChamber = f->randInt(5); if (chambers[whichChamber]->getHas_Player() == true) continue; Info temp = (chambers[whichChamber]->getRandomTile(f.get())).getInfo(); int x = temp.x; int y = temp.y; tiles[x][y] = make_shared<Stairs> (make_shared<BasicTile> (x, y, *d)); d->update(*tiles[x][y], "Stairs"); hasStairs = true; break; } } void Floor::spawnEnemy() { int whichChamber = 0; while (numEnemy < maxEnemy) { whichChamber = f->randInt(5); //cout << "random number is " << whichChamber << endl; chambers[whichChamber]->spawnEnemy(f.get()); ++numEnemy; } } void Floor::spawnPotion() { int whichChamber = 0; while (numPotion < maxPotion) { whichChamber = f->randInt(5); chambers[whichChamber]->spawnPotion(f.get()); ++numPotion; } } void Floor::spawnTreasure() { int whichChamber = 0; while (numTreasure < maxTreasure) { whichChamber = f->randInt(5); chambers[whichChamber]->spawnGold(f.get()); ++numTreasure; } } // other methods void Floor::constructObject(int x, int y, char input) { //cout << input << endl; if (input == 'H') { //cout << "constructing 1" << endl; tiles[x][y]->addNPC(make_shared<HumanNPC> (x, y, tiles[x][y].get())); tiles[x][y]->setOccupy(true); player->attach(tiles[x][y]->getNPC()); ++numEnemy; } else if (input == 'W') { //cout << "constructing 2" << endl; tiles[x][y]->addNPC(make_shared<DwarfNPC> (x, y, tiles[x][y].get())); tiles[x][y]->setOccupy(true); player->attach(tiles[x][y]->getNPC()); ++numEnemy; } else if (input == 'E') { //cout << "constructing 3" << endl; tiles[x][y]->addNPC(make_shared<ElfNPC> (x, y, tiles[x][y].get())); tiles[x][y]->setOccupy(true); player->attach(tiles[x][y]->getNPC()); ++numEnemy; } else if (input == 'O') { //cout << "constructing 4" << endl; tiles[x][y]->addNPC(make_shared<OrcNPC> (x, y, tiles[x][y].get())); tiles[x][y]->setOccupy(true); player->attach(tiles[x][y]->getNPC()); ++numEnemy; } else if (input == 'M') { //cout << "constructing 5" << endl; tiles[x][y]->addNPC(make_shared<MerchantNPC> (x, y, tiles[x][y].get())); tiles[x][y]->setOccupy(true); //cout << "DONE" << endl; player->attach(tiles[x][y]->getNPC()); // player->attach(t.getNPC()); //cout << "DONE2" << endl; ++numEnemy; } else if (input == 'D') { //cout << "constructing 6" << endl; tiles[x][y]->addNPC(make_shared<DragonNPC> (x, y, tiles[x][y].get())); tiles[x][y]->setOccupy(true); player->attach(tiles[x][y]->getNPC()); ++numEnemy; } else if (input == 'L') { //cout << "constructing 7" << endl; tiles[x][y]->addNPC(make_shared<HalflingNPC> (x, y, tiles[x][y].get())); tiles[x][y]->setOccupy(true); player->attach(tiles[x][y]->getNPC()); ++numEnemy; } else if (input == 'P') { //cout << "constructing 8" << endl; //f->addPotion(getTile(x, y)); ++numPotion; } else if (input == '0') { //cout << "constructing 9" << endl; tiles[x][y]->addObject(make_shared<RestoreHealth> (make_shared<BasicPotion>(0,"Restore Health", true, x, y))); tiles[x][y]->setOccupy(true); ++numPotion; } else if (input == '1') { //cout << "constructing 10" << endl; tiles[x][y]->addObject(make_shared<BoostAtk> (make_shared<BasicPotion>(0,"Boost Attack", true, x, y))); tiles[x][y]->setOccupy(true); ++numPotion; } else if (input == '2') { //cout << "constructing 11" << endl; tiles[x][y]->addObject(make_shared<BoostDef> (make_shared<BasicPotion>(0,"Boost Defense", true, x, y))); tiles[x][y]->setOccupy(true); ++numPotion; } else if (input == '3') { //cout << "constructing 12" << endl; tiles[x][y]->addObject(make_shared<PoisonHealth> (make_shared<BasicPotion>(0,"Poison Health", true, x, y))); tiles[x][y]->setOccupy(true); ++numPotion; } else if (input == '4') { //cout << "constructing 13" << endl; tiles[x][y]->addObject(make_shared<WoundAtk> (make_shared<BasicPotion>(0,"Wound Attack", true, x, y))); tiles[x][y]->setOccupy(true); ++numPotion; } else if (input == '5') { //cout << "constructing 14" << endl; tiles[x][y]->addObject(make_shared<WoundDef> (make_shared<BasicPotion>(0,"Wound Defense", true, x, y))); tiles[x][y]->setOccupy(true); ++numPotion; } else if (input == 'G') { //cout << "constructing 15" << endl; //f->addGold(getTile(x, y)); tiles[x][y]->setOccupy(true); ++numTreasure; } else if (input == '6') { //cout << "constructing 16" << endl; tiles[x][y]->addObject(make_shared<Gold>(2, x, y, false)); tiles[x][y]->setOccupy(true); ++numTreasure; } else if (input == '7') { //cout << "constructing 17" << endl; tiles[x][y]->addObject(make_shared<Gold>(1, x, y, false)); tiles[x][y]->setOccupy(true); ++numTreasure; } else if (input == '8') { //cout << "constructing 18" << endl; tiles[x][y]->addObject(make_shared<Gold>(4, x, y, false)); tiles[x][y]->setOccupy(true); ++numTreasure; } else if (input == '9') { //cout << "constructing 19" << endl; tiles[x][y]->addObject(make_shared<Gold>(6, x, y, true)); tiles[x][y]->setOccupy(true); // // come back to this tomorrow: how to attach to Dragon! especially // if Dragon spawns before or after? ++numTreasure; } } void Floor::oneChamber(int id, Tile *t) { //cout << t << endl; if (t->getType() == 0 && t->getChamberID() == 0) { (chambers.back())->addTile(t); t->setChamberID(id); //cout << t->getChamberID() << endl; oneChamber(id, t->getNeighbr(0)); oneChamber(id, t->getNeighbr(1)); oneChamber(id, t->getNeighbr(2)); oneChamber(id, t->getNeighbr(3)); oneChamber(id, t->getNeighbr(4)); oneChamber(id, t->getNeighbr(5)); oneChamber(id, t->getNeighbr(6)); oneChamber(id, t->getNeighbr(7)); } //if (t == nullptr) cout << "NULL POINTER" << endl; } void Floor::constructChamber(int id) { bool found = false; chambers.emplace_back(make_shared<Chamber> (id)); for (int i = 0; i < 25; ++i) { for (int j = 0; j < 79; ++j) { if (tiles[i][j]->getType() == 0 && tiles[i][j]->getChamberID() == 0) { found = true; //cout << "run oneChamber for " << i << " " << j << endl; oneChamber(id, tiles[i][j].get()); break; } } if (found == true) break; } } void Floor::constructFloor(istream &input, int start, string race, PC *existing) { string line; // construct all Tiles accordingly enemyPosn.resize(25); tiles.resize(25); for (int i = 0; i < 25; ++i) { tiles[i].resize(79); getline(input, line); enemyPosn[i] = line; //cout << line << endl; for (int j = 0; j < 79; ++j) { if (line[j] == '|') { tiles[i][j] = make_shared<Wall> ((make_shared<BasicTile> (i, j, *d)), 1); } else if (line[j] == ' ') { tiles[i][j] = make_shared<None> (make_shared<BasicTile> (i, j, *d)); } else if (line[j] == '-') { tiles[i][j] = make_shared<Wall> ((make_shared<BasicTile> (i, j, *d)), 0); } else if (line[j] == '#') { tiles[i][j] = make_shared<Passage> (make_shared<BasicTile> (i, j, *d)); } else if (line[j] == '+') { tiles[i][j] = make_shared<Door> (make_shared<BasicTile> (i, j, *d)); } else if (line[j] == '@') { tiles[i][j] = make_shared<BasicTile> (i, j, *d); hasPlayer = true; f->addPC(*(tiles[i][j].get()), race); player = (tiles[i][j]->getPC()); player->setDungeon(dungeon); if (position != 1) { int baseAtk = player->getAtk(); int baseDef = player->getDef(); player->setStats(existing->getHP(), baseAtk, baseDef); player->addMoney(existing->getMoney()); } } else if (line[j] == 92) { hasStairs = true; tiles[i][j] = make_shared<Stairs> (make_shared<BasicTile> (i, j, *d)); } else { tiles[i][j] = make_shared<BasicTile> (i, j, *d); } } } //cout << "basic floor constructed" << endl; // setting up neigbours for all Tiles for (int i = 0; i <= 24; ++i) { for (int j = 0; j <= 78; ++j) { //cout << "neighbour construction at : " << i << " " << j << endl; // the neighbours can be identified by position in the vector (integer 0-9 inclusive) // Setting up neighbours to be like below: // |---|---|---| // | 0 | 1 | 2 | // |---|---|---| // | 3 | | 4 | // |---|---|---| // | 5 | 6 | 7 | // |---|---|---| if (i == 0 && j == 0) { // north west corner //cout << "tracker 1" << endl;= tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(tiles[i][j + 1].get()); tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(tiles[i + 1][j].get()); tiles[i][j]->addNeighbr(tiles[i + 1][j + 1].get()); } else if (i == 0 && j == 78) { // north east corner //cout << "tracker 2" << endl; tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(tiles[i][j - 1].get()); tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(tiles[i + 1][j - 1].get()); tiles[i][j]->addNeighbr(tiles[i + 1][j].get()); tiles[i][j]->addNeighbr(nullptr); } else if (i == 0) { // north border //cout << "tracker 3" << endl; tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(tiles[i][j - 1].get()); tiles[i][j]->addNeighbr(tiles[i][j + 1].get()); tiles[i][j]->addNeighbr(tiles[i + 1][j - 1].get()); tiles[i][j]->addNeighbr(tiles[i + 1][j].get()); tiles[i][j]->addNeighbr(tiles[i + 1][j + 1].get()); } else if (i == 24 && j == 0) { // south west corner //cout << "tracker 4" << endl; tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(tiles[i - 1][j].get()); tiles[i][j]->addNeighbr(tiles[i - 1][j + 1].get()); tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(tiles[i][j + 1].get()); tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(nullptr); } else if (i == 24 && j == 78) { // south east corner //cout << "tracker 5" << endl; tiles[i][j]->addNeighbr(tiles[i - 1][j - 1].get()); tiles[i][j]->addNeighbr(tiles[i - 1][j].get()); tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(tiles[i][j - 1].get()); tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(nullptr); } else if (i == 24) { // south border //cout << "tracker 6" << endl; tiles[i][j]->addNeighbr(tiles[i - 1][j - 1].get()); tiles[i][j]->addNeighbr(tiles[i - 1][j].get()); tiles[i][j]->addNeighbr(tiles[i - 1][j + 1].get()); tiles[i][j]->addNeighbr(tiles[i][j - 1].get()); tiles[i][j]->addNeighbr(tiles[i][j + 1].get()); tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(nullptr); } else if (j == 0) { // west border //cout << "tracker 7" << endl; tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(tiles[i - 1][j].get()); tiles[i][j]->addNeighbr(tiles[i - 1][j + 1].get()); tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(tiles[i][j + 1].get()); tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(tiles[i + 1][j].get()); tiles[i][j]->addNeighbr(tiles[i + 1][j + 1].get()); } else if (j == 78) { // east border //cout << "tracker 8" << endl; tiles[i][j]->addNeighbr(tiles[i - 1][j - 1].get()); tiles[i][j]->addNeighbr(tiles[i - 1][j].get()); tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(tiles[i][j - 1].get()); tiles[i][j]->addNeighbr(nullptr); tiles[i][j]->addNeighbr(tiles[i + 1][j - 1].get()); tiles[i][j]->addNeighbr(tiles[i + 1][j].get()); tiles[i][j]->addNeighbr(nullptr); } else { // center tiles //cout << "tracker 9" << endl; tiles[i][j]->addNeighbr(tiles[i - 1][j - 1].get()); tiles[i][j]->addNeighbr(tiles[i - 1][j].get()); tiles[i][j]->addNeighbr(tiles[i - 1][j + 1].get()); tiles[i][j]->addNeighbr(tiles[i][j - 1].get()); tiles[i][j]->addNeighbr(tiles[i][j + 1].get()); tiles[i][j]->addNeighbr(tiles[i + 1][j - 1].get()); tiles[i][j]->addNeighbr(tiles[i + 1][j].get()); tiles[i][j]->addNeighbr(tiles[i + 1][j + 1].get()); } } } //cout << "neighbour setup completed" << endl; // construct chamber; for (int i = 1; i <= numChambers; ++i) { constructChamber(i); } //cout << "chamber construction completed" << endl; // display setup d->defaultFloor(); //cout << &d << endl; spawnPC(race, existing); //cout << "player spawned" << endl; player->attach(*d); //cout << start << endl; bool predetermined = false; // add all other Objects for (int i = 0; i < 25; ++i) { line = enemyPosn[i]; for (int j = 0; j < 79; ++j) { //cout << "tracker" << endl; if (line[j] == '|' || line[j] == ' ' || line[j] == '-' || line[j] == '#' || line[j] == '.' || line[j] == '@' || line[j] == '+' || line[j] == 92) { // do nothing... } else { predetermined = true; //cout << "next object is " << line[j] << endl; Floor::constructObject(i, j, line[j]); } } } //cout << "all setup completed" << endl; // spawning all Objects necessary for one Floor if (predetermined == false) { spawnStairs(); //cout << "stairs spawned" << endl; spawnEnemy(); //cout << "enemy spawned" << endl; spawnPotion(); //cout << "potions spawned" << endl; spawnTreasure(); //cout << "treasure spawned" << endl; } } std::ostream & operator<<(ostream &out, const Floor &f) { out << f.getDisplay(); return out; }
20f7700d944495d20674095ac2b9a3d22cb40255
942bc7a374ced8f96a139feac1a01148cc4e60d7
/indy/C4/IdMappedFTP.hpp
75b3cfa9bf6e44741a889d9b0c3ef53f8362d25f
[]
no_license
p-ameline/Episodus
915b0dfa324a0b9374b887f0fc9fd74a599b9ae3
8bba0a26e267cff40a7669c6ae47647c68a30834
refs/heads/master
2022-04-07T12:39:09.224028
2020-03-06T09:20:03
2020-03-06T09:20:03
119,287,108
1
3
null
null
null
null
UTF-8
C++
false
false
4,461
hpp
IdMappedFTP.hpp
// Borland C++ Builder // Copyright (c) 1995, 1999 by Borland International // All rights reserved // (DO NOT EDIT: machine generated header) 'IdMappedFTP.pas' rev: 4.00 #ifndef IdMappedFTPHPP #define IdMappedFTPHPP #pragma delphiheader begin #pragma option push -w- #include <IdComponent.hpp> // Pascal unit #include <SysUtils.hpp> // Pascal unit #include <IdTCPConnection.hpp> // Pascal unit #include <IdThread.hpp> // Pascal unit #include <IdAssignedNumbers.hpp> // Pascal unit #include <IdMappedPortTCP.hpp> // Pascal unit #include <IdTCPServer.hpp> // Pascal unit #include <Classes.hpp> // Pascal unit #include <SysInit.hpp> // Pascal unit #include <System.hpp> // Pascal unit //-- user supplied ----------------------------------------------------------- namespace Idmappedftp { //-- type declarations ------------------------------------------------------- class DELPHICLASS TIdMappedFtpThread; class DELPHICLASS TIdMappedFtpDataThread; #pragma pack(push, 4) class PASCALIMPLEMENTATION TIdMappedFtpDataThread : public Idthread::TIdThread { typedef Idthread::TIdThread inherited; protected: TIdMappedFtpThread* FMappedFtpThread; Idtcpconnection::TIdTCPConnection* FConnection; Idtcpconnection::TIdTCPConnection* FOutboundClient; Classes::TList* FReadList; AnsiString FNetData; virtual void __fastcall BeforeRun(void); virtual void __fastcall Run(void); public: __fastcall TIdMappedFtpDataThread(TIdMappedFtpThread* AMappedFtpThread); __fastcall virtual ~TIdMappedFtpDataThread(void); __property TIdMappedFtpThread* MappedFtpThread = {read=FMappedFtpThread}; __property Idtcpconnection::TIdTCPConnection* Connection = {read=FConnection}; __property Idtcpconnection::TIdTCPConnection* OutboundClient = {read=FOutboundClient}; __property AnsiString NetData = {read=FNetData, write=FNetData}; }; #pragma pack(pop) #pragma pack(push, 4) class PASCALIMPLEMENTATION TIdMappedFtpThread : public Idmappedporttcp::TIdMappedPortThread { typedef Idmappedporttcp::TIdMappedPortThread inherited; protected: AnsiString FFtpCommand; AnsiString FFtpParams; AnsiString FHost; AnsiString FoutboundHost; int FPort; int FoutboundPort; TIdMappedFtpDataThread* FDataChannelThread; AnsiString __fastcall GetFtpCmdLine(); void __fastcall CreateDataChannelThread(void); virtual bool __fastcall ProcessFtpCommand(void); virtual void __fastcall ProcessOutboundDc(const bool APASV); virtual void __fastcall ProcessDataCommand(void); public: __fastcall virtual TIdMappedFtpThread(bool ACreateSuspended); __property AnsiString FtpCommand = {read=FFtpCommand, write=FFtpCommand}; __property AnsiString FtpParams = {read=FFtpParams, write=FFtpParams}; __property AnsiString FtpCmdLine = {read=GetFtpCmdLine}; __property AnsiString Host = {read=FHost, write=FHost}; __property AnsiString OutboundHost = {read=FoutboundHost, write=FoutboundHost}; __property int Port = {read=FPort, write=FPort, nodefault}; __property int OutboundPort = {read=FoutboundPort, write=FoutboundPort, nodefault}; __property TIdMappedFtpDataThread* DataChannelThread = {read=FDataChannelThread}; public: #pragma option push -w-inl /* TIdMappedPortThread.Destroy */ inline __fastcall virtual ~TIdMappedFtpThread(void) { } #pragma option pop }; #pragma pack(pop) #pragma option push -b- enum TIdMappedFtpOutboundDcMode { fdcmClient, fdcmPort, fdcmPasv }; #pragma option pop class DELPHICLASS TIdMappedFTP; #pragma pack(push, 4) class PASCALIMPLEMENTATION TIdMappedFTP : public Idmappedporttcp::TIdMappedPortTCP { typedef Idmappedporttcp::TIdMappedPortTCP inherited; protected: TIdMappedFtpOutboundDcMode FOutboundDcMode; virtual bool __fastcall DoExecute(Idtcpserver::TIdPeerThread* AThread); public: __fastcall virtual TIdMappedFTP(Classes::TComponent* AOwner); __published: __property DefaultPort ; __property MappedPort ; __property TIdMappedFtpOutboundDcMode OutboundDcMode = {read=FOutboundDcMode, write=FOutboundDcMode , default=0}; public: #pragma option push -w-inl /* TIdTCPServer.Destroy */ inline __fastcall virtual ~TIdMappedFTP(void) { } #pragma option pop }; #pragma pack(pop) //-- var, const, procedure --------------------------------------------------- } /* namespace Idmappedftp */ #if !defined(NO_IMPLICIT_NAMESPACE_USE) using namespace Idmappedftp; #endif #pragma option pop // -w- #pragma delphiheader end. //-- end unit ---------------------------------------------------------------- #endif // IdMappedFTP
39a8f98dfcc81072093efc4acd4f69ad80cebf27
03196a00af2e56b2dc0a34148fcdbca9c0cfca15
/light.cpp
693b558e508b53671a62e492eafb194107220500
[ "MIT" ]
permissive
epsxy/RayTracingPlusPlus
e4a6187ae91df1778e7c4a64e04532b065a85443
efbd3b569bb35a7783a9b9b7d60fd1eb6949b27d
refs/heads/master
2021-05-29T12:50:29.317901
2015-06-12T18:00:42
2015-06-12T18:00:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
464
cpp
light.cpp
#include <iostream> #include "light.h" #include "point.h" using namespace std; void Light::setSource(Point source) { m_source = source; } void Light::setIntensity(double intensity) { m_intensity = intensity; } void Light::printLight() { cout << "Light, de centre"; m_source.printPoint(); cout << "et d'intensité " << m_intensity << endl; } Point Light::getSource() { return m_source; } double Light::getIntensity() { return m_intensity; }
57ac33698ddbabb9869692e3261450fd8d67a4dc
f09774159c0a5791af0bab7550e7d877d6376ac8
/src/pokemons/PokemonCreator.hpp
5d77c154efebc7808189b485066a48c95ae1b978
[]
no_license
WathisLove/PokemonAE
df2dfca499ba14de3c782f5f007af9c5bb3101c2
344d0ae38522f5b4aa7a56a2dc8fac83f00faf4d
refs/heads/master
2023-04-21T00:33:44.450187
2021-05-07T13:57:43
2021-05-07T13:57:43
364,509,897
0
0
null
null
null
null
UTF-8
C++
false
false
1,185
hpp
PokemonCreator.hpp
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /* * File: PokemonCreator.hpp * Author: Redbuzard * * Created on 21 décembre 2019, 15:23 */ #ifndef POKEMONCREATOR_HPP #define POKEMONCREATOR_HPP #include "PokemonID.hpp" #include "Pokemon.hpp" /** * Create a pokemon * @param id the Pokemon ID * @param level the pokemon Level * @return a pointer to the pokemon created */ Pokemon* createPokemon(PokemonID id, int level); /** * Create a pokemon * @param id the Pokemon ID * @param level the pokemon Level * @param actualHealth the health of the pokemon * @return a pointer to the pokemon created */ Pokemon* createPokemon(PokemonID id, int level, int actualHealth); /** * Create a pokemon * @param id the Pokemon ID * @param level the pokemon Level * @param actualHealth the health of the pokemon * @param metadata the pokemon Metadata * @return a pointer to the pokemon created */ Pokemon* createPokemon(PokemonID id, int level, int actualHealth, PokemonMetadata metadata); #endif /* POKEMONCREATOR_HPP */
a73846d57d75141c3177088b66d6a848d210b54c
0f2ce868d634d48362639a556734c66ba5838ae8
/Final/Encrypted Computing/ACA-Final-Team1-Encrypted-Computing-main/src/kernel/scale.cpp
4916e622853c1b1acd78c2e3d05228e13f6d5f20
[ "MIT" ]
permissive
NTU-CSIE-HLS/ACA-HLS
32ae2978cc2a4d62f1c4ccd2d6dcf05a9c786044
4e81b4332e6a3f7867070b11bc9af70a0857e486
refs/heads/main
2023-06-09T10:26:20.929988
2021-07-03T08:44:38
2021-07-03T08:44:38
382,534,133
4
0
null
null
null
null
UTF-8
C++
false
false
6,497
cpp
scale.cpp
#include "rns.h" #include "mod.h" #include <iostream> using namespace std; extern "C" { const int PRAGMA_UNROLL_NUM = UNROLL_NUM; const int PRAGMA_RNS_NUM_2_MINUS_1 = 2*RNS_NUM-1; const int PRAGMA_RNS_NUM_2 = 2*RNS_NUM; const int PRAGMA_RNS_NUM = RNS_NUM; const int PRAGMA_SCALE_LATENCY = SCALE_LATENCY; ap_int<PRIME_BIT+1> center(ap_int<PRIME_BIT+1> a, ap_uint<PRIME_BIT> mod) { ap_int<PRIME_BIT + 1> t = a; if (t > mod/2) t -= mod; if (t < -mod/2) t += mod; return t; } void scale(ap_uint<2*PRIME_BIT> poly_coeff1[RNS_NUM][UNROLL_NUM][N/UNROLL_NUM/2], ap_uint<2*PRIME_BIT> poly_coeff2[RNS_NUM][UNROLL_NUM][N/UNROLL_NUM/2], ap_uint<2*PRIME_BIT> out[RNS_NUM][UNROLL_NUM][N/UNROLL_NUM/2], ap_uint<LOG_RNS> which) { #pragma HLS INTERFACE bram port=poly_coeff1 #pragma HLS RESOURCE variable=poly_coeff1 core=RAM_T2P_BRAM #pragma HLS ARRAY_PARTITION variable=poly_coeff1 complete dim=1 #pragma HLS ARRAY_PARTITION variable=poly_coeff1 block factor=PRAGMA_UNROLL_NUM dim=2 #pragma HLS INTERFACE bram port=poly_coeff2 #pragma HLS RESOURCE variable=poly_coeff2 core=RAM_T2P_BRAM #pragma HLS ARRAY_PARTITION variable=poly_coeff2 complete dim=1 #pragma HLS ARRAY_PARTITION variable=poly_coeff2 block factor=PRAGMA_UNROLL_NUM dim=2 #pragma HLS INTERFACE bram port=out #pragma HLS RESOURCE variable=out core=RAM_T2P_BRAM #pragma HLS ARRAY_PARTITION variable=out complete dim=1 #pragma HLS ARRAY_PARTITION variable=out block factor=PRAGMA_UNROLL_NUM dim=2 ap_uint<LOG_N> i, j, k, l; main: for (i = 0; i < N/UNROLL_NUM/2; i++) { #pragma HLS PIPELINE II=PRAGMA_SCALE_LATENCY for (j = RNS_NUM; j < 2*RNS_NUM; j++) { unroll_calculate: for (l = 0; l < UNROLL_NUM; l++) { //#pragma HLS UNROLL, put it in the innerest loop ap_uint<LOG_N> tmp = j-RNS_NUM; ap_int<3*PRIME_BIT+1> acc11 = 0; ap_int<3*PRIME_BIT+1> acc22 = 0; ap_int<PRIME_BIT+1> acc1 = 0; ap_int<PRIME_BIT+1> acc2 = 0; unroll_k: for (k = 0; k < RNS_NUM-1; k++) { // get coeff ap_uint<2*PRIME_BIT> tempp = poly_coeff1[k][l][i]; ap_int<PRIME_BIT> temp1 = (ap_int<PRIME_BIT>)tempp(PRIME_BIT-1, 0); ap_int<PRIME_BIT> temp2 = (ap_int<PRIME_BIT>)tempp(2*PRIME_BIT-1, PRIME_BIT); // Theta ap_int<3*PRIME_BIT> temp11 = temp1*Theta[which][k]; acc11 += temp11; ap_int<PRIME_BIT+1> upper1 = acc11(3*PRIME_BIT, 2*PRIME_BIT); upper1 = center(upper1, MOD[j]); acc11 = (upper1, acc11(2*PRIME_BIT-1, 0)); ap_int<3*PRIME_BIT> temp22 = temp2*Theta[which][k]; acc22 += temp22; ap_int<PRIME_BIT+1> upper2 = acc22(3*PRIME_BIT, 2*PRIME_BIT); upper2 = center(upper2, MOD[j]); acc22 = (upper2, acc22(2*PRIME_BIT-1, 0)); // Omega ap_int<PRIME_BIT> multiplicand = Omega[which][k][tmp]; ap_int<PRIME_BIT> temp1111 = modular_multiplication(temp1, multiplicand, MOD[j], j); acc1 += temp1111; acc1 = center(acc1, MOD[j]); ap_int<PRIME_BIT> temp2222 = modular_multiplication(temp2, multiplicand, MOD[j], j); acc2 += temp2222; acc2 = center(acc2, MOD[j]); } ap_uint<2*PRIME_BIT> temppp = poly_coeff2[j-RNS_NUM][l][i]; ap_int<PRIME_BIT> tta = temppp(PRIME_BIT-1, 0); ap_int<PRIME_BIT> ttb = temppp(2*PRIME_BIT-1, PRIME_BIT); ap_int<PRIME_BIT> out1 = modular_multiplication(tta, tQ[which][tmp], MOD[j], j); ap_int<PRIME_BIT> out2 = modular_multiplication(ttb, tQ[which][tmp], MOD[j], j); acc1 += out1; acc1 = center(acc1, MOD[j]); acc2 += out2; acc2 = center(acc2, MOD[j]); ap_int<PRIME_BIT> ret1; ret1 = (acc11(2*PRIME_BIT-1, 2*PRIME_BIT-1)) ? acc11(3*PRIME_BIT-1, 2*PRIME_BIT) + 1 : acc11(3*PRIME_BIT-1, 2*PRIME_BIT); ap_int<PRIME_BIT> ret2; ret2 = (acc22(2*PRIME_BIT-1, 2*PRIME_BIT-1)) ? acc22(3*PRIME_BIT-1, 2*PRIME_BIT) + 1 : acc22(3*PRIME_BIT-1, 2*PRIME_BIT); acc1 += ret1; acc1 = center(acc1, MOD[j]); acc2 += ret2; acc2 = center(acc2, MOD[j]); out[j-RNS_NUM][l][i] = (acc2(PRIME_BIT-1,0), acc1(PRIME_BIT-1,0)); } } } } void K_scale(ap_int<PRIME_BIT> *in1, ap_int<PRIME_BIT> *in2, ap_int<PRIME_BIT> *out, int which) { #pragma HLS ALLOCATION instances=scale limit=1 function #pragma HLS INTERFACE m_axi port=in1 offset=slave #pragma HLS INTERFACE m_axi port=in2 offset=slave #pragma HLS INTERFACE m_axi port=out offset=slave #pragma HLS INTERFACE s_axilite port = in1 bundle = control #pragma HLS INTERFACE s_axilite port = in2 bundle = control #pragma HLS INTERFACE s_axilite port = out bundle = control #pragma HLS INTERFACE s_axilite port = which bundle = control #pragma HLS INTERFACE s_axilite port = return bundle = control ap_uint<2*PRIME_BIT> poly_coeff1[RNS_NUM][UNROLL_NUM][N/UNROLL_NUM/2]; ap_uint<2*PRIME_BIT> poly_coeff2[RNS_NUM][UNROLL_NUM][N/UNROLL_NUM/2]; #pragma HLS ARRAY_PARTITION variable=poly_coeff1 complete dim=1 #pragma HLS ARRAY_PARTITION variable=poly_coeff1 complete dim=2 #pragma HLS ARRAY_PARTITION variable=poly_coeff2 complete dim=1 #pragma HLS ARRAY_PARTITION variable=poly_coeff2 complete dim=2 for (ap_uint<LOG_RNS+1> r = 0; r < RNS_NUM; r++) { #pragma HLS PIPELINE for (ap_uint<LOG_N+1> i = 0; i < N/2; i++) { poly_coeff1[r][i/(N/UNROLL_NUM/2)][i%(N/UNROLL_NUM/2)] = (in1[2*i+1+r*N], in1[2*i+r*N]); poly_coeff2[r][i/(N/UNROLL_NUM/2)][i%(N/UNROLL_NUM/2)] = (in2[2*i+1+r*N], in2[2*i+r*N]); } } scale(poly_coeff1, poly_coeff2, poly_coeff2, which); for (ap_uint<LOG_RNS+1> r = 0; r < RNS_NUM; r++) { #pragma HLS PIPELINE for (ap_uint<LOG_N+1> i = 0; i < N/2; i++) { (out[2*i+1+r*N], out[2*i+r*N]) = poly_coeff2[r][i/(N/UNROLL_NUM/2)][i%(N/UNROLL_NUM/2)]; } } return; } }
3391381547f4e85eff8637a67afdaff1b09a5280
69b81075af42da499b7ffb3ef18932607dcdcd5c
/2/prog/misc/sam_06_05/main.cpp
808e3d8e319ff98d0440d43f75cbeb1ad5f83f6b
[]
no_license
jakwuh/bsu
30e11f91409d78067de8c05e645c54a829622f5b
53285d64a02d8f7604999f482dedf52db128e598
refs/heads/master
2020-12-25T18:13:51.979492
2017-12-19T16:13:50
2017-12-19T16:13:50
36,699,846
5
1
null
null
null
null
WINDOWS-1251
C++
false
false
788
cpp
main.cpp
// 5 вариант // Джеймс Аквух // Самостоятельная работа 06.05 #include <iostream> #include <fstream> #include "vector.h" #include "fraction.h" using namespace std; int main() { try { ifstream in("input.txt"); ofstream out("output.txt"); int n, m, k; in >> n >> m; Vector < Vector < Fraction > > v(n, Vector< Fraction >(m, 0)); for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { in >> k; v[i][j] = k; } } out << "Input matrix:" << v; cout << "Enter k:\t"; cin >> k; v[k].sort(); out << "\n\nMatrix with row k sorted:" << v << "\n\nLast row plus row k sorted:" << (v[n - 1] + v[k]); } catch (Error& e) { cout << e.what(); } catch (...) { cout << "Error!"; } system("pause"); return 0; }
f65afb203166d203465e324f503611e56b32c5a6
fcc777b709d795c4116bad5415439e9faa532d39
/dali/pyramid.cpp
bb482d0f8abd44154e39eadc6efe4920b315f41c
[]
no_license
demonsheart/C-
1dcaa2128ec8b20e047ae55dd33f66a359097910
f567b8ca4a4d3ccdf6d59e9fae5b5cea27ec85c1
refs/heads/master
2022-11-29T00:27:30.604843
2020-08-10T11:48:36
2020-08-10T11:48:36
283,923,861
1
0
null
null
null
null
UTF-8
C++
false
false
505
cpp
pyramid.cpp
#include<stdio.h> #include<stdlib.h> int main() { int t,n,j,a,m; char ch; scanf("%d ",&t); for(int i=1;i<=t;i++) { scanf("%d %c",&n,&ch); for(j=1;j<=n;j++) { m=2*j-1; a=2*n-1-m; for(int k=1;k<=a;k++) printf(" "); for(int l=1;l<=m;l++) printf("%c",ch); printf("\n"); } printf("\n"); } system("pause"); } /*ceshishuju 3 1 5 6 * 3 A 输出 5 * *** ***** ******* ********* *********** A AAA AAAAA */
601ef4cfcf46637afb5df61192919b49dcf0bcda
66257fa9bf3025d4398d11d01f19e559a350ee5b
/SDA/Module/Manager/ProcessModuleManager.h
62a31035d8b200f5cdd8c6cfd47ea66731f5b032
[]
no_license
Fleynaro/MultiPlayer
79a7e3e646ef23f5851d5ecc257ad0d77adc6ca1
eb4310e0c61ab7126b3e3e31b322add999cef44b
refs/heads/master
2023-06-12T16:00:53.713952
2021-05-14T14:14:15
2021-05-14T14:14:15
233,058,852
6
0
null
null
null
null
UTF-8
C++
false
false
898
h
ProcessModuleManager.h
#pragma once #include "AbstractManager.h" #include <Address/ProcessModule.h> namespace DB { class ProcessModuleMapper; }; namespace CE { class ProcessModuleManager : public AbstractItemManager { public: using Iterator = AbstractIterator<ProcessModule>; ProcessModuleManager(ProgramModule* module); ~ProcessModuleManager(); void loadProcessModules(); ProcessModule* createProcessModule(HMODULE hModule, const std::string& comment = ""); ProcessModule* createProcessModule(FS::File file, const std::string& comment = ""); ProcessModule* getProcessModuleById(DB::Id id); ProcessModule* getProcessModuleByName(const std::string& name); ProcessModule* findProcessModule(HMODULE hModule); ProcessModule* getMainModule(); std::list<HMODULE> getCurrentlyLoadedModules(); private: ProcessModule* m_mainModule; DB::ProcessModuleMapper* m_processModuleMapper; }; };
60adddc40929241f12d93e3c6d2c2ad1b1c038e5
619941b532c6d2987c0f4e92b73549c6c945c7e5
/Include/Nuclex/Storage/Storage.h
15827a7bdcab237e9009205d15c0791354fc43ae
[]
no_license
dzw/stellarengine
2b70ddefc2827be4f44ec6082201c955788a8a16
2a0a7db2e43c7c3519e79afa56db247f9708bc26
refs/heads/master
2016-09-01T21:12:36.888921
2008-12-12T12:40:37
2008-12-12T12:40:37
36,939,169
0
0
null
null
null
null
UTF-8
C++
false
false
2,471
h
Storage.h
//  // // # # ### # # -= Nuclex Library =-  // // ## # # # ## ## Storage.h - Storage system  // // ### # # ###  // // # ### # ### Everything related to data storage and access  // // # ## # # ## ##  // // # # ### # # R1 (C)2002-2004 Markus Ewald -> License.txt  // //  // #ifndef NUCLEX_STORAGE_STORAGE_H #define NUCLEX_STORAGE_STORAGE_H namespace Nuclex { /// Storage system /** All accesses to stored data in Nuclex are performed through streams. A stream is roughly equivalent to a simplified version of the C++ iostream interface, because it doesn't carry all the formatting and conversion features with it. The most common type of a stream is the FileStream, which does nothing more than reading data out of a file. Nuclex also provides an abstraction for the containers of streams, which are labelled as Archives. If you think of a stream as a file, you can think of an archive as a directory. Archives provide a good way to keep several streams together - for example, all graphics files in a simple game. The storage server allows you to 'mount' archives to make them globally accessable, thus, allowing you to change storage media at will without the need to rewrite any code. If an object in your application needs to store its state in a file or somewhere else, as is the case when you wish to implement save game functionality, you can use a Serializer. A Serializer formats data and can aid you in avoiding versioning troubles, adjusting byte ordering and supporting multiple file formats where needed. Plugins can enable the StorageServer to support new archive types (like zip or rar archives), provide access to new storage media (like an ftp server) and mount their own archives. */ namespace Storage { // Nothing yet } // namespace Storage } // namespace Nuclex #endif // NUCLEX_STORAGE_STORAGE_H
5d23f901a2c269c44f3e2e979ef88eb2faecd3e7
d22ce67851c44e45b3acc80524db95c8f98de6eb
/editbinarywindow.h
1161daed55a7a4671b155121b3d6ec0a126066a4
[]
no_license
Vorobeyyyyyy/ExtendedRegedit
dd57c4b0d5e99aba3b0698163aa81476179b7856
71cd83de294952f912a7610d57c71717ec68a047
refs/heads/master
2022-08-01T10:31:04.361411
2020-05-10T21:55:31
2020-05-10T21:55:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
337
h
editbinarywindow.h
#ifndef EDITBINARYWINDOW_H #define EDITBINARYWINDOW_H #include <QDialog> namespace Ui { class EditBinaryWindow; } class EditBinaryWindow : public QDialog { Q_OBJECT public: explicit EditBinaryWindow(QWidget *parent = nullptr); ~EditBinaryWindow(); private: Ui::EditBinaryWindow *ui; }; #endif // EDITBINARYWINDOW_H
3f523a45d4604a65ef862daaa481f98bb37e1430
39eac74fa6a244d15a01873623d05f480f45e079
/PicContainerDlg.h
b8f2593d71bb398f84ba1d0c4fa070ff42996ebe
[]
no_license
15831944/Practice
a8ac8416b32df82395bb1a4b000b35a0326c0897
ae2cde9c8f2fb6ab63bd7d8cd58701bd3513ec94
refs/heads/master
2021-06-15T12:10:18.730367
2016-11-30T15:13:53
2016-11-30T15:13:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
19,964
h
PicContainerDlg.h
#if !defined(AFX_PICCONTAINERDLG_H__AFBF66FA_C391_4DA4_98E6_E53683F88452__INCLUDED_) #define AFX_PICCONTAINERDLG_H__AFBF66FA_C391_4DA4_98E6_E53683F88452__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // PicContainerDlg.h : header file // #include "EmrFrameWnd.h" #include "EmrPatientFrameWnd.h" #include "MergeEngine.h" #include "HistoryDlg.h" #include "EmrUtils.h" #include "PatientLabsDlg.h" #include "PicViews.h" ///////////////////////////////////////////////////////////////////////////// // CPicContainerDlg dialog class CProcInfoCenterDlg; class CBillingModuleDlg; class CEmrEditorDlg; class CEMN; class CPicDocTemplate; enum ClosePicReason { cprNone = 0,//Simply close without doing anything cprScheduler = 1, //Close, then go to the scheduler module. cprEmnTemplate = 2, //Close, then switch to the EMR tab, and start editing the template with the id given in LPARAM }; enum ClosePicAction { cpaCreateBill = 0, cpaCreateQuote, cpaWritePrescriptions, cpaDoNothing, cpaDoPartialBilling, // (j.dinatale 2012-01-18 17:22) - PLID 47539 - we can do partial billing now }; //TES 2/3/2006 - Used when checking for duplicates. struct DetailInfo { CEMNDetail *pDetail; BOOL m_bMarkedForDeletion; CString m_strFormatted; }; class CNxRibbonAutoComboBox; // (a.walling 2011-10-20 21:22) - PLID 46076 - Facelift - EMR frame window // (a.walling 2012-02-28 14:53) - PLID 48451 - Now deriving from CEmrPatientFrameWnd class CPicContainerDlg : public CEmrPatientFrameWnd { DECLARE_DYNCREATE(CPicContainerDlg) // Construction public: CPicContainerDlg(); // standard constructor virtual ~CPicContainerDlg(); long m_nColor; // (j.jones 2012-09-26 14:04) - PLID 52879 - added drug interactions // (j.jones 2012-11-30 11:09) - PLID 53194 - added bShowEvenIfUnchanged, which // will show the dialog even if its current interactions have not changed since the last popup void ViewDrugInteractions(bool bShowEvenWhenEmpty = false, bool bShowEvenIfUnchanged = false); protected: //// /// UI state afx_msg void OnUpdateViewPic(CCmdUI* pCmdUI); afx_msg void OnUpdateViewHistory(CCmdUI* pCmdUI); afx_msg void OnUpdateViewLabs(CCmdUI* pCmdUI); // (a.walling 2011-12-09 17:16) - PLID 46643 - Tool buttons and UI components (time, etc) // (a.wilson 2012-4-30) PLID 49479 - removing the graph button because it is no longer necessary. //afx_msg void OnUpdateViewGraphs(CCmdUI* pCmdUI); afx_msg void OnUpdateViewEPrescribing(CCmdUI* pCmdUI); afx_msg void OnUpdateViewMedAllergy(CCmdUI* pCmdUI); afx_msg void OnUpdateViewBarcode(CCmdUI* pCmdUI); afx_msg void OnUpdateViewEyemaginations(CCmdUI* pCmdUI); // (b.savon 2012-02-22 10:39) - PLID 48307 - Recall tool button afx_msg void OnUpdateViewRecall(CCmdUI* pCmdUI); // (a.walling 2012-04-02 16:51) - PLID 49360 - Device Import handling afx_msg void OnUpdateViewDeviceImport(CCmdUI* pCmdUI); // (j.jones 2012-09-26 14:04) - PLID 52879 - added drug interactions afx_msg void OnUpdateViewDrugInteractions(CCmdUI* pCmdUI); // (a.walling 2012-02-28 08:27) - PLID 48429 - EmrEditor is for patients afx_msg void OnUpdateStatusTotalTimeOpen(CCmdUI* pCmdUI); afx_msg void OnUpdateStatusCurrentTimeOpen(CCmdUI* pCmdUI); /// Merging // (a.walling 2012-04-30 12:47) - PLID 49832 - Merging UI afx_msg void OnUpdateMergeFromPacket(CCmdUI* pCmdUI); afx_msg void OnUpdateMergeFromTemplate(CCmdUI* pCmdUI); afx_msg void OnUpdateEditPacket(CCmdUI* pCmdUI); afx_msg void OnUpdateEditTemplate(CCmdUI* pCmdUI); afx_msg void OnUpdateNewTemplate(CCmdUI* pCmdUI); afx_msg void OnUpdateMergePacketCombo(CCmdUI* pCmdUI); afx_msg void OnUpdateMergeTemplateCombo(CCmdUI* pCmdUI); afx_msg void OnUpdateMergeAdvancedSetup(CCmdUI* pCmdUI); afx_msg void OnUpdateMergeRefresh(CCmdUI* pCmdUI); afx_msg void OnUpdateMergeOptions(CCmdUI* pCmdUI); /// Single EMN Merge // (a.walling 2012-10-01 09:15) - PLID 52119 - Handle merging from single EMN, setting default templates afx_msg void OnUpdateEmnMergeFromTemplate(CCmdUI* pCmdUI); afx_msg void OnUpdateEmnMergeFromOther(CCmdUI* pCmdUI); afx_msg void OnUpdateEmnEditTemplate(CCmdUI* pCmdUI); afx_msg void OnUpdateEmnMergeTemplateCombo(CCmdUI* pCmdUI); afx_msg void OnUpdateEmnMergeTemplateMakeDefault(CCmdUI* pCmdUI); CNxRibbonAutoComboBox* GetRibbonPacketCombo(); CNxRibbonAutoComboBox* GetRibbonTemplateCombo(); CNxRibbonAutoComboBox* GetRibbonEmnTemplateCombo(); // (a.walling 2012-10-01 09:15) - PLID 52119 - combo for single EMN merging struct MergeOptions { MergeOptions() : saveToHistory(true) , reverseOrder(false) , separateHistory(false) , toPrinter(false) , allEMNs(true) {} void Load(); void Save(); bool saveToHistory; bool reverseOrder; bool separateHistory; bool toPrinter; bool allEMNs; }; bool m_bLoadedMergePacketCombo; bool m_bLoadedMergeTemplateCombo; MergeOptions m_mergeOptions; //// /// UI commands afx_msg void OnViewPic(); afx_msg void OnViewHistory(); afx_msg void OnViewLabs(); // (a.walling 2011-12-09 17:16) - PLID 46643 - Tool buttons and UI components (time, etc) // (a.wilson 2012-4-30) PLID 49479 - removing the graph button because it is no longer necessary. //afx_msg void OnViewGraphs(); afx_msg void OnViewEPrescribing(); afx_msg void OnViewMedAllergy(); afx_msg void OnViewBarcode(); afx_msg void OnViewEyemaginations(); // (b.savon 2012-02-22 10:39) - PLID 48307 - Recall tool button afx_msg void OnViewRecall(); // (a.walling 2012-04-02 16:51) - PLID 49360 - Device Import handling afx_msg void OnViewDeviceImport(); // (j.jones 2012-09-26 14:04) - PLID 52879 - added drug interactions afx_msg void OnViewDrugInteractions(); //// /// Merging // (a.walling 2012-04-30 13:38) - PLID 50072 - Merging implementation afx_msg void OnMergeFromPacket(); afx_msg void OnMergeFromPacketToWord(); afx_msg void OnMergeFromPacketToPrinter(); void DoMergeFromPacket(); afx_msg void OnMergeFromTemplate(); afx_msg void OnMergeFromTemplateToWord(); afx_msg void OnMergeFromTemplateToPrinter(); void DoMergeFromTemplate(); afx_msg void OnEditPacket(); afx_msg void OnEditTemplate(); afx_msg void OnNewTemplate(); afx_msg void OnCopyTemplate(); void DoCreateNewTemplate(const CString& strBaseTemplate); afx_msg void OnMergePacketCombo(); afx_msg void OnMergeTemplateCombo(); afx_msg void OnMergeAdvancedSetup(); afx_msg void OnMergeRefresh(); afx_msg void OnMergeOptions(UINT nID); /// Single EMN Merge // (a.walling 2012-10-01 09:15) - PLID 52119 - Handle merging from single EMN, setting default templates afx_msg void OnEmnMergeFromTemplate(); afx_msg void OnEmnMergeFromTemplateToWord(); afx_msg void OnEmnMergeFromTemplateToPrinter(); afx_msg void OnEmnMergeFromOther(); afx_msg void OnEmnMergeFromOtherToWord(); afx_msg void OnEmnMergeFromOtherToPrinter(); void DoEmnMergeFromTemplate(CString strTemplateFileName, bool bSaveInHistory, bool bDirectToPrinter); afx_msg void OnEmnEditTemplate(); afx_msg void OnEmnMergeTemplateCombo(); afx_msg void OnEmnMergeTemplateMakeDefault(); public: //When opening a PicContainerDlg, you must give it either an EmrGroupID or a ProcInfoID. //You may also optionally give it an EMN ID to load initially, or an EMN Template ID to create a new EMN for, //in which case it will launch an EMN with the given criteria. //TES 7/26/2005 - Now there is just one function, that takes a PicID, and a tab (can be 0, 1, or 2). // (b.cardillo 2006-06-13 18:29) - You may also specify the HWND of your window if you want // to be notified when the user finishes closing the PIC container created by this function. // (a.walling 2012-05-01 15:31) - PLID 50117 - Tab numbers don't make sense anymore, now it is bShowPIC // (a.walling 2013-01-17 12:08) - PLID 54666 - Removed unused params OPTIONAL HWND hwndReportClosureToWindow = NULL, long nEMNCategoryID = -1 int OpenPic(long nPicID, bool bShowPIC, long nEmnID = -1, long nEmnTemplateID = -1); // (j.dinatale 2012-07-12 14:19) - PLID 51481 - need to keep track of how we opened the pic container bool OpenedForPic(); long GetCurrentPicID(); long GetCurrentProcInfoID(); long GetCurrentEMRGroupID(); // (j.dinatale 2012-06-29 12:49) - PLID 51282 - need to refresh certain panes when a file is attached to history void RefreshPhotoPane(); // (a.walling 2007-08-27 09:17) - PLID 26195 - Return whether the EMR is unsaved or not. BOOL IsEMRUnsaved(); // (j.jones 2011-07-15 13:45) - PLID 42111 - takes in an image file name (could be a path), // and returns TRUE if any Image detail on this EMR references it BOOL IsImageFileInUseOnEMR(const CString strFileName); CBillingModuleDlg *m_BillingDlg; // (c.haag 2006-04-12 09:26) - PLID 20040 - We now cache the IsCommitted // status of a PIC inline BOOL GetIsCommitted() { return m_bIsCommitted; } void SetIsCommitted(BOOL bCommitted) { m_bIsCommitted = bCommitted; } //TES 2006-08-08 - PLID 21667 - Actually commits the PIC, in data. void Commit(); void HandleNewProcInfoProcedures(CArray<long, long> &arProcIDs); void HandleDeletingProcInfoProcedures(CArray<long, long> &arProcIDs); void HandleNewEmrProcedures(CArray<long, long> &arProcIDs); //TES 5/20/2008 - PLID 27905 - Pass in the EMN that they're being deleted from, so we can take that into account when // re-generating our list of IDs. void HandleDeletingEmrProcedures(CArray<long, long> &arProcIDs, CEMN *pEMN); BOOL Save(); CString GetDelimitedProcedureList(); //TES 6/17/2008 - PLID 30414 - Print out prescriptions for the given EMN's medications. If you already know the template // name, pass it in, otherwise the function will calculate it. void PrintPrescriptions(CEMN *pEMN, BOOL bDirectlyToPrinter, const CString &strTemplateName = ""); // (z.manning, 04/25/2008) - PLID 29795 - Added NxIconButtons for merge buttons // Dialog Data //{{AFX_DATA(CPicContainerDlg) enum { IDD = IDD_PIC_CONTAINER_DLG }; //}}AFX_DATA // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CPicContainerDlg) public: protected: virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); //}}AFX_VIRTUAL // Implementation public: afx_msg LRESULT OnTableChanged(WPARAM wParam, LPARAM lParam); // (j.jones 2014-08-04 16:11) - PLID 63181 - added Ex handling virtual LRESULT OnTableChangedEx(WPARAM wParam, LPARAM lParam); // (j.jones 2007-02-06 15:22) - PLID 24493 - track when the user changes the workstation time void FireTimeChanged(); public: // (c.haag 2007-03-07 15:58) - PLID 25110 - Patient ID and name functions void SetPatientID(long nPatID); long GetPatientID() const; CString GetPatientName() const; // (a.walling 2008-05-05 11:11) - PLID 29894 - Function sets and returns the new surgery appt id for this PIC long UpdateSurgeryAppt(); // (j.jones 2010-03-31 17:33) - PLID 37980 - returns TRUE if m_pEmrEditorDlg is non-null, // and has an EMN opened to a topic that is writeable BOOL HasWriteableEMRTopicOpen(); // (j.jones 2010-04-01 11:58) - PLID 37980 - gets the pointer to the active EMN, if there is one CEMN* GetActiveEMN(); CEMR* GetEmr(); // (z.manning 2011-10-28 17:48) - PLID 44594 // (j.jones 2013-03-01 09:41) - PLID 52818 - cache the e-prescribing type CLicense::EPrescribingType m_eRxType; // (a.walling 2012-02-28 08:27) - PLID 48429 - EmrEditor is for patients CEmrEditorDlg* GetEmrEditor() { return m_emrTreePane.GetEmrEditor(); } protected: virtual void InitializeRibbonTabButtons(); //// /// Tools scoped_ptr<CEmrMedAllergyViewerDlg> m_pMedAllergyViewerDlg; // (c.haag 2010-08-03 17:14) - PLID 38928 - Display the medication / allergy viewer void ShowMedAllergyViewer(BOOL bShowExplanation); scoped_ptr<CEMRBarcodeDlg> m_pBarcodeDlg; // (j.dinatale 2011-07-26 17:41) - PLID 44702 - barcode dialog to display this emr's barcode // (j.jones 2012-09-26 13:58) - PLID 52879 - added a drug interactions dialog that uses the EMR as its parent scoped_ptr<CDrugInteractionDlg> m_pDrugInteractionDlg; //(a.wilson 2011-10-17) PLID 45971 CString m_strEyePath; BOOL GenerateLumaXml(); //// /// Messages //// BOOL m_bInitialized; long m_nPicID; bool m_bIsNew; bool m_bLoadedForPic; // (j.dinatale 2012-07-12 14:19) - PLID 51481 - need to keep track of how we opened the pic container long m_nInitialTemplateID; long m_nInitialEmnID; long m_nEmrGroupID; long m_nProcInfoID; //These are just here so we don't have to keep pulling them from data. BOOL m_bIsCommitted; long m_lNewEmnCategoryID; //Makes sure that m_nEmrGroupID and m_nProcInfoID are valid. void EnsureIDs(); // (j.jones 2010-04-01 15:50) - PLID 34915 - added patient gender, age, and primary insurance company BYTE m_cbPatientGender; CString m_strPatientAge; CString m_strPrimaryInsCo; //TES 6/17/2008 - PLID 30411 - Changed long nBillInsuredPartyID to an LPARAM, which will be interpreted differently // based on cpaAction. BOOL SaveAndClose(ClosePicAction cpaAction = cpaDoNothing, CEMN *pEMN = NULL, LPARAM paramActionInfo = NULL); void CloseCleanup(); // (z.manning 2010-01-13 17:52) - PLID 36864 - Removed unused strMergeTemplateName parameter BOOL GenerateMergeData(CMergeEngine &mi, OUT CString &strHeaders, OUT CString &strData, BOOL bEditingTemplate); BOOL GenerateCommonMergeData(const CString& strEMNIDFilter, CList<MergeField,MergeField&> &listMergeFields); BOOL GenerateCategoryMergeData(CList<MergeField,MergeField&> &listMergeFields, BOOL bEditingTemplate); //TES 3/21/2006 - Add an output array of the CEMNs loaded by this function, so GenerateRelatedMergeData won't have to reload them. // (z.manning 2010-01-13 17:52) - PLID 36864 - Removed unused strMergeTemplateName parameter BOOL GenerateDetailMergeData(const CString& strEMNIDFilter, CMergeEngine& mi, CArray<DetailInfo, DetailInfo>& aDetails, POSITION& pLastNonAlphabetized, CList<MergeField,MergeField&> &listMergeFields, BOOL bEditingTemplate, OUT CArray<CEMN*,CEMN*> &arEmns); BOOL GenerateRelatedMergeData(const CArray<CEMN*,CEMN*>& arEMNs, CList<MergeField,MergeField&> &listMergeFields, POSITION posLastNonAlphabetized); CString GetParagraph(CArray<CEMNDetail*, CEMNDetail*>& aDetails, long nCategoryID, EmrCategoryFormat Format, CMergeEngine &mi, CMap<long,long, CArray<long,long>*, CArray<long,long>*>& mapEmrInfoCat); void GenerateTempMergeFiles(CArray<CEMNDetail*, CEMNDetail*>& aDetails, CMergeEngine &mi); void GenerateTempMergeFile(CArray<CEMNDetail*, CEMNDetail*>& aDetails, long nCategoryID, EmrCategoryFormat fmt, const CString& strCatName, CMergeEngine &mi, CMap<long,long, CArray<long,long>*, CArray<long,long>*>& mapEmrInfoCat); void RemoveTempMergeFiles(); // (z.manning 2010-01-13 17:52) - PLID 36864 - Removed unused strMergeTemplateName parameter BOOL CheckAndWarnOfDuplicates(CList<MergeField,MergeField&> &listMergeFields, CArray<DetailInfo, DetailInfo>& aDetails); // (j.jones 2012-07-24 12:49) - PLID 44349 - added filter for only billable codes CString GetServiceCodesOutput(CString strEMNIDFilter, BOOL bOnlyIncludeBillableCodes); CString GetDiagCodesOutput(CString strEMNIDFilter); CString GetMedicationsOutput(CString strEMNIDFilter); // (c.haag 2007-03-07 14:51) - PLID 21207 - Returns TRUE if an EMN does not have // a procedure that exists in aProcIDs BOOL AnyProcedureNotInEMN(CArray<int,int>& aProcIDs, CEMN* pEMN); BOOL AnyProcedureNotInEMN(CArray<int,int>& aProcIDs, long nEMNID); // (a.walling 2007-10-16 17:26) - PLID 27786 - Throws an exception if the EmrGroupID of this PicT record is not null, // not a deleted group, and is not the desired group static BOOL VerifyEmrGroupID(long nPicID, long nDesiredGroupID); // (a.walling 2011-12-08 17:27) - PLID 46641 - Create views for Labs, History, and ProcInfoCenter scoped_ptr<CPicDocTemplate> m_pPicDocTemplate; // (a.walling 2011-10-20 14:23) - PLID 46071 - Liberating window hierarchy dependencies among EMR interface components CProcInfoCenterDlg* GetPicDlg(bool bAutoCreate = false); CHistoryDlg* GetHistoryDlg(bool bAutoCreate = false); CPatientLabsDlg* GetLabsDlg(bool bAutoCreate = false); //Stores the temp .htm files so they can be deleted. CStringArray m_saTempFiles; CArray<long,long> m_arPICProcedureIDs; void GenerateProcedureList(); virtual CString GenerateTitleBarText(); BOOL m_bPicDlgNeedsToLoad; //TES 7/13/2009 - PLID 25154 - This function goes through any EMNs on the dialog, and checks to make sure that, if // they have the "Send to HL7" box checked, they get sent to HL7. This function should be called just before // closing the PIC, but after any saving has taken place. void SendEmnBillsToHL7(); // (a.walling 2012-02-28 08:27) - PLID 48429 - EmrEditor is for patients // (a.walling 2011-12-09 17:16) - PLID 46643 - Time tracking int m_nLastTotalSecondsOpen; int m_nLastCurrentSecondsOpen; BOOL BuildMergeEngineObjects(class CEMR_ExtraMergeFields& emf, class CMergeEngine& mi, BOOL bPacket); bool PickEMNMergeList(IN OUT CDWordArray& adwEMNIDs); protected: // (c.haag 2007-03-07 15:56) - PLID 25110 - The PIC must now keep track of its // patient ID long m_nPatientID; protected: // (a.walling 2012-04-30 14:33) - PLID 50076 - Packet and template combo virtual void SynchronizeDelayedRibbonSubitems(CMFCRibbonBaseElement* pElement); // Generated message map functions //{{AFX_MSG(CPicContainerDlg) BOOL Initialize(); // (a.walling 2012-02-28 08:27) - PLID 48429 - EmrEditor is for patients void InitializeEmrEditor(long nEmrGroupID, long nPicID, long nInitialTemplateID, long nInitialEmnID); void InitializePic(); void InitializeHistory(); void InitializeLabs(); // (a.walling 2012-11-09 08:45) - PLID 53670 - Create a view from path name virtual CMDIChildWndEx* CreateDocumentWindow(LPCTSTR lpcszDocName, CObject* pObj) override; afx_msg void OnDestroy(); afx_msg void OnClose(); afx_msg void OnSaveAndClose(); // (j.dinatale 2012-07-13 14:03) - PLID 51481 afx_msg LRESULT OnClosePic(WPARAM wParam, LPARAM lParam); afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor); afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg LRESULT OnSaveCreateEMNBill(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnSaveCreateEMNQuote(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnSaveWritePrescriptions(WPARAM wParam, LPARAM lParam); //afx_msg void OnNewTemplate(); afx_msg LRESULT OnNonClinicalProceduresAdded(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnPrintPrescriptions(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnEmrMinimizePic(WPARAM wParam, LPARAM lParam); // (a.walling 2009-06-22 10:45) - PLID 34635 - This is useless code which may end up causing problems. //afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized); // (a.walling 2008-09-10 13:31) - PLID 31334 afx_msg LRESULT OnWIAEvent(WPARAM wParam, LPARAM lParam); // (j.jones 2009-08-25 11:37) - PLID 31459 - supported allowing an external refresh of the Proc Info payments afx_msg LRESULT OnReloadProcInfoPays(WPARAM wParam, LPARAM lParam); // (j.jones 2010-03-31 17:01) - PLID 37980 - added ability to tell the EMR to add a given image afx_msg LRESULT OnAddImageToEMR(WPARAM wParam, LPARAM lParam); // (j.jones 2010-06-21 10:22) - PLID 39010 - added ability to add a generic table to the EMR afx_msg LRESULT OnAddGenericTableToEMR(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnSaveCreatePartialEMNBills(WPARAM wParam, LPARAM lParam); // (j.dinatale 2012-01-18 17:32) - PLID 47539 // (j.jones 2014-08-04 10:12) - PLID 63144 - added OnShowWindow afx_msg void OnShowWindow(BOOL bShow, UINT nStatus); DECLARE_EVENTSINK_MAP() //}}AFX_MSG DECLARE_MESSAGE_MAP() }; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_PICCONTAINERDLG_H__AFBF66FA_C391_4DA4_98E6_E53683F88452__INCLUDED_)
d256c9e3e7f0aa9d57fce2d9e00f5dfb5453693b
dbecc8d098ea32cc2b7c9076aa6ef2f710683180
/spell/MagicArrow.h
30ea41dab2c947bed6cf8b16f529e783c727fd8f
[]
no_license
pushkin-82/Army
b4ac572c1ad2bc11f5900d155ab754784c6776c8
9a1b2ffac2c21c5769a47005c41837adc32c98f8
refs/heads/master
2021-09-18T01:20:56.817567
2018-07-08T09:45:56
2018-07-08T09:45:56
114,532,569
0
0
null
2018-07-08T09:39:02
2017-12-17T11:59:18
C++
UTF-8
C++
false
false
306
h
MagicArrow.h
#ifndef MAGIC_ARROW_H #define MAGIC_ARROW_H #include "Spell.h" class MagicArrow : public Spell { public: MagicArrow(std::string title="Magic Arrow", int cost=5, int points=10); virtual ~MagicArrow(); virtual void action(Unit* target); }; #endif // MAGIC_ARROW_H
75b681d3b44e0b97d76de602bf8bca8532de8613
daffbc366b1938b07fb3badf64a2a6bfaf27b226
/Server.cpp
b4a08f4b07c3cb69d23ea7aaf51e4e7a7e515944
[]
no_license
OskarMariaGraf/Kuppel
50f887cea04fd12bd28f1a6a5601a7198b5bdd60
9adc9b3445aec072a1913f518844b59980dc4cef
refs/heads/master
2021-01-10T16:00:09.928715
2017-02-13T08:23:09
2017-02-13T08:23:09
52,727,128
1
1
null
2016-10-20T15:41:14
2016-02-28T15:11:32
C++
UTF-8
C++
false
false
7,763
cpp
Server.cpp
//g++ -Wall -o Server -std=c++11 Server.cpp utility.cpp //Copyright @ David Fucking Berger //Anmerkungen zu Kommentaren: entweder man weiß wie Sockets und Read()/Write() in c/c++ funktionieren oder halt nicht, dann einfach mal kurzes Tutorial googlen, dauert wenn man c/c++ kann vielleicht 30min //Die spezifischen, nicht selbsterklärenden Teile wie Datenformate etc. sollten eigentlich schon angegeben sein. Fragen bitte einfach an david.p.berger@gmx.de //||UPDATE|| Ich hab jetz doch alles dokumentiert -.- #define INTERVALL 1000000 //1s #define READTIMEOUT 1 //1s #define WRITETIMEOUT 1 //1s #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> #include <string> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <iostream> #include <unistd.h> #include <time.h> #include <sys/time.h> #include <ctime> #include <chrono> #include <sys/stat.h>//---------------- #include <fcntl.h> //----------------- #include <iomanip> #include "utility.h" using namespace std; int newsockfd = 0; int RegenRinne1 = 0; int RegenRinne2 = 0; int KameraWolken1 = 0; int KameraWolken2 = 0; const char* WritePipe = "/tmp/RegenRinne1"; const char* ReadPipe = "/tmp/RegenRinne2"; const char *WritePipeCam = "/tmp/camin"; const char *ReadPipeCam = "/tmp/camout"; double buf; void CleanUp() //Zeug schließen { if (newsockfd != 0) close(newsockfd); } //Versucht ein Double Array der Länge 5 an Client zu senden //return value: -1 Fehler; 1 Erfolg int DatenSenden(int sockfd, double Daten[5]) { int n; char *buffer = (char*)&Daten[0]; if ((n = write(sockfd, buffer, 40)) < 0) { error("ERROR beim Senden der Daten"); return -1; } cout <<currentTime() <<"Daten gesendet" << endl; return 1; } //Versucht ein einzelnes byte Client zu senden //return value: -1 Fehler; 1 Erfolg int BefehlSenden(int sockfd, char Befehl) { int n; if ((n = write(sockfd, (void *)&Befehl, 1)) < 0) { error("ERROR beim Senden eines Befehls"); return -1; } cout <<currentTime() <<"Befehl " << (int)Befehl << " gesendet" << endl; return 1; } //schickt ein byte Anfrage an pipe sockfd und erhält einen double von pipe sockfd2 //Gibt 420 bei Fehler zurück double DatenEmpfangen(int sockfd, int sockfd2) { double buffer; unsigned char shakebyte = 0xff; int n; if ((n = write(sockfd, &shakebyte, 1)) <= 0) { error("ERROR beim Handshake mit einem Sensor"); return 420; } n = read(sockfd2, (void *)&buffer,8); if (n <= 0) { error("ERROR beim Empfangen der Sensordaten"); return 420; } cout <<currentTime() <<"SensorDaten " << (double)buffer << " empfangen" << endl; return buffer; } //empfängt ein einzelnes byte von Socket sockfd //return value 0xfe bei Fehler (z.B Timeout), weil das byte auch vom client gesendet wird wenn er absichtlich disconnected unsigned char BefehlEmpfangen(int sockfd) { char buffer; int n; n= read(sockfd, (void *)&buffer,1); if (n <= 0) { error("ERROR beim Empfangen des Befehls"); return 0xfe; } cout <<currentTime() <<"Befehl " << (int)buffer << " empfangen" << endl; return buffer; } int main(int argc, char *argv[]) { //Funktion CleanUp beim schließen aufrufen, damit der Socket geschlossen und der Port wieder frei ist atexit(CleanUp); //"Handle" für den Socket int sockfd; //Der Port auf dem auf einen client gewartet wird int portno = 5902; //länge der client adresse (wenn 0 connect Fehlgeschlagen) int clilen; //eigene und client adresse struct sockaddr_in serv_addr, cli_addr; //Der letze Befehl... char letzerBefehl = 0; cout <<currentTime() << "Port #" << portno << endl; //öffne einen Socket für internet sockfd = socket(AF_INET, SOCK_STREAM, 0); int option = 1; //wenn auf linux sockets nicht mit close() geschlossen werden, bleibt der port für ca. 4 min belegt und das erneute Starten des servers schlägt fehl //--> REUSEADDR ; sofort den port wieder freigeben setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(option)); if (sockfd < 0) error("ERROR beim Socket öffnen"); //server adresse mit nullern vollschreiben, falls noch schmarrn im allocated memory steht bzero((char *)&serv_addr, sizeof(serv_addr)); //hatten wir ja schon... serv_addr.sin_family = AF_INET; //parsed ips und ddns server und alles halt serv_addr.sin_addr.s_addr = INADDR_ANY; //port setzen serv_addr.sin_port = htons(portno); //Socket an port und adresse binden if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) error("ERROR beim Binden"); //maximal eine connection annehmen listen(sockfd, 1); //länge der clientadresse setzen clilen = sizeof(cli_addr); //reconnect loop: //Warten auf Verbindung von Client, daten austauschen, bei fehler disconnecten und wieder warten while (1) { connect: cout <<currentTime() << "Warte auf Verbindung..." << endl; //einen Client akzeptieren und sein handle in newsockfd speichern if ((newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, (socklen_t*)&clilen)) < 0) error("ERROR beim Annehmen der Verbindung"); //Timeout erklärt sich von selbst struct timeval timeout; timeout.tv_sec = READTIMEOUT; timeout.tv_usec = WRITETIMEOUT; if (setsockopt (newsockfd, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof(timeout)) < 0) error("setsockopt fehlgeschlagen\n"); if (setsockopt (newsockfd, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, sizeof(timeout)) < 0) error("setsockopt fehlgeschlagen\n"); cout <<currentTime() << "Client verbunden" << endl; while (1) { //die pipes jedes mal öffnen, wenn sie schon offen sind machts keinen unterschied //es kann sein, dass die pipe zwischendurch zu is, deswegen eine art reconnect versuch //leider kann man nicht testen, ob die pipe noch verbunden ist, also lieber nummer sicher RegenRinne1 = open(WritePipe, O_RDWR | O_NONBLOCK); //RegenPipe zum Schreiben RegenRinne2 = open(ReadPipe,O_RDWR | O_NONBLOCK); //-"- zum lesen KameraWolken1 = open(WritePipeCam, O_RDWR | O_NONBLOCK); //Kamera-Pipe KameraWolken2 = open(ReadPipeCam, O_RDWR | O_NONBLOCK); //Sendeintervall warten usleep(INTERVALL); //client sollte ein byte senden, in dem paar sachen stehn letzerBefehl = BefehlEmpfangen(newsockfd); switch (letzerBefehl) { case 0xff://Daten Senden versuchen bei 0xff, weil das halt so is double d[5]; d[0] = ((int) DatenEmpfangen(KameraWolken1, KameraWolken2)) / 100; //Wolkenverdeckung d[1] = DatenEmpfangen(RegenRinne1,RegenRinne2); //Regen d[2] = rand() * 324872.123; //Windgeschwindigkeit d[3] = rand() * 123.45; //Himmelshelligkeit d[4] = rand() * 0.00123; //Himmelsqualität //returnwert von datensenden sollte optimalerweise nicht -1 sein if (DatenSenden(newsockfd, d)==-1) goto connect; //wartet auf neuen client, weil senden fehlgeschlagen ist if(BefehlSenden(newsockfd, 0xff)==-1)//sagt dem client bescheid, dass der server wieder bereit und noch da ist goto connect; //Scheiße gelaufen, client nicht mehr erreichbar --> reconnect break; case 0xfe: //das sendet der client, wenn er planmäßig beendet wird cout<<currentTime() << "Client hat Verbindung beendet" << endl; goto connect; default: cout <<currentTime() << "unbekannten Befehl erhalten" << endl; break; } } } return 0; }
e0f0da6ebee3e336f0d089e7d9c0ee95192e3424
5d9725f9748016798bb93a40be612b99d03d8b00
/图书管理系统/build-LibraryManageSystem-Desktop_Qt_5_9_0_MSVC2017_64bit-Debug/debug/moc_admininterface.cpp
21e9a617e16f14db4f4c0dd0ef0604a3ee6b3d0e
[ "MIT" ]
permissive
cjj1024/Blog
f5b9fa85b9917719e73c3959736503aa0991b2a3
a108cf47150cd1b980725deadca564fe6f9cc2f5
refs/heads/master
2020-04-28T03:33:51.638424
2019-03-11T06:59:07
2019-03-11T06:59:07
174,942,454
0
0
null
null
null
null
UTF-8
C++
false
false
4,807
cpp
moc_admininterface.cpp
/**************************************************************************** ** Meta object code from reading C++ file 'admininterface.h' ** ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.9.0) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "../../LibraryManageSystem/admininterface.h" #include <QtCore/qbytearray.h> #include <QtCore/qmetatype.h> #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'admininterface.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 67 #error "This file was generated using the moc from 5.9.0. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_AdminInterface_t { QByteArrayData data[12]; char stringdata0[142]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_AdminInterface_t, stringdata0) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_AdminInterface_t qt_meta_stringdata_AdminInterface = { { QT_MOC_LITERAL(0, 0, 14), // "AdminInterface" QT_MOC_LITERAL(1, 15, 16), // "ShowBookInfoSlot" QT_MOC_LITERAL(2, 32, 0), // "" QT_MOC_LITERAL(3, 33, 16), // "QTreeWidgetItem*" QT_MOC_LITERAL(4, 50, 4), // "item" QT_MOC_LITERAL(5, 55, 6), // "column" QT_MOC_LITERAL(6, 62, 11), // "AddBookSlot" QT_MOC_LITERAL(7, 74, 14), // "DeleteBookSlot" QT_MOC_LITERAL(8, 89, 11), // "AddUserSlot" QT_MOC_LITERAL(9, 101, 14), // "DeleteUserSlot" QT_MOC_LITERAL(10, 116, 12), // "ShowAllBooks" QT_MOC_LITERAL(11, 129, 12) // "ShowAllUsers" }, "AdminInterface\0ShowBookInfoSlot\0\0" "QTreeWidgetItem*\0item\0column\0AddBookSlot\0" "DeleteBookSlot\0AddUserSlot\0DeleteUserSlot\0" "ShowAllBooks\0ShowAllUsers" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_AdminInterface[] = { // content: 7, // revision 0, // classname 0, 0, // classinfo 7, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount // slots: name, argc, parameters, tag, flags 1, 2, 49, 2, 0x0a /* Public */, 6, 0, 54, 2, 0x0a /* Public */, 7, 0, 55, 2, 0x0a /* Public */, 8, 0, 56, 2, 0x0a /* Public */, 9, 0, 57, 2, 0x0a /* Public */, 10, 0, 58, 2, 0x0a /* Public */, 11, 0, 59, 2, 0x0a /* Public */, // slots: parameters QMetaType::Void, 0x80000000 | 3, QMetaType::Int, 4, 5, QMetaType::Void, QMetaType::Void, QMetaType::Void, QMetaType::Void, QMetaType::Void, QMetaType::Void, 0 // eod }; void AdminInterface::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { AdminInterface *_t = static_cast<AdminInterface *>(_o); Q_UNUSED(_t) switch (_id) { case 0: _t->ShowBookInfoSlot((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 1: _t->AddBookSlot(); break; case 2: _t->DeleteBookSlot(); break; case 3: _t->AddUserSlot(); break; case 4: _t->DeleteUserSlot(); break; case 5: _t->ShowAllBooks(); break; case 6: _t->ShowAllUsers(); break; default: ; } } } const QMetaObject AdminInterface::staticMetaObject = { { &QWidget::staticMetaObject, qt_meta_stringdata_AdminInterface.data, qt_meta_data_AdminInterface, qt_static_metacall, nullptr, nullptr} }; const QMetaObject *AdminInterface::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *AdminInterface::qt_metacast(const char *_clname) { if (!_clname) return nullptr; if (!strcmp(_clname, qt_meta_stringdata_AdminInterface.stringdata0)) return static_cast<void*>(const_cast< AdminInterface*>(this)); return QWidget::qt_metacast(_clname); } int AdminInterface::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 7) qt_static_metacall(this, _c, _id, _a); _id -= 7; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 7) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 7; } return _id; } QT_WARNING_POP QT_END_MOC_NAMESPACE
45866de9d2061e88d2248244e246d5f0b727bdad
877fff5bb313ccd23d1d01bf23b1e1f2b13bb85a
/app/src/main/cpp/dir521/dir3871/dir4221/dir4222/file4323.cpp
00975c6a4f0a6a131a409c77488ab6eee9f70f73
[]
no_license
tgeng/HugeProject
829c3bdfb7cbaf57727c41263212d4a67e3eb93d
4488d3b765e8827636ce5e878baacdf388710ef2
refs/heads/master
2022-08-21T16:58:54.161627
2020-05-28T01:54:03
2020-05-28T01:54:03
267,468,475
0
0
null
null
null
null
UTF-8
C++
false
false
111
cpp
file4323.cpp
#ifndef file4323 #error "macro file4323 must be defined" #endif static const char* file4323String = "file4323";
d314a6ff0d771f4d58761b6c968b48a3dc2cd72c
3161b3bb926b9c60bf6b8bf579887575345cbed5
/SWExpertAcademy/2117_Home_security_service/source.cpp
d98d675db7cfaf20d6fd0f0dcb346fcb48babed6
[]
no_license
mks0/CodingTest
71bf660d73c11580035b9a245a0954752d2282c0
c89a534d9ff552d449075b4c964c7b1214d92276
refs/heads/master
2023-07-26T19:07:19.946830
2021-09-12T12:39:14
2021-09-12T12:39:14
367,276,687
0
0
null
null
null
null
UTF-8
C++
false
false
1,199
cpp
source.cpp
#include <iostream> #include <cmath> using namespace std; struct Pos { int i, j; }; int mapSize, money, homeCnt; Pos home[400]; inline int GetCost(const int k) { return k * k + (k - 1) * (k - 1); } inline int GetDist(const Pos& pos1, const Pos& pos2) { return abs(pos1.i - pos2.i) + abs(pos1.j - pos2.j); } void Input() { scanf("%d %d", &mapSize, &money); homeCnt = 0; for (int i = 0; i < mapSize; ++i) { for (int j = 0; j < mapSize; ++j) { int temp; scanf("%d", &temp); if (temp) { home[homeCnt].i = i; home[homeCnt++].j = j; } } } } int Solution() { int result = 0; for (int k = 1; k <= mapSize + 1; ++k) { const int cost = GetCost(k); for (int i = 0; i < mapSize; ++i) { for (int j = 0; j < mapSize; ++j) { int inCount = 0; for (int z = 0; z < homeCnt; ++z) if (k > GetDist({ i, j }, home[z])) ++inCount; if (cost <= inCount * money) result = max(result, inCount); } } } return result; } int main(int argc, char** argv) { int T; //freopen("sample_input.txt", "r", stdin); scanf("%d", &T); for (int test_case = 1; test_case <= T; ++test_case) { Input(); printf("#%d %d\n", test_case, Solution()); } return 0; }
bcd7aebc4c8cd008cb743a87b4f27501263351bd
1cc305e092455e108267ca3d6f3189321a258114
/src/main_gui_objects/Model.h
e842936cb5e2d54eabd867339349450e59b44d5f
[]
no_license
katja/FunnyGears
0f247e1e56b6a8e4a97669f7a80ebe857cf74c03
91c80e63b96764e37fe97031b770865700a24435
refs/heads/master
2016-08-04T20:11:20.753149
2015-10-23T12:53:14
2015-10-23T12:53:14
18,118,762
0
0
null
null
null
null
UTF-8
C++
false
false
10,907
h
Model.h
#ifndef MODEL #define MODEL #include "stable.h" #include "graphics_objects/GraphicsScheduleItem.h" #include "helper_objects/ChangingObjectResponder.h" /** Model (tree) of the ModelTreeView and the whole scene * Responsible for adding, organising and removing items * * Holds a tree of all GraphicsScheduleItems – the root of the tree is an GraphicsRootItem * and is created in the initializer. * This root item is added to the QGraphicsScene scene, too, so all other items of the * model are added as children of this root item. It is not visible, as it has no graphic * representation. * As all GraphicsScheduleItems (the root item included) are installed on the scene, * the scene is responsible for the deletion of these items.) * * To be able to use the ModelTreeView in the ObjectScheduleViewWidget it uses Qt's * QAbstractItemModel. Therefore it has implementations of the methods index(), parent(), * hasChildren(), rowCount(), columnCount(), data(), setData(), headerData() and flags(). * * Qt uses objects of QModelIndex to represent the data in a QAbstractItemModel. The Model * used here has a fixed number of columns (described in enum DATA). The number of rows * complies with the number of children of the root item and may grow and shrink. In every * cell of one row is saved the same internal pointer – the pointer to the corresponding * GraphicsScheduleItem. It only differs when data() is called. Depending on the column * data() calls the name() or the isVisible() on the GraphicsScheduleItem. It is no good * design to have these same pointers saved several times in each row. But this approach * makes the connection to the tree view easier. * * Items can only be added as top level items! But the GraphicsScheduleItems can have * children on their own (by calling setParentItem(...) on the children). Access to the * child items it available by the model, too. Thus the top level items are responsible * for the creation and the deletion of their child items!!! * * When items are deleted it is very essential to inform other components of the removal. * Qt provides and demandes therefore the beginRemoveRows() and the endRemoveRows() methods. * As Model provides methods to remove many items at once but internal handles this by * removing item by item, two new signals are introduced by class Model. * QAbstractItemModel::beginRemoveRows(const QModelIndex &parent, int first, int last) * emits the signal QAbstractItemModel::rowsAboutToBeRemoved(const QModelIndex &parent, int first, int last) * Inspired by this the signal rowsAboutToBeRemoved() is emitted before any item is removed * (and also before the beginRemoveRows(...) is called, therefore even before the first * QAbstractItemModel::rowsAboutToBeRemoved(...) signal is emitted) * And after all the removal has finished (and also the last endRemoveRows() had been called) * signal rowsFinishedRemoval() is emitted. */ class Model : public QAbstractItemModel, public ChangingObjectResponder { Q_OBJECT public: /** Constructor of a Model for the given @param scene * Note that the model uses a special invisible root item, which is added to the scene * As this root item is added first here in the constructor, any QGraphicsItems (or * GraphicsScheduleItems) added before, are ignored! */ Model(QGraphicsScene *scene, QObject *parent = 0); virtual ~Model(); /** Describes the different columns available in this model */ enum Data { NAME, VISIBILITY }; /** Returns the index of the item in the model * specified by the given row, column and parent index. */ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; //When reimplementing this function in a subclass, call createIndex() to generate model indexes that other components can use to refer to items in your model. /** Returns the parent of the model item with the given index. * If the item has no parent, an invalid QModelIndex is returned. * * A common convention is that only the items in the first column have children. * Therefore the column of the returned QModelIndex would always be 0. */ QModelIndex parent(const QModelIndex &index) const; //When reimplementing this function in a subclass, be careful to avoid calling QModelIndex member functions, such as QModelIndex::parent(), since indexes belonging to your model will simply call your implementation, leading to infinite recursion. /** Returns true, if the corresponding GraphicsScheduleItem is found and has any * children; otherwise returns false. */ bool hasChildren(const QModelIndex &parent = QModelIndex()) const; /** Returns the number of rows under the given parent. * When the parent is valid it means that rowCount is returning * the number of children of parent. */ int rowCount(const QModelIndex &parent = QModelIndex()) const; /** Returns the number of columns for the children of the given parent. * In this implementation the number of columns is independent of the given parent * and always 2. */ int columnCount(const QModelIndex &parent = QModelIndex()) const; /** Returns the data stored under the given role for the item referred to by the index. */ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; //If you do not have a value to return, return an invalid QVariant instead of returning 0. /** Sets the role data for the item at index to value. * Returns true if successful; otherwise returns false. * dataChanged() signal is emitted, if data was successfully set */ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); //emit dataChanged() signal /** Toggles the boolean values (up to now there is only the visibility value). * Returns true, if toggling was possible. */ bool toggleValue(const QModelIndex &index); /** Returns the data for the given role and section in the header * with the specified orientation. */ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; /** Returns the item flags for the given index. */ Qt::ItemFlags flags(const QModelIndex &index) const; //The base class implementation returns a combination of flags that enables the item (ItemIsEnabled) and allows it to be selected (ItemIsSelectable). ItemIsEditable must be returned! /** Adds given newItem to model as top level item */ bool addItem(GraphicsScheduleItem *newItem); /** @brief Removes the single row item with QModelIndex index * * The row to which index belongs, is removed. Only top level items are removed by * the Model! When index is not a top level item, false is returned. * To inform other components about the removal and the completion of the removal, * the signals rowsAboutToBeRemoved() and rowsFinishedRemoval are emitted. * @return true if the row of the index could properly be removed */ bool remove(QModelIndex index); /** @brief Removes all top level rows, which the given QModelIndexList indices belong to * * In fact it only deletes the rows, if an item of indices in column 0 is given. * A QModelIndex with another column is not handles at all. But it is expected that * all items of a row are listed in indices, as they all belong to the row. * All QModelIndexes which are not top level items, that means they have another parent * than the root item, are not deleted and should be deleted by their parents themselves! * * To prevent other components of trying to access items, while the removal is in * progress, the signal rowsAboutToBeRemoved() is emitted before the first item is * removed. The signal rowsFinishedRemoval is emitted when the whole removal is * finished. * @return true if every row given by the indices could be properly removed or when * no row is given by indices, false otherwise */ bool remove(QModelIndexList indices); /** @brief Removes all items of the Model except the root item * * To prevent other components of trying to access items, while the removal is in * progress, the signal rowsAboutToBeRemoved() is emitted before the first item is * removed. The signal rowsFinishedRemoval is emitted when the whole removal is * finished. */ void removeAll(); /** Clears the selection of every item in the model */ void clearSelection(); /** Returns a pointer to the GraphicsScheduleItem, which belongs to the given QModelIndex. * If Index is not valid or no corresponding GraphicsScheduleItem can be found * nullptr is returned. */ GraphicsScheduleItem* getItemFromIndex(const QModelIndex &index) const; /** Returns the QModelIndex (in column 0) which belongs to the given GraphicsScheduleItem. */ QModelIndex getIndexFromItem(GraphicsScheduleItem *item) const; bool hasChanged() const override; // from ChangingObjectResponder void clearChanges() override; // from ChangingObjectResponder signals: void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>()); // void rowsAboutToBeRemoved(const QModelIndex &parent, int first, int last); void rowsAboutToBeRemoved(); void rowsFinishedRemoval(); private: QGraphicsScene *m_scene; GraphicsScheduleItem *m_rootItem; QHash< Data, QHash<Qt::ItemDataRole, QString> > m_headHash; bool m_changed; /** @brief Removes the given (top level) row * * This method does not emit necessary signals to inform other components of the removal! * It acts only as a helper method for the public methods to remove items! Do not use * it in another way! */ bool removeRow(int row); /** @brief Removes all dependencies and deletes item */ void deleteItem(GraphicsScheduleItem *item); /** @brief Informs all current ChangingObjectListener to this object about changes */ // void changed(); bool haveItemsChanged() const; void clearChangedInItems(); /** @brief Like @see changed() but also emits dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>& = QVector<int> ())) */ void dataChanged(const QModelIndex &index); /** Returns a pointer to the GraphicsScheduleItem, which belongs to the given QModelIndex. * If Index is not valid or no corresponding GraphicsScheduleItem can be found * m_rootItem is returned. */ GraphicsScheduleItem* getInternItemFromIndex(const QModelIndex &index) const; }; #endif // MODEL
52d1075bb1516f9648a6693ab6cfba117b7ba3cc
89e8fff78ca6ff0ac56cb7958d9d093159038367
/CreativeEngine/GameObject.cpp
92c69fc1c7231493bb667f99df99369e238cee72
[]
no_license
WhipCream4K/CreativeEngine
ae79c84cdc45b4edb9091b5b92133b09756811e1
e154d63545720f692bad96fd61200a41d63d98b6
refs/heads/master
2022-12-11T23:22:53.647022
2020-08-25T09:27:24
2020-08-25T09:27:24
258,779,855
0
0
null
null
null
null
UTF-8
C++
false
false
1,290
cpp
GameObject.cpp
#include "pch.h" #include "GameObject.h" #include "BaseComponent.h" #include "Transform.h" #include "PhysicsComponent.h" dae::GameObject::GameObject() : m_pTransform() , m_Tag{} , m_IsStatic{} , m_IsActive{ true } , m_IsInit{} { auto transform = std::make_shared<Transform>(); m_pComponents.emplace_back(transform); m_pTransform = transform; } void dae::GameObject::RootRender() const { Render(); for (const auto& component : m_pComponents) { component->Render(); } //for (const auto& physicsComponent : m_pPhysicsComponent) //{ // physicsComponent->Render(); //} } void dae::GameObject::RootAwake() { Awake(); for (const auto& component : m_pComponents) { component->Awake(); } } void dae::GameObject::RootStart() { Start(); for (const auto& component : m_pComponents) { component->Start(); } } void dae::GameObject::RootUpdate() { Update(); for (const auto& component : m_pComponents) { component->Update(); } } void dae::GameObject::RootLateUpdate() { LateUpdate(); for (const auto& component : m_pComponents) { component->LateUpdate(); } } void dae::GameObject::RegisterCollider(const std::shared_ptr<BaseComponent>& component) { GetScene()->GetPhysicsScene()->RegisterCollider(std::static_pointer_cast<Collider>(component)); }
cd67cc3fde152b2fc765a6c9edfdd630cc43cc35
a3c7d2e1bb0b8b7a48f5a32565117cdbe6c714c5
/include/pyhrol_type_iterable.hpp
d06fc6732af6c18fac6cf5a03ccaaa56d77717ec
[ "BSD-2-Clause" ]
permissive
dyomas/pyhrol
353bd6e1e2b9aa53d8b6f4046cd25b71d4390883
6865b7de3377f9d6d3f1b282a39d5980497b703d
refs/heads/master
2021-01-23T15:14:28.867590
2015-08-08T08:25:57
2015-08-08T08:25:57
40,325,532
0
0
null
null
null
null
UTF-8
C++
false
false
4,861
hpp
pyhrol_type_iterable.hpp
/* * Copyright (c) 2013, 2014, Pyhrol, pyhrol@rambler.ru * GEO: N55.703431,E37.623324 .. N48.742359,E44.536997 * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the Pyhrol nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ // $Date: 2014-04-04 16:35:38 +0400 (Пт., 04 апр. 2014) $ // $Revision: 906 $ #ifndef __pyhrol_type_iterable_hpp__ #define __pyhrol_type_iterable_hpp__ #include "pyhrol_type_iterable.h" #include "pyhrol_type_base.hpp" #include "pyhrol_exception_handler.h" namespace pyhrol { namespace __iter_internal { void stop_iteration_error(const char *type_name); } //namespace __iter_internal template <typename T, typename I> void TypeIterable<T, I>::call_iter::call() { typename TypeBase<I>::T_struct *pres = NULL; try { const TypeIterable &type = dynamic_cast<const TypeIterable &>(TypeBase<T>::m_get()); pres = TypeBase<I>::allocate_static(); T &obj = reinterpret_cast<typename TypeBase<T>::T_struct *>(self)->endosome; PYHROL_TRACE(pyhrol::tpMediator, type.address(obj), signature); retval = *pres; type.iter(Ptr<I>(&pres->endosome, retval), Ptr<const T>(&obj, self)); } catch (...) { TypeBase<I>::free_static(pres); retval = NULL; throw; } } template <typename T, typename I> TypeIterable<T, I>::call_iter::call_iter(PyObject *_self, const char *_signature) :self(_self) , signature(_signature) , retval(NULL) { } template <typename T, typename I> void TypeIterable<T, I>::call_next::call() { typename TypeBase<I>::T_struct *pres = NULL; try { const TypeIterable &type = dynamic_cast<const TypeIterable &>(TypeBase<T>::m_get()); pres = TypeBase<I>::allocate_static(); T &obj = reinterpret_cast<typename TypeBase<T>::T_struct *>(self)->endosome; PYHROL_TRACE(pyhrol::tpMediator, type.address(obj), signature); retval = *pres; if (!type.next(Ptr<I>(&pres->endosome, retval), Ptr<T>(&obj, self))) { TypeBase<I>::free_static(pres); retval = NULL; __iter_internal::stop_iteration_error(type->tp_name); } } catch (...) { TypeBase<I>::free_static(pres); retval = NULL; throw; } } template <typename T, typename I> TypeIterable<T, I>::call_next::call_next(PyObject *_self, const char *_signature) : self(_self) , signature(_signature) , retval(NULL) { } template <typename T, typename I> TypeIterable<T, I>::TypeIterable() { m_init(); } template <typename T, typename I> void TypeIterable<T, I>::m_init() { TypeBase<T>::m_type_object.tp_iter = mediator_tp_iter; TypeBase<T>::m_type_object.tp_iternext = mediator_tp_iternext; } template <typename T, typename I> void TypeIterable<T, I>::iter(const Ptr<I> &, const Ptr<const T> &) const { throw ImplementationException(); } template <typename T, typename I> bool TypeIterable<T, I>::next(const Ptr<I> &, const Ptr<T> &) const { throw ImplementationException(); } template <typename T, typename I> PyObject *TypeIterable<T, I>::mediator_tp_iter(PyObject *self) { call_iter c(self, __PRETTY_FUNCTION__); exceptionHandler::call(c, reinterpret_cast<size_t>(mediator_tp_iter)); return c.retval; } template <typename T, typename I> PyObject *TypeIterable<T, I>::mediator_tp_iternext(PyObject *self) { call_next c(self, __PRETTY_FUNCTION__); exceptionHandler::call(c, reinterpret_cast<size_t>(mediator_tp_iternext)); return c.retval; } } //namespace pyhrol #endif //__pyhrol_type_iterable_hpp__
745de3bd0e09033bfe89d50d04f3f4a78552e703
e13e1524348b27dfda021b2d1d2d11fa60de7f4a
/gui/module/debug.hpp
71b324f8a34973b3785d244dbebdf1a94d4ff98f
[]
no_license
Librianets/OESD
11c99aeeee5c211476029a7d109e058a8127163a
aff12cce705801e89769bf644e65e3be5762b14e
refs/heads/master
2022-02-22T12:22:32.376721
2019-07-31T02:54:04
2019-07-31T02:54:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
529
hpp
debug.hpp
#ifndef __DEBUG_HPP__ #define __DEBUG_HPP__ #define MAXMSGLOGLEN 0x0200 //512 class CDebugInfo { public: CDebugInfo(); ~CDebugInfo(); void ClearClass(void); void Debug(const wchar_t *fmt, ...); void Info(const wchar_t *fmt, ...); void WriteLog(int iLogSwitch, int iNumCount); wchar_t *lpGetGlobalMsg(void); void SetPath(wchar_t *Path, int iSizePath); private: wchar_t sPathFilelog [MAXMSGLOGLEN] = {0}; wchar_t sGlobalMsg[MAXMSGLOGLEN] = L"TEST TEST TEST"; }; #endif //__DEBUG_HPP__
67914b4614ba485d1207ba4675cffeb5581c23f0
44a1382fbb4f566a933ff2ad3a864d6f6f4dcaf2
/Number_of_Minimum_Picks_to_get_K_Pairs_of_Socks_from_a_Drawer.cpp
6defa8c71ae56f32e5183ed8e77b9dd42ad19d0c
[]
no_license
yashparmar15/Cpp-Codes
e3f15c5f6bb626d5b8e8115a14a3a825ed138630
7016ef17f03f9d493ee7866785f27e73b09779e7
refs/heads/master
2023-04-19T02:39:19.138477
2021-05-09T18:12:55
2021-05-09T18:12:55
276,151,617
2
0
null
null
null
null
UTF-8
C++
false
false
1,998
cpp
Number_of_Minimum_Picks_to_get_K_Pairs_of_Socks_from_a_Drawer.cpp
/*A drawer contains socks of n different colours. The number of socks available of ith colour is given by a[i] where a is an array of n elements. Tony wants to take k pairs of socks out of the drawer. However, he cannot see the colour of the sock that he is picking. You have to tell what is the minimum number of socks Tony has to pick in one attempt from the drawer such that he can be absolutely sure, without seeing their colours, that he will have at least k matching pairs. Example 1: Input: N = 4, K = 6 a[] = {3, 4, 5, 3} Output: 15 Explanation: All 15 socks have to be picked in order to obtain 6 pairs. Example 2: Input: N = 2, K = 3 a[] = {4, 6} Output: 7 Explanation: The Worst case scenario after 6 picks can be {3,3} or {1,5} or {5,1} of each coloured socks. Hence 7th pick will ensure 3rd pair. Your Task: You don't need to read input or print anything. Complete the function find_min() which takes the array a[], size of array N, and value K as input parameters and returns the minimum number of socks Tony has to pick. If it is not possible to pick then return -1. Expected Time Complexity: O(N) Expected Auxiliary Space: O(1) Constraints: 1 ≤ N ≤ 105 1 ≤ a[i] ≤ 106*/ class Solution{ public: int find_min(int a[], int n, int k) { int pairs = 1; int even = 0; int ans = n + 1; for(int i = 0 ; i < n ; i++){ pairs += (a[i] - 1) / 2; if(a[i] % 2 == 0) even++; } // 9 9 7 8 6 7 6 7 // 1 1 1 1 1 1 1 1 // 3 3 3 3 3 3 3 3 // 5 5 5 5 5 5 5 5 // 7 7 7 7 7 7 // 9 9 if(n == 1 and a[0] == 1 and k == 1) return -1; if(pairs + even <= k) return -1; if(pairs >= k) return ans + (k - 1) * 2; return ans + (pairs - 1) * 2 + (k - pairs); } };
8080abec9ca86f198ad570aa339db2c0f71c3290
26148e715dceeb7592f244cd7dfaa84f2ddec542
/ABC/175/c.cpp
c65fa56aeae63dbb126f175f41f416f1f220d9dc
[]
no_license
R-Hys/compro
4677a1c0c239167976018c3a9fdf02a4a66bc21a
8ce50f09c7f483d72de70413385c52df08995485
refs/heads/master
2023-03-29T16:28:06.211174
2021-03-27T16:11:35
2021-03-27T16:11:35
274,610,838
0
0
null
null
null
null
UTF-8
C++
false
false
714
cpp
c.cpp
#include <iostream> #include <iomanip> #include <algorithm> #include <vector> #include <cmath> using namespace std; typedef long long ll; ll X,K,D; void input() { cin >> X >> K >> D; } void solve() { if (X == 0){ if (K % 2 == 0) cout << 0 << endl; else cout << D << endl; return ; } else { if (X < 0) X = -X; ll pl = X % D, mi = D - pl; ll to_pl = X / D; if (to_pl > K){ cout << X - K * D << endl; } else { if ((K - to_pl) % 2 == 0) cout << pl << endl; else cout << mi << endl; } } } int main() { cin.tie(); ios::sync_with_stdio(false); input(); solve(); return 0; }
33c6913049126b2ffe3d443ff8fcd5b6dd1bbc77
fa7474550cac23f55205666e13a99e59c749db97
/ml/handwriting.h
f879ce6083ccc1d2e62b72a1e6278974b2be8ec6
[ "BSD-3-Clause" ]
permissive
kalyankondapally/chromiumos-platform2
4fe8bac63a95a07ac8afa45088152c2b623b963d
5e5337009a65b1c9aa9e0ea565f567438217e91f
refs/heads/master
2023-01-05T15:25:41.667733
2020-11-08T06:12:01
2020-11-08T07:16:44
295,388,294
0
1
null
null
null
null
UTF-8
C++
false
false
5,879
h
handwriting.h
// Copyright 2020 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef ML_HANDWRITING_H_ #define ML_HANDWRITING_H_ #include <string> #include <base/no_destructor.h> #include <base/optional.h> #include <base/scoped_native_library.h> #include <chromeos/libhandwriting/handwriting_interface.h> #include "chrome/knowledge/handwriting/handwriting_interface.pb.h" #include "ml/mojom/handwriting_recognizer.mojom.h" #include "ml/util.h" namespace ml { // A singleton proxy class for the handwriting DSO. // Usage: // auto* const hwr_library = HandwritingLibrary::GetInstance(); // if (hwr_library->GetStatus() == HandwritingLibrary::kOk) { // // Do the real handwriting here. // recognizer = hwr_library->CreateHandwritingRecognizer(); // ... // } else { // // Otherwise, use HandwritingLibrary::GetStatus() to get the error type. // // Maybe return "not installed". // ... // } class HandwritingLibrary { public: enum class Status { kOk = 0, kUninitialized = 1, kLoadLibraryFailed = 2, kFunctionLookupFailed = 3, kNotSupported = 4, }; // Default handwriting model directory on rootfs. static constexpr char kHandwritingDefaultModelDir[] = "/opt/google/chrome/ml_models/handwriting"; ~HandwritingLibrary() = default; // Returns whether HandwritingLibrary is supported. static constexpr bool IsHandwritingLibrarySupported() { return (IsUseLibHandwritingEnabled() || IsUseLibHandwritingDlcEnabled()) && !IsAsan(); } // Returns whether HandwritingLibrary is supported for unit tests. static constexpr bool IsHandwritingLibraryUnitTestSupported() { return IsUseLibHandwritingEnabled() && !IsAsan(); } // Returns bool of use.ondevice_handwriting. static constexpr bool IsUseLibHandwritingEnabled() { return USE_ONDEVICE_HANDWRITING; } // Returns bool of use.ondevice_handwriting_dlc. static constexpr bool IsUseLibHandwritingDlcEnabled() { return USE_ONDEVICE_HANDWRITING_DLC; } // Gets the singleton HandwritingLibrary. The singleton is initialized with // `model_path` on the first call to GetInstance; for the rest of the calls, // the `model_path` is ignored, and the existing singleton is returned. // The `model_path` should be either a path on rootfs or a path returned by // DlcService. static HandwritingLibrary* GetInstance( const std::string& model_path = kHandwritingDefaultModelDir); // Get whether the library is successfully initialized. // Initially, the status is `Status::kUninitialized` (this value should never // be returned). // If libhandwriting.so can not be loaded, return `kLoadLibraryFailed`. This // usually means on-device handwriting is not supported. // If the functions can not be successfully looked up, return // `kFunctionLookupFailed`. // Return `Status::kOk` if everything works fine. Status GetStatus() const; // The following public member functions define the interface functions of // the libhandwriting.so library. Function `InitHandwritingRecognizerLibrary` // and `DeleteHandwritingResultData` do not need interfaces because the client // won't call it. // Creates and returns a handwriting recognizer which is needed for using the // other interface. The memory is owned by the user and should be deleted // using `DestroyHandwritingRecognizer` after usage. HandwritingRecognizer CreateHandwritingRecognizer() const; // Load the models with `spec` stores the language, the path to the data files // of the model (machine learning models, configurations etc.). // Returns true if HandwritingRecognizer is correctly loaded and // initialized. Returns false otherwise. bool LoadHandwritingRecognizer( HandwritingRecognizer recognizer, chromeos::machine_learning::mojom::HandwritingRecognizerSpecPtr spec) const; // Sends the specified `request` to `recognizer`, if succeeds, `result` (which // should not be null) is populated with the recognition result. // Returns true if succeeds, otherwise returns false. bool RecognizeHandwriting( HandwritingRecognizer recognizer, const chrome_knowledge::HandwritingRecognizerRequest& request, chrome_knowledge::HandwritingRecognizerResult* result) const; // Destroys the handwriting recognizer created by // `CreateHandwritingRecognizer`. Must be called if the handwriting recognizer // will not be used anymore, otherwise there will be memory leak. void DestroyHandwritingRecognizer(HandwritingRecognizer recognizer) const; private: friend class base::NoDestructor<HandwritingLibrary>; FRIEND_TEST(HandwritingLibraryTest, CanLoadLibrary); // Initialize the handwriting library. explicit HandwritingLibrary(const std::string& root_path); // Currently HandwritingLibrary is supported only when the "sanitizer" is not // enabled (see https://crbug.com/1082632). static constexpr bool IsAsan() { return __has_feature(address_sanitizer); } base::Optional<base::ScopedNativeLibrary> library_; Status status_; const base::FilePath model_path_; // Store the interface function pointers. // TODO(honglinyu) as pointed out by cjmcdonald@, we should group the pointers // into a single `HandwritingInterface` struct and make it optional, i.e., // declaring something like |base::Optional<HandwritingInterface> interface_|. CreateHandwritingRecognizerFn create_handwriting_recognizer_; LoadHandwritingRecognizerFn load_handwriting_recognizer_; RecognizeHandwritingFn recognize_handwriting_; DeleteHandwritingResultDataFn delete_handwriting_result_data_; DestroyHandwritingRecognizerFn destroy_handwriting_recognizer_; DISALLOW_COPY_AND_ASSIGN(HandwritingLibrary); }; } // namespace ml #endif // ML_HANDWRITING_H_
921660ba3604a725c5bef1ab34267ea2ddf84d6e
fd900bb8f6ab02f7b4a1397ecd5137896c8ff2c6
/Segment Lazy Sum.cpp
bb3bce0933ef38cb153424c0ba0ebbf787d61cf1
[]
no_license
farhad-aman/Algorithms
ff308bcbbcbe82ed0f3cfb7d856d54a52af708b5
b759829948c0e66f755f99b96cdcc99778a17b29
refs/heads/master
2023-02-26T16:51:31.012851
2021-02-04T06:42:26
2021-02-04T06:42:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,010
cpp
Segment Lazy Sum.cpp
// In Name Of God #include <bits/stdc++.h> #define IB std::ios::sync_with_stdio(0); #define forn(i,b) for(int i=0 ; i<b ; i++) #define endl "\n" #define all(x) x.begin(),x.end() #define pb push_back #define po pop_back #define F first #define S second using namespace std; typedef long long ll; typedef pair <int,int> pii; const int mod=1e9+7; const ll inf=1e18; const int maxn=1e5+10; const double eps=1e-7; const double pi=3.14159265359; int seg[maxn*4]; int lazy[maxn*4]; int a[maxn]; void build(int id,int l,int r) { if(l>r) { return; } if(l==r) { seg[id]=a[l]; return; } int mid=(l+r)/2; build(id*2,l,mid); build(id*2+1,mid+1,r); seg[id]=seg[id*2]+seg[id*2+1]; } void relax(int id,int l,int r) { if(l>r) { return; } if(lazy[id]!=0) { seg[id]+=lazy[id]; if(l!=r) { lazy[id*2]+=lazy[id]; lazy[id*2+1]+=lazy[id]; } lazy[id]=0; } } void update(int id,int l,int r,int s,int e,int val) { relax(id,l,r); if(l>r or l>e or r<s) { return; } if(l>=s and r<=e) { seg[id]+=val; if(l!=r) { lazy[id*2]+=val; lazy[id*2+1]+=val; } return; } int mid=(l+r)/2; update(id*2,l,mid,s,e,val); update(id*2+1,mid+1,r,s,e,val); seg[id]=seg[id*2]+seg[id*2+1]; } int query(int id,int l,int r,int s,int e) { if(l>r or l>e or r<s) { return 0; } relax(id,l,r); if(l>=s and r<=e) { return seg[id]; } int mid=(l+r)/2; int q1=query(id*2,l,mid,s,e); int q2=query(id*2+1,mid+1,r,s,e); int res=q1+q2; return res; } int main() { IB; cin.tie(0); cout.tie(0); int n; cin>>n; forn(i,n) { cin>>a[i]; } build(1,0,n-1); cout<<"ha"<<endl; cout<<query(1,0,n-1,0,2)<<endl; update(1,0,n-1,1,3,10); cout<<query(1,0,n-1,0,2); } //Written By Farhad Aman
5317953c163a6ffe9c3754d8a26b3cda5c06af21
38e0228a1daa76556c4b4166409fe35fc721b788
/OperatorOverloading/ComplexNumberTest.h
69b81e57e5f70650375988873897c3a2fc0fa871
[]
no_license
LukeChalkley/Complex_Number_Operator_Overloading
3e50240bd1f5dbdd08124841f8969a94018975fe
b6b49e073fbeb6e2929d4e21343f8d88af51f34a
refs/heads/master
2020-04-30T15:42:15.152286
2019-03-21T11:03:01
2019-03-21T11:03:01
176,926,889
0
0
null
null
null
null
UTF-8
C++
false
false
11,142
h
ComplexNumberTest.h
#pragma once #include "cxxtest/TestSuite.h" #include <iostream> #include "complex.h" class ComplexNumberTest : public CxxTest::TestSuite { public: void testAddition1(void) { /// (3+2i) + (1+7i) == 4+9i == 3 + 1 + (2+7)i std::cout << "Beginning addition tests." << std::endl; TS_TRACE("This test should PASS."); complex<int> lhs = complex<int>{ 3, 2 }; complex<int> rhs = complex<int>{ 1, 7 }; complex<int> expectedAnswer = complex<int>{ 4, 9 }; complex<int> actualAnswer = lhs + rhs; //std::cout << "\nExpected answer: " << lhs << " + " << rhs << " = " << expectedAnswer << std::endl; //std::cout << "Actual answer: " << lhs << " + " << rhs << " = " << actualAnswer << std::endl; TS_ASSERT(expectedAnswer == actualAnswer); } void testAddition2(void) { ///(3+5i) + (4-3i) == 7 + 2i == 3+4 + (5-3)i TS_TRACE("This test should PASS."); complex<int> lhs = complex<int>{ 3, 5 }; complex<int> rhs = complex<int>{ 4, -3 }; complex<int> expectedAnswer = complex<int>{ 7, 2 }; complex<int> actualAnswer = lhs + rhs; //std::cout << "Expected answer: " << lhs << " + " << rhs << " = " << expectedAnswer << std::endl; //std::cout << "Actual answer: " << lhs << " + " << rhs << " = " << actualAnswer << std::endl; TS_ASSERT(expectedAnswer == actualAnswer); } void testAddition3(void) { ///(3+5i) + (4-3i) == 7 + 2i == 3+4 + (5-3)i TS_TRACE("This test should PASS."); complex<int> lhs = complex<int>{ 1, 2 }; complex<int> rhs = complex<int>{ 3, 4 }; complex<int> expectedAnswer = complex<int>{ 4, 6 }; complex<int> actualAnswer = lhs + rhs; //std::cout << "Expected answer: " << lhs << " + " << rhs << " = " << expectedAnswer << std::endl; //std::cout << "Actual answer: " << lhs << " + " << rhs << " = " << actualAnswer << std::endl; TS_ASSERT(expectedAnswer == actualAnswer); } void testAdditionFail(void) { ///(3+5i) + (4-3i) == 7 + 2i == 3+4 + (5-3)i TS_TRACE("This test should FAIL."); complex<int> lhs = complex<int>{ 1, 2 }; complex<int> rhs = complex<int>{ 3, 4 }; complex<int> expectedAnswer = complex<int>{ 1, 1 }; complex<int> actualAnswer = lhs + rhs; //std::cout << "Expected answer: " << lhs << " + " << rhs << " = " << expectedAnswer << std::endl; //std::cout << "Actual answer: " << lhs << " + " << rhs << " = " << actualAnswer << std::endl; TS_ASSERT(expectedAnswer != actualAnswer); } void testSubtraction1(void) { std::cout << "Beginning subtraction tests." << std::endl; TS_TRACE("This test should PASS."); complex<int> lhs = complex<int>{ -9, -2 }; complex<int> rhs = complex<int>{ 2, 3 }; complex<int> expectedAnswer = complex<int>{ -11, -5 }; complex<int> actualAnswer = lhs - rhs; //std::cout << "Expected answer: " << lhs << " - " << rhs << " = " << expectedAnswer << std::endl; //std::cout << "Actual answer: " << lhs << " - " << rhs << " = " << actualAnswer << std::endl; TS_ASSERT(expectedAnswer == actualAnswer); } void testSubtraction2(void) { TS_TRACE("This test should PASS."); complex<int> lhs = complex<int>{ 8, -3 }; complex<int> rhs = complex<int>{ -6, 2 }; complex<int> expectedAnswer = complex<int>{ 14, -5 }; complex<int> actualAnswer = lhs - rhs; //std::cout << "Expected answer: " << lhs << " - " << rhs << " = " << expectedAnswer << std::endl; //std::cout << "Actual answer: " << lhs << " - " << rhs << " = " << actualAnswer << std::endl; TS_ASSERT(expectedAnswer == actualAnswer); } void testNegationBothPositive(void) { TS_TRACE("This test should PASS."); complex<int> number = complex<int>{ 2, 3 }; complex<int> expectedAnswer = complex<int>{ -2, -3 }; complex<int> actualAnswer = -number; //std::cout << "Expected answer: " << expectedAnswer << std::endl; //std::cout << "Actual answer: " << actualAnswer << std::endl; TS_ASSERT(expectedAnswer == actualAnswer); } void testNegationPosRealNegImag(void) { TS_TRACE("This test should PASS."); complex<int> number = complex<int>{ 2, -3 }; complex<int> expectedAnswer = complex<int>{ -2, 3 }; complex<int> actualAnswer = -number; //std::cout << "Expected answer: " << expectedAnswer << std::endl; //std::cout << "Actual answer: " << actualAnswer << std::endl; TS_ASSERT(expectedAnswer == actualAnswer); } void testNegationNegRealPosImag() { TS_TRACE("This test should PASS."); complex<int> number = complex<int>{ -2, 3 }; complex<int> expectedAnswer = complex<int>{ 2, -3 }; complex<int> actualAnswer = -number; //std::cout << "Expected answer: " << expectedAnswer << std::endl; //std::cout << "Actual answer: " << actualAnswer << std::endl; TS_ASSERT(expectedAnswer == actualAnswer); } void testNegationBothNegative(void) { TS_TRACE("This test should PASS."); complex<int> number = complex<int>{ -2, -3 }; complex<int> expectedAnswer = complex<int>{ 2, 3 }; complex<int> actualAnswer = -number; //std::cout << "Expected answer: " << expectedAnswer << std::endl; //std::cout << "Actual answer: " << actualAnswer << std::endl; TS_ASSERT(expectedAnswer == actualAnswer); } void testMultiplication() { std::cout << "Beginning multiplication tests." << std::endl; TS_TRACE("This test should PASS."); complex<int> lhs = complex<int>{ 3, 2 }; complex<int> rhs = complex<int>{ 1, 7 }; complex<int> expectedAnswer = complex<int>{ -11, 23 }; complex<int> actualAnswer = lhs * rhs; //std::cout << "Expected answer: " << lhs << " * " << rhs << " = " << expectedAnswer << std::endl; //std::cout << "Actual answer: " << lhs << " * " << rhs << " = " << actualAnswer << std::endl; TS_ASSERT(expectedAnswer == actualAnswer); } void testMultiplication2() { TS_TRACE("This test should PASS."); complex<int> lhs = complex<int>{ 1, 4 }; complex<int> rhs = complex<int>{ 5, 1 }; complex<int> expectedAnswer = complex<int>{ 1, 21 }; complex<int> actualAnswer = lhs * rhs; //std::cout << "Expected answer: " << lhs << " * " << rhs << " = " << expectedAnswer << std::endl; //std::cout << "Actual answer: " << lhs << " * " << rhs << " = " << actualAnswer << std::endl; TS_ASSERT(expectedAnswer == actualAnswer); } void testConjugate1() { std::cout << "Beginning conjugate tests." << std::endl; TS_TRACE("This test should PASS."); complex<int> number = complex<int>{ 3,2 }; complex<int> expectedAnswer = complex<int>(3, -2); complex<int> actualAnswer = number.get_conjugate(); //std::cout << "Conjugate of " << number << " should be " << expectedAnswer << std::endl; //std::cout << "Actual answer: " << actualAnswer << std::endl; TS_ASSERT(expectedAnswer == actualAnswer); } void testConjugate2() { TS_TRACE("This test should PASS."); complex<int> number = complex<int>{3,-2}; complex<int> expectedAnswer = complex<int>(3, 2); complex<int> actualAnswer = number.get_conjugate(); /* std::cout << "Conjugate of " << number << " should be " << expectedAnswer << std::endl; std::cout << "Actual answer: " << actualAnswer << std::endl;*/ TS_ASSERT(expectedAnswer == actualAnswer); } void testDivision() { std::cout << "Beginning division tests." << std::endl; TS_TRACE("This test should PASS."); complex<int> lhs = complex<int>{ 20, -4 }; complex<int> rhs = complex<int>{ 3, 2 }; complex<int> expectedAnswer = complex<int>{ 4, -4 }; complex<int> actualAnswer = lhs / rhs; std::cout << "Expected answer: " << lhs << " / " << rhs << " = " << expectedAnswer << std::endl; std::cout << "Actual answer: " << lhs << " / " << rhs << " = " << actualAnswer << std::endl; TS_ASSERT(expectedAnswer == actualAnswer); } void testDivision2() { TS_TRACE("This test should PASS."); complex<int> lhs = complex<int>{ 3, 2 }; complex<int> rhs = complex<int>{ 4, -3 }; complex<int> expectedAnswer = complex<int>{ 6/25, 17/25 }; complex<int> actualAnswer = lhs / rhs; std::cout << "Expected answer: " << lhs << " / " << rhs << " = " << expectedAnswer << std::endl; std::cout << "Actual answer: " << lhs << " / " << rhs << " = " << actualAnswer << std::endl; TS_ASSERT(expectedAnswer == actualAnswer); } void testDivision3() { TS_TRACE("This test should PASS."); complex<int> lhs = complex<int>{ 4, 5 }; complex<int> rhs = complex<int>{ 2, 6 }; complex<int> expectedAnswer = complex<int>{ 19/20, -7/20 }; complex<int> actualAnswer = lhs / rhs; std::cout << "Expected answer: " << lhs << " / " << rhs << " = " << expectedAnswer << std::endl; std::cout << "Actual answer: " << lhs << " / " << rhs << " = " << actualAnswer << std::endl; TS_ASSERT(expectedAnswer == actualAnswer); } void testDivision4() { TS_TRACE("This test should PASS."); complex<int> lhs = complex<int>{ 4, 7 }; complex<int> rhs = complex<int>{ 1, -3 }; complex<int> expectedAnswer = complex<int>{ -17/10, 19/10 }; complex<int> actualAnswer = lhs / rhs; std::cout << "Expected answer: " << lhs << " / " << rhs << " = " << expectedAnswer << std::endl; std::cout << "Actual answer: " << lhs << " / " << rhs << " = " << actualAnswer << std::endl; TS_ASSERT(expectedAnswer == actualAnswer); } void testDivision5() { TS_TRACE("This test should PASS."); complex<int> lhs = complex<int>{ 2, -5 }; complex<int> rhs = complex<int>{ -4, 3 }; complex<int> expectedAnswer = complex<int>{ -23/25, 14/25 }; complex<int> actualAnswer = lhs / rhs; std::cout << "Expected answer: " << lhs << " / " << rhs << " = " << expectedAnswer << std::endl; std::cout << "Actual answer: " << lhs << " / " << rhs << " = " << actualAnswer << std::endl; TS_ASSERT(expectedAnswer == actualAnswer); } void testDivision6() { TS_TRACE("This test should PASS."); complex<int> lhs = complex<int>{ 2, -1 }; complex<int> rhs = complex<int>{ -3, 6 }; complex<int> expectedAnswer = complex<int>{ -4/15, -1/5 }; complex<int> actualAnswer = lhs / rhs; std::cout << "Expected answer: " << lhs << " / " << rhs << " = " << expectedAnswer << std::endl; std::cout << "Actual answer: " << lhs << " / " << rhs << " = " << actualAnswer << std::endl; TS_ASSERT(expectedAnswer == actualAnswer); } void testDivision7() { TS_TRACE("This test should PASS."); complex<int> lhs = complex<int>{ 4, 5 }; complex<int> rhs = complex<int>{ 2, 6 }; complex<int> expectedAnswer = complex<int>{ 19/20, -7/20 }; complex<int> actualAnswer = lhs / rhs; std::cout << "Expected answer: " << lhs << " / " << rhs << " = " << expectedAnswer << std::endl; std::cout << "Actual answer: " << lhs << " / " << rhs << " = " << actualAnswer << std::endl; TS_ASSERT(expectedAnswer == actualAnswer); } void testDivision8() { TS_TRACE("This test should PASS."); complex<int> lhs = complex<int>{ -6, -3 }; complex<int> rhs = complex<int>{ 4, 6 }; complex<int> expectedAnswer = complex<int>{ -21 / 26, 6/13 }; complex<int> actualAnswer = lhs / rhs; std::cout << "Expected answer: " << lhs << " / " << rhs << " = " << expectedAnswer << std::endl; std::cout << "Actual answer: " << lhs << " / " << rhs << " = " << actualAnswer << std::endl; TS_ASSERT(expectedAnswer == actualAnswer); } };
b2dced042ca031f2fe1b504fa61bc82bf5d10a44
7a5dce836d3467e702dca8e30eb2fe7256ed922d
/C Programs/charsi.cpp
a90c712ebb8750c77d071eb7b0db331f2c167289
[]
no_license
anubhav23sept/My-Spoj-Submissions
9605358b13899ef74ad0445012ac3c44205f1497
eb906538a9242d3cf19ce42956bee931a12639df
refs/heads/master
2021-01-22T05:33:39.978362
2017-02-11T19:07:11
2017-02-11T19:07:11
81,674,854
0
0
null
null
null
null
UTF-8
C++
false
false
1,332
cpp
charsi.cpp
/* Anubhav Singh MNNIT Allahabad CSE */ #include<bits/stdc++.h> using namespace std; int arr[1000004],arr2[1000004]; void seive() { int i,j,k=0;; arr[1]=1; for(i=2;i<=1000004;++i) { if(!arr[i]) { arr2[k++]=i; j=2; while(j*i<=1000004) { arr[j*i]=1; ++j; } } } } int main() { long long ans[100004]={0},fac[100004]; int i; long long j,k; long long l,r; double p; seive(); // cout<<"a"; scanf("%lld %lld %lf",&l,&r,&p); int l1=sqrt(r); for(i=0;i<=r-l;++i) fac[i]=i+l; i=0; while(arr2[i]<=l1) { //cout<<arr2[i]<<endl; k=l; if(l%arr2[i]==0) k-=arr2[i]; for(j=k+(arr2[i]-(l%arr2[i]));j<=r;j+=arr2[i]) { if(arr2[i]>sqrt(j)) continue; //cout<<fac[j-l]<<" "<<arr2[i]<<endl; while((fac[j-l]%arr2[i])==0) { fac[j-l]/=arr2[i]; ans[j-l]++; // cout<<fac[j-l]<<" "<<arr2[i]<<endl; } } i++; } k=0,j=0; for(i=0;i<=r-l;++i) { if(ans[i]!=0) { k++; if(fac[i]!=1) j+=(ans[i]+1); else j+=ans[i]; } } double a; if(k!=0) a=p+(((double)j/k)*(1-p)); else a=p; printf("%lf",a); return 0; }
17f840cb0e37baa14448c28e0f3d69616a0918d7
6f04bfa59fd4e9bbc5281a85e7b250f2e2a2939a
/util.hh
be4a49958368fb0dbc6d398cb39a653c93482c80
[]
no_license
rgrr/vsoup
00e83068e1d49608d72889e171f2ea8fe2a9be04
5a8f084323465bfc3b6334d8993feb9cb1ae3d30
refs/heads/master
2021-02-09T17:45:16.697522
2020-03-02T07:43:03
2020-03-02T07:43:03
244,308,925
0
0
null
null
null
null
UTF-8
C++
false
false
894
hh
util.hh
// $Id: util.hh 1.14 1999/08/29 12:58:41 Hardy Exp Hardy $ // // This progam/module was written by Hardy Griech based on ideas and // pieces of code from Chin Huang (cthuang@io.org). Bug reports should // be submitted to rgriech@swol.de. // // This file is part of VSoup for OS/2. VSoup including this file // is freeware. There is no warranty of any kind implied. The terms // of the GNU Gernal Public Licence are valid for this piece of software. // // NNTP client routines // #ifndef __UTIL_HH__ #define __UTIL_HH__ #include <rgfile.hh> const char *getHeader( TFile &handle, const char *header ); unsigned hashi( const char *src, unsigned tabSize ); int nhandles( int depth=0 ); const char *extractAddress( const char *src ); char *findAddressSep( const char *src ); int isHeader( const char *buf, const char *header ); void urlDecode( char *s ); #endif // __UTIL_HH__