blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 3
264
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
85
| license_type
stringclasses 2
values | repo_name
stringlengths 5
140
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 905
values | visit_date
timestamp[us]date 2015-08-09 11:21:18
2023-09-06 10:45:07
| revision_date
timestamp[us]date 1997-09-14 05:04:47
2023-09-17 19:19:19
| committer_date
timestamp[us]date 1997-09-14 05:04:47
2023-09-06 06:22:19
| github_id
int64 3.89k
681M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us]date 2012-06-07 00:51:45
2023-09-14 21:58:39
⌀ | gha_created_at
timestamp[us]date 2008-03-27 23:40:48
2023-08-21 23:17:38
⌀ | gha_language
stringclasses 141
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
10.4M
| extension
stringclasses 115
values | content
stringlengths 3
10.4M
| authors
listlengths 1
1
| author_id
stringlengths 0
158
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
71501d38877dbe1af7273594bc7200704708884c
|
c8b39acfd4a857dc15ed3375e0d93e75fa3f1f64
|
/Engine/Source/ThirdParty/llvm/3.6.2/include/clang/AST/Comment.h
|
94470cbf305f6d9603b988c50738e9eb201963fe
|
[
"MIT",
"LicenseRef-scancode-proprietary-license"
] |
permissive
|
windystrife/UnrealEngine_NVIDIAGameWorks
|
c3c7863083653caf1bc67d3ef104fb4b9f302e2a
|
b50e6338a7c5b26374d66306ebc7807541ff815e
|
refs/heads/4.18-GameWorks
| 2023-03-11T02:50:08.471040
| 2022-01-13T20:50:29
| 2022-01-13T20:50:29
| 124,100,479
| 262
| 179
|
MIT
| 2022-12-16T05:36:38
| 2018-03-06T15:44:09
|
C++
|
UTF-8
|
C++
| false
| false
| 31,883
|
h
|
//===--- Comment.h - Comment AST nodes --------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines comment AST nodes.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_AST_COMMENT_H
#define LLVM_CLANG_AST_COMMENT_H
#include "clang/AST/CommentCommandTraits.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/Type.h"
#include "clang/Basic/SourceLocation.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
namespace clang {
class Decl;
class ParmVarDecl;
class TemplateParameterList;
namespace comments {
class FullComment;
/// Describes the syntax that was used in a documentation command.
///
/// Exact values of this enumeration are important because they used to select
/// parts of diagnostic messages. Audit diagnostics before changing or adding
/// a new value.
enum CommandMarkerKind {
/// Command started with a backslash character:
/// \code
/// \foo
/// \endcode
CMK_Backslash = 0,
/// Command started with an 'at' character:
/// \code
/// @foo
/// \endcode
CMK_At = 1
};
/// Any part of the comment.
/// Abstract class.
class Comment {
protected:
/// Preferred location to show caret.
SourceLocation Loc;
/// Source range of this AST node.
SourceRange Range;
class CommentBitfields {
friend class Comment;
/// Type of this AST node.
unsigned Kind : 8;
};
enum { NumCommentBits = 8 };
class InlineContentCommentBitfields {
friend class InlineContentComment;
unsigned : NumCommentBits;
/// True if there is a newline after this inline content node.
/// (There is no separate AST node for a newline.)
unsigned HasTrailingNewline : 1;
};
enum { NumInlineContentCommentBits = NumCommentBits + 1 };
class TextCommentBitfields {
friend class TextComment;
unsigned : NumInlineContentCommentBits;
/// True if \c IsWhitespace field contains a valid value.
mutable unsigned IsWhitespaceValid : 1;
/// True if this comment AST node contains only whitespace.
mutable unsigned IsWhitespace : 1;
};
enum { NumTextCommentBits = NumInlineContentCommentBits + 2 };
class InlineCommandCommentBitfields {
friend class InlineCommandComment;
unsigned : NumInlineContentCommentBits;
unsigned RenderKind : 2;
unsigned CommandID : CommandInfo::NumCommandIDBits;
};
enum { NumInlineCommandCommentBits = NumInlineContentCommentBits + 2 +
CommandInfo::NumCommandIDBits };
class HTMLTagCommentBitfields {
friend class HTMLTagComment;
unsigned : NumInlineContentCommentBits;
/// True if we found that this tag is malformed in some way.
unsigned IsMalformed : 1;
};
enum { NumHTMLTagCommentBits = NumInlineContentCommentBits + 1 };
class HTMLStartTagCommentBitfields {
friend class HTMLStartTagComment;
unsigned : NumHTMLTagCommentBits;
/// True if this tag is self-closing (e. g., <br />). This is based on tag
/// spelling in comment (plain <br> would not set this flag).
unsigned IsSelfClosing : 1;
};
enum { NumHTMLStartTagCommentBits = NumHTMLTagCommentBits + 1 };
class ParagraphCommentBitfields {
friend class ParagraphComment;
unsigned : NumCommentBits;
/// True if \c IsWhitespace field contains a valid value.
mutable unsigned IsWhitespaceValid : 1;
/// True if this comment AST node contains only whitespace.
mutable unsigned IsWhitespace : 1;
};
enum { NumParagraphCommentBits = NumCommentBits + 2 };
class BlockCommandCommentBitfields {
friend class BlockCommandComment;
unsigned : NumCommentBits;
unsigned CommandID : CommandInfo::NumCommandIDBits;
/// Describes the syntax that was used in a documentation command.
/// Contains values from CommandMarkerKind enum.
unsigned CommandMarker : 1;
};
enum { NumBlockCommandCommentBits = NumCommentBits +
CommandInfo::NumCommandIDBits + 1 };
class ParamCommandCommentBitfields {
friend class ParamCommandComment;
unsigned : NumBlockCommandCommentBits;
/// Parameter passing direction, see ParamCommandComment::PassDirection.
unsigned Direction : 2;
/// True if direction was specified explicitly in the comment.
unsigned IsDirectionExplicit : 1;
};
enum { NumParamCommandCommentBits = NumBlockCommandCommentBits + 3 };
union {
CommentBitfields CommentBits;
InlineContentCommentBitfields InlineContentCommentBits;
TextCommentBitfields TextCommentBits;
InlineCommandCommentBitfields InlineCommandCommentBits;
HTMLTagCommentBitfields HTMLTagCommentBits;
HTMLStartTagCommentBitfields HTMLStartTagCommentBits;
ParagraphCommentBitfields ParagraphCommentBits;
BlockCommandCommentBitfields BlockCommandCommentBits;
ParamCommandCommentBitfields ParamCommandCommentBits;
};
void setSourceRange(SourceRange SR) {
Range = SR;
}
void setLocation(SourceLocation L) {
Loc = L;
}
public:
enum CommentKind {
NoCommentKind = 0,
#define COMMENT(CLASS, PARENT) CLASS##Kind,
#define COMMENT_RANGE(BASE, FIRST, LAST) \
First##BASE##Constant=FIRST##Kind, Last##BASE##Constant=LAST##Kind,
#define LAST_COMMENT_RANGE(BASE, FIRST, LAST) \
First##BASE##Constant=FIRST##Kind, Last##BASE##Constant=LAST##Kind
#define ABSTRACT_COMMENT(COMMENT)
#include "clang/AST/CommentNodes.inc"
};
Comment(CommentKind K,
SourceLocation LocBegin,
SourceLocation LocEnd) :
Loc(LocBegin), Range(SourceRange(LocBegin, LocEnd)) {
CommentBits.Kind = K;
}
CommentKind getCommentKind() const {
return static_cast<CommentKind>(CommentBits.Kind);
}
const char *getCommentKindName() const;
void dump() const;
void dumpColor() const;
void dump(const ASTContext &Context) const;
void dump(raw_ostream &OS, const CommandTraits *Traits,
const SourceManager *SM) const;
SourceRange getSourceRange() const LLVM_READONLY { return Range; }
SourceLocation getLocStart() const LLVM_READONLY {
return Range.getBegin();
}
SourceLocation getLocEnd() const LLVM_READONLY {
return Range.getEnd();
}
SourceLocation getLocation() const LLVM_READONLY { return Loc; }
typedef Comment * const *child_iterator;
child_iterator child_begin() const;
child_iterator child_end() const;
// TODO: const child iterator
unsigned child_count() const {
return child_end() - child_begin();
}
};
/// Inline content (contained within a block).
/// Abstract class.
class InlineContentComment : public Comment {
protected:
InlineContentComment(CommentKind K,
SourceLocation LocBegin,
SourceLocation LocEnd) :
Comment(K, LocBegin, LocEnd) {
InlineContentCommentBits.HasTrailingNewline = 0;
}
public:
static bool classof(const Comment *C) {
return C->getCommentKind() >= FirstInlineContentCommentConstant &&
C->getCommentKind() <= LastInlineContentCommentConstant;
}
void addTrailingNewline() {
InlineContentCommentBits.HasTrailingNewline = 1;
}
bool hasTrailingNewline() const {
return InlineContentCommentBits.HasTrailingNewline;
}
};
/// Plain text.
class TextComment : public InlineContentComment {
StringRef Text;
public:
TextComment(SourceLocation LocBegin,
SourceLocation LocEnd,
StringRef Text) :
InlineContentComment(TextCommentKind, LocBegin, LocEnd),
Text(Text) {
TextCommentBits.IsWhitespaceValid = false;
}
static bool classof(const Comment *C) {
return C->getCommentKind() == TextCommentKind;
}
child_iterator child_begin() const { return nullptr; }
child_iterator child_end() const { return nullptr; }
StringRef getText() const LLVM_READONLY { return Text; }
bool isWhitespace() const {
if (TextCommentBits.IsWhitespaceValid)
return TextCommentBits.IsWhitespace;
TextCommentBits.IsWhitespace = isWhitespaceNoCache();
TextCommentBits.IsWhitespaceValid = true;
return TextCommentBits.IsWhitespace;
}
private:
bool isWhitespaceNoCache() const;
};
/// A command with word-like arguments that is considered inline content.
class InlineCommandComment : public InlineContentComment {
public:
struct Argument {
SourceRange Range;
StringRef Text;
Argument(SourceRange Range, StringRef Text) : Range(Range), Text(Text) { }
};
/// The most appropriate rendering mode for this command, chosen on command
/// semantics in Doxygen.
enum RenderKind {
RenderNormal,
RenderBold,
RenderMonospaced,
RenderEmphasized
};
protected:
/// Command arguments.
ArrayRef<Argument> Args;
public:
InlineCommandComment(SourceLocation LocBegin,
SourceLocation LocEnd,
unsigned CommandID,
RenderKind RK,
ArrayRef<Argument> Args) :
InlineContentComment(InlineCommandCommentKind, LocBegin, LocEnd),
Args(Args) {
InlineCommandCommentBits.RenderKind = RK;
InlineCommandCommentBits.CommandID = CommandID;
}
static bool classof(const Comment *C) {
return C->getCommentKind() == InlineCommandCommentKind;
}
child_iterator child_begin() const { return nullptr; }
child_iterator child_end() const { return nullptr; }
unsigned getCommandID() const {
return InlineCommandCommentBits.CommandID;
}
StringRef getCommandName(const CommandTraits &Traits) const {
return Traits.getCommandInfo(getCommandID())->Name;
}
SourceRange getCommandNameRange() const {
return SourceRange(getLocStart().getLocWithOffset(-1),
getLocEnd());
}
RenderKind getRenderKind() const {
return static_cast<RenderKind>(InlineCommandCommentBits.RenderKind);
}
unsigned getNumArgs() const {
return Args.size();
}
StringRef getArgText(unsigned Idx) const {
return Args[Idx].Text;
}
SourceRange getArgRange(unsigned Idx) const {
return Args[Idx].Range;
}
};
/// Abstract class for opening and closing HTML tags. HTML tags are always
/// treated as inline content (regardless HTML semantics).
class HTMLTagComment : public InlineContentComment {
protected:
StringRef TagName;
SourceRange TagNameRange;
HTMLTagComment(CommentKind K,
SourceLocation LocBegin,
SourceLocation LocEnd,
StringRef TagName,
SourceLocation TagNameBegin,
SourceLocation TagNameEnd) :
InlineContentComment(K, LocBegin, LocEnd),
TagName(TagName),
TagNameRange(TagNameBegin, TagNameEnd) {
setLocation(TagNameBegin);
HTMLTagCommentBits.IsMalformed = 0;
}
public:
static bool classof(const Comment *C) {
return C->getCommentKind() >= FirstHTMLTagCommentConstant &&
C->getCommentKind() <= LastHTMLTagCommentConstant;
}
StringRef getTagName() const LLVM_READONLY { return TagName; }
SourceRange getTagNameSourceRange() const LLVM_READONLY {
SourceLocation L = getLocation();
return SourceRange(L.getLocWithOffset(1),
L.getLocWithOffset(1 + TagName.size()));
}
bool isMalformed() const {
return HTMLTagCommentBits.IsMalformed;
}
void setIsMalformed() {
HTMLTagCommentBits.IsMalformed = 1;
}
};
/// An opening HTML tag with attributes.
class HTMLStartTagComment : public HTMLTagComment {
public:
class Attribute {
public:
SourceLocation NameLocBegin;
StringRef Name;
SourceLocation EqualsLoc;
SourceRange ValueRange;
StringRef Value;
Attribute() { }
Attribute(SourceLocation NameLocBegin, StringRef Name) :
NameLocBegin(NameLocBegin), Name(Name),
EqualsLoc(SourceLocation()),
ValueRange(SourceRange()), Value(StringRef())
{ }
Attribute(SourceLocation NameLocBegin, StringRef Name,
SourceLocation EqualsLoc,
SourceRange ValueRange, StringRef Value) :
NameLocBegin(NameLocBegin), Name(Name),
EqualsLoc(EqualsLoc),
ValueRange(ValueRange), Value(Value)
{ }
SourceLocation getNameLocEnd() const {
return NameLocBegin.getLocWithOffset(Name.size());
}
SourceRange getNameRange() const {
return SourceRange(NameLocBegin, getNameLocEnd());
}
};
private:
ArrayRef<Attribute> Attributes;
public:
HTMLStartTagComment(SourceLocation LocBegin,
StringRef TagName) :
HTMLTagComment(HTMLStartTagCommentKind,
LocBegin, LocBegin.getLocWithOffset(1 + TagName.size()),
TagName,
LocBegin.getLocWithOffset(1),
LocBegin.getLocWithOffset(1 + TagName.size())) {
HTMLStartTagCommentBits.IsSelfClosing = false;
}
static bool classof(const Comment *C) {
return C->getCommentKind() == HTMLStartTagCommentKind;
}
child_iterator child_begin() const { return nullptr; }
child_iterator child_end() const { return nullptr; }
unsigned getNumAttrs() const {
return Attributes.size();
}
const Attribute &getAttr(unsigned Idx) const {
return Attributes[Idx];
}
void setAttrs(ArrayRef<Attribute> Attrs) {
Attributes = Attrs;
if (!Attrs.empty()) {
const Attribute &Attr = Attrs.back();
SourceLocation L = Attr.ValueRange.getEnd();
if (L.isValid())
Range.setEnd(L);
else {
Range.setEnd(Attr.getNameLocEnd());
}
}
}
void setGreaterLoc(SourceLocation GreaterLoc) {
Range.setEnd(GreaterLoc);
}
bool isSelfClosing() const {
return HTMLStartTagCommentBits.IsSelfClosing;
}
void setSelfClosing() {
HTMLStartTagCommentBits.IsSelfClosing = true;
}
};
/// A closing HTML tag.
class HTMLEndTagComment : public HTMLTagComment {
public:
HTMLEndTagComment(SourceLocation LocBegin,
SourceLocation LocEnd,
StringRef TagName) :
HTMLTagComment(HTMLEndTagCommentKind,
LocBegin, LocEnd,
TagName,
LocBegin.getLocWithOffset(2),
LocBegin.getLocWithOffset(2 + TagName.size()))
{ }
static bool classof(const Comment *C) {
return C->getCommentKind() == HTMLEndTagCommentKind;
}
child_iterator child_begin() const { return nullptr; }
child_iterator child_end() const { return nullptr; }
};
/// Block content (contains inline content).
/// Abstract class.
class BlockContentComment : public Comment {
protected:
BlockContentComment(CommentKind K,
SourceLocation LocBegin,
SourceLocation LocEnd) :
Comment(K, LocBegin, LocEnd)
{ }
public:
static bool classof(const Comment *C) {
return C->getCommentKind() >= FirstBlockContentCommentConstant &&
C->getCommentKind() <= LastBlockContentCommentConstant;
}
};
/// A single paragraph that contains inline content.
class ParagraphComment : public BlockContentComment {
ArrayRef<InlineContentComment *> Content;
public:
ParagraphComment(ArrayRef<InlineContentComment *> Content) :
BlockContentComment(ParagraphCommentKind,
SourceLocation(),
SourceLocation()),
Content(Content) {
if (Content.empty()) {
ParagraphCommentBits.IsWhitespace = true;
ParagraphCommentBits.IsWhitespaceValid = true;
return;
}
ParagraphCommentBits.IsWhitespaceValid = false;
setSourceRange(SourceRange(Content.front()->getLocStart(),
Content.back()->getLocEnd()));
setLocation(Content.front()->getLocStart());
}
static bool classof(const Comment *C) {
return C->getCommentKind() == ParagraphCommentKind;
}
child_iterator child_begin() const {
return reinterpret_cast<child_iterator>(Content.begin());
}
child_iterator child_end() const {
return reinterpret_cast<child_iterator>(Content.end());
}
bool isWhitespace() const {
if (ParagraphCommentBits.IsWhitespaceValid)
return ParagraphCommentBits.IsWhitespace;
ParagraphCommentBits.IsWhitespace = isWhitespaceNoCache();
ParagraphCommentBits.IsWhitespaceValid = true;
return ParagraphCommentBits.IsWhitespace;
}
private:
bool isWhitespaceNoCache() const;
};
/// A command that has zero or more word-like arguments (number of word-like
/// arguments depends on command name) and a paragraph as an argument
/// (e. g., \\brief).
class BlockCommandComment : public BlockContentComment {
public:
struct Argument {
SourceRange Range;
StringRef Text;
Argument() { }
Argument(SourceRange Range, StringRef Text) : Range(Range), Text(Text) { }
};
protected:
/// Word-like arguments.
ArrayRef<Argument> Args;
/// Paragraph argument.
ParagraphComment *Paragraph;
BlockCommandComment(CommentKind K,
SourceLocation LocBegin,
SourceLocation LocEnd,
unsigned CommandID,
CommandMarkerKind CommandMarker) :
BlockContentComment(K, LocBegin, LocEnd),
Paragraph(nullptr) {
setLocation(getCommandNameBeginLoc());
BlockCommandCommentBits.CommandID = CommandID;
BlockCommandCommentBits.CommandMarker = CommandMarker;
}
public:
BlockCommandComment(SourceLocation LocBegin,
SourceLocation LocEnd,
unsigned CommandID,
CommandMarkerKind CommandMarker) :
BlockContentComment(BlockCommandCommentKind, LocBegin, LocEnd),
Paragraph(nullptr) {
setLocation(getCommandNameBeginLoc());
BlockCommandCommentBits.CommandID = CommandID;
BlockCommandCommentBits.CommandMarker = CommandMarker;
}
static bool classof(const Comment *C) {
return C->getCommentKind() >= FirstBlockCommandCommentConstant &&
C->getCommentKind() <= LastBlockCommandCommentConstant;
}
child_iterator child_begin() const {
return reinterpret_cast<child_iterator>(&Paragraph);
}
child_iterator child_end() const {
return reinterpret_cast<child_iterator>(&Paragraph + 1);
}
unsigned getCommandID() const {
return BlockCommandCommentBits.CommandID;
}
StringRef getCommandName(const CommandTraits &Traits) const {
return Traits.getCommandInfo(getCommandID())->Name;
}
SourceLocation getCommandNameBeginLoc() const {
return getLocStart().getLocWithOffset(1);
}
SourceRange getCommandNameRange(const CommandTraits &Traits) const {
StringRef Name = getCommandName(Traits);
return SourceRange(getCommandNameBeginLoc(),
getLocStart().getLocWithOffset(1 + Name.size()));
}
unsigned getNumArgs() const {
return Args.size();
}
StringRef getArgText(unsigned Idx) const {
return Args[Idx].Text;
}
SourceRange getArgRange(unsigned Idx) const {
return Args[Idx].Range;
}
void setArgs(ArrayRef<Argument> A) {
Args = A;
if (Args.size() > 0) {
SourceLocation NewLocEnd = Args.back().Range.getEnd();
if (NewLocEnd.isValid())
setSourceRange(SourceRange(getLocStart(), NewLocEnd));
}
}
ParagraphComment *getParagraph() const LLVM_READONLY {
return Paragraph;
}
bool hasNonWhitespaceParagraph() const {
return Paragraph && !Paragraph->isWhitespace();
}
void setParagraph(ParagraphComment *PC) {
Paragraph = PC;
SourceLocation NewLocEnd = PC->getLocEnd();
if (NewLocEnd.isValid())
setSourceRange(SourceRange(getLocStart(), NewLocEnd));
}
CommandMarkerKind getCommandMarker() const LLVM_READONLY {
return static_cast<CommandMarkerKind>(
BlockCommandCommentBits.CommandMarker);
}
};
/// Doxygen \\param command.
class ParamCommandComment : public BlockCommandComment {
private:
/// Parameter index in the function declaration.
unsigned ParamIndex;
public:
enum : unsigned {
InvalidParamIndex = ~0U,
VarArgParamIndex = ~0U/*InvalidParamIndex*/ - 1U
};
ParamCommandComment(SourceLocation LocBegin,
SourceLocation LocEnd,
unsigned CommandID,
CommandMarkerKind CommandMarker) :
BlockCommandComment(ParamCommandCommentKind, LocBegin, LocEnd,
CommandID, CommandMarker),
ParamIndex(InvalidParamIndex) {
ParamCommandCommentBits.Direction = In;
ParamCommandCommentBits.IsDirectionExplicit = false;
}
static bool classof(const Comment *C) {
return C->getCommentKind() == ParamCommandCommentKind;
}
enum PassDirection {
In,
Out,
InOut
};
static const char *getDirectionAsString(PassDirection D);
PassDirection getDirection() const LLVM_READONLY {
return static_cast<PassDirection>(ParamCommandCommentBits.Direction);
}
bool isDirectionExplicit() const LLVM_READONLY {
return ParamCommandCommentBits.IsDirectionExplicit;
}
void setDirection(PassDirection Direction, bool Explicit) {
ParamCommandCommentBits.Direction = Direction;
ParamCommandCommentBits.IsDirectionExplicit = Explicit;
}
bool hasParamName() const {
return getNumArgs() > 0;
}
StringRef getParamName(const FullComment *FC) const;
StringRef getParamNameAsWritten() const {
return Args[0].Text;
}
SourceRange getParamNameRange() const {
return Args[0].Range;
}
bool isParamIndexValid() const LLVM_READONLY {
return ParamIndex != InvalidParamIndex;
}
bool isVarArgParam() const LLVM_READONLY {
return ParamIndex == VarArgParamIndex;
}
void setIsVarArgParam() {
ParamIndex = VarArgParamIndex;
assert(isParamIndexValid());
}
unsigned getParamIndex() const LLVM_READONLY {
assert(isParamIndexValid());
assert(!isVarArgParam());
return ParamIndex;
}
void setParamIndex(unsigned Index) {
ParamIndex = Index;
assert(isParamIndexValid());
assert(!isVarArgParam());
}
};
/// Doxygen \\tparam command, describes a template parameter.
class TParamCommandComment : public BlockCommandComment {
private:
/// If this template parameter name was resolved (found in template parameter
/// list), then this stores a list of position indexes in all template
/// parameter lists.
///
/// For example:
/// \verbatim
/// template<typename C, template<typename T> class TT>
/// void test(TT<int> aaa);
/// \endverbatim
/// For C: Position = { 0 }
/// For TT: Position = { 1 }
/// For T: Position = { 1, 0 }
ArrayRef<unsigned> Position;
public:
TParamCommandComment(SourceLocation LocBegin,
SourceLocation LocEnd,
unsigned CommandID,
CommandMarkerKind CommandMarker) :
BlockCommandComment(TParamCommandCommentKind, LocBegin, LocEnd, CommandID,
CommandMarker)
{ }
static bool classof(const Comment *C) {
return C->getCommentKind() == TParamCommandCommentKind;
}
bool hasParamName() const {
return getNumArgs() > 0;
}
StringRef getParamName(const FullComment *FC) const;
StringRef getParamNameAsWritten() const {
return Args[0].Text;
}
SourceRange getParamNameRange() const {
return Args[0].Range;
}
bool isPositionValid() const LLVM_READONLY {
return !Position.empty();
}
unsigned getDepth() const {
assert(isPositionValid());
return Position.size();
}
unsigned getIndex(unsigned Depth) const {
assert(isPositionValid());
return Position[Depth];
}
void setPosition(ArrayRef<unsigned> NewPosition) {
Position = NewPosition;
assert(isPositionValid());
}
};
/// A line of text contained in a verbatim block.
class VerbatimBlockLineComment : public Comment {
StringRef Text;
public:
VerbatimBlockLineComment(SourceLocation LocBegin,
StringRef Text) :
Comment(VerbatimBlockLineCommentKind,
LocBegin,
LocBegin.getLocWithOffset(Text.size())),
Text(Text)
{ }
static bool classof(const Comment *C) {
return C->getCommentKind() == VerbatimBlockLineCommentKind;
}
child_iterator child_begin() const { return nullptr; }
child_iterator child_end() const { return nullptr; }
StringRef getText() const LLVM_READONLY {
return Text;
}
};
/// A verbatim block command (e. g., preformatted code). Verbatim block has an
/// opening and a closing command and contains multiple lines of text
/// (VerbatimBlockLineComment nodes).
class VerbatimBlockComment : public BlockCommandComment {
protected:
StringRef CloseName;
SourceLocation CloseNameLocBegin;
ArrayRef<VerbatimBlockLineComment *> Lines;
public:
VerbatimBlockComment(SourceLocation LocBegin,
SourceLocation LocEnd,
unsigned CommandID) :
BlockCommandComment(VerbatimBlockCommentKind,
LocBegin, LocEnd, CommandID,
CMK_At) // FIXME: improve source fidelity.
{ }
static bool classof(const Comment *C) {
return C->getCommentKind() == VerbatimBlockCommentKind;
}
child_iterator child_begin() const {
return reinterpret_cast<child_iterator>(Lines.begin());
}
child_iterator child_end() const {
return reinterpret_cast<child_iterator>(Lines.end());
}
void setCloseName(StringRef Name, SourceLocation LocBegin) {
CloseName = Name;
CloseNameLocBegin = LocBegin;
}
void setLines(ArrayRef<VerbatimBlockLineComment *> L) {
Lines = L;
}
StringRef getCloseName() const {
return CloseName;
}
unsigned getNumLines() const {
return Lines.size();
}
StringRef getText(unsigned LineIdx) const {
return Lines[LineIdx]->getText();
}
};
/// A verbatim line command. Verbatim line has an opening command, a single
/// line of text (up to the newline after the opening command) and has no
/// closing command.
class VerbatimLineComment : public BlockCommandComment {
protected:
StringRef Text;
SourceLocation TextBegin;
public:
VerbatimLineComment(SourceLocation LocBegin,
SourceLocation LocEnd,
unsigned CommandID,
SourceLocation TextBegin,
StringRef Text) :
BlockCommandComment(VerbatimLineCommentKind,
LocBegin, LocEnd,
CommandID,
CMK_At), // FIXME: improve source fidelity.
Text(Text),
TextBegin(TextBegin)
{ }
static bool classof(const Comment *C) {
return C->getCommentKind() == VerbatimLineCommentKind;
}
child_iterator child_begin() const { return nullptr; }
child_iterator child_end() const { return nullptr; }
StringRef getText() const {
return Text;
}
SourceRange getTextRange() const {
return SourceRange(TextBegin, getLocEnd());
}
};
/// Information about the declaration, useful to clients of FullComment.
struct DeclInfo {
/// Declaration the comment is actually attached to (in the source).
/// Should not be NULL.
const Decl *CommentDecl;
/// CurrentDecl is the declaration with which the FullComment is associated.
///
/// It can be different from \c CommentDecl. It happens when we we decide
/// that the comment originally attached to \c CommentDecl is fine for
/// \c CurrentDecl too (for example, for a redeclaration or an overrider of
/// \c CommentDecl).
///
/// The information in the DeclInfo corresponds to CurrentDecl.
const Decl *CurrentDecl;
/// Parameters that can be referenced by \\param if \c CommentDecl is something
/// that we consider a "function".
ArrayRef<const ParmVarDecl *> ParamVars;
/// Function return type if \c CommentDecl is something that we consider
/// a "function".
QualType ReturnType;
/// Template parameters that can be referenced by \\tparam if \c CommentDecl is
/// a template (\c IsTemplateDecl or \c IsTemplatePartialSpecialization is
/// true).
const TemplateParameterList *TemplateParameters;
/// A simplified description of \c CommentDecl kind that should be good enough
/// for documentation rendering purposes.
enum DeclKind {
/// Everything else not explicitly mentioned below.
OtherKind,
/// Something that we consider a "function":
/// \li function,
/// \li function template,
/// \li function template specialization,
/// \li member function,
/// \li member function template,
/// \li member function template specialization,
/// \li ObjC method,
/// \li a typedef for a function pointer, member function pointer,
/// ObjC block.
FunctionKind,
/// Something that we consider a "class":
/// \li class/struct,
/// \li class template,
/// \li class template (partial) specialization.
ClassKind,
/// Something that we consider a "variable":
/// \li namespace scope variables;
/// \li static and non-static class data members;
/// \li enumerators.
VariableKind,
/// A C++ namespace.
NamespaceKind,
/// A C++ typedef-name (a 'typedef' decl specifier or alias-declaration),
/// see \c TypedefNameDecl.
TypedefKind,
/// An enumeration or scoped enumeration.
EnumKind
};
/// What kind of template specialization \c CommentDecl is.
enum TemplateDeclKind {
NotTemplate,
Template,
TemplateSpecialization,
TemplatePartialSpecialization
};
/// If false, only \c CommentDecl is valid.
unsigned IsFilled : 1;
/// Simplified kind of \c CommentDecl, see \c DeclKind enum.
unsigned Kind : 3;
/// Is \c CommentDecl a template declaration.
unsigned TemplateKind : 2;
/// Is \c CommentDecl an ObjCMethodDecl.
unsigned IsObjCMethod : 1;
/// Is \c CommentDecl a non-static member function of C++ class or
/// instance method of ObjC class.
/// Can be true only if \c IsFunctionDecl is true.
unsigned IsInstanceMethod : 1;
/// Is \c CommentDecl a static member function of C++ class or
/// class method of ObjC class.
/// Can be true only if \c IsFunctionDecl is true.
unsigned IsClassMethod : 1;
void fill();
DeclKind getKind() const LLVM_READONLY {
return static_cast<DeclKind>(Kind);
}
TemplateDeclKind getTemplateKind() const LLVM_READONLY {
return static_cast<TemplateDeclKind>(TemplateKind);
}
};
/// A full comment attached to a declaration, contains block content.
class FullComment : public Comment {
ArrayRef<BlockContentComment *> Blocks;
DeclInfo *ThisDeclInfo;
public:
FullComment(ArrayRef<BlockContentComment *> Blocks, DeclInfo *D) :
Comment(FullCommentKind, SourceLocation(), SourceLocation()),
Blocks(Blocks), ThisDeclInfo(D) {
if (Blocks.empty())
return;
setSourceRange(SourceRange(Blocks.front()->getLocStart(),
Blocks.back()->getLocEnd()));
setLocation(Blocks.front()->getLocStart());
}
static bool classof(const Comment *C) {
return C->getCommentKind() == FullCommentKind;
}
child_iterator child_begin() const {
return reinterpret_cast<child_iterator>(Blocks.begin());
}
child_iterator child_end() const {
return reinterpret_cast<child_iterator>(Blocks.end());
}
const Decl *getDecl() const LLVM_READONLY {
return ThisDeclInfo->CommentDecl;
}
const DeclInfo *getDeclInfo() const LLVM_READONLY {
if (!ThisDeclInfo->IsFilled)
ThisDeclInfo->fill();
return ThisDeclInfo;
}
ArrayRef<BlockContentComment *> getBlocks() const { return Blocks; }
};
} // end namespace comments
} // end namespace clang
#endif
|
[
"tungnt.rec@gmail.com"
] |
tungnt.rec@gmail.com
|
1a49875910acde426161e1cda75d790695fef49c
|
2b19a7d798a7a8b259857ef0cd0445724df9056a
|
/project/include/ctrlext.h
|
0116497e1ff1a0809b70148ebc77e421c1e67326
|
[
"MIT"
] |
permissive
|
lakeweb/spur-gear-gen
|
98a95838bcbc1b24e2b1133f877552fdffab3857
|
40714adfbe0acca16d517e6824eb72d1f3dec42d
|
refs/heads/master
| 2021-05-01T22:25:21.896050
| 2017-01-16T21:14:38
| 2017-01-16T21:14:38
| 77,257,019
| 1
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 8,316
|
h
|
// ctrlext.h :
//
// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
#ifndef __TREECTLX_H__
#define __TREECTLX_H__
//#define TCN_BEGIN_LIST 32780
#define TCN_LMOUSEBUTTON 32780
#ifdef _AFX_NO_AFXCMN_SUPPORT
#error Windows Common Control classes not supported in this library variant.
#endif
#ifndef __AFXWIN_H__
#include <afxwin.h>
#endif
class CTreeCtrlEx;
//.........................................................
/*
#define TVHT_NOWHERE 0x0001
#define TVHT_ONITEMICON 0x0002
#define TVHT_ONITEMLABEL 0x0004
#define TVHT_ONITEM (TVHT_ONITEMICON | TVHT_ONITEMLABEL | TVHT_ONITEMSTATEICON)
#define TVHT_ONITEMINDENT 0x0008
#define TVHT_ONITEMBUTTON 0x0010
#define TVHT_ONITEMRIGHT 0x0020
#define TVHT_ONITEMSTATEICON 0x0040
#define TVHT_ABOVE 0x0100
#define TVHT_BELOW 0x0200
#define TVHT_TORIGHT 0x0400
#define TVHT_TOLEFT 0x0800
typedef struct tagTVHITTESTINFO {
POINT pt;
UINT flags;
HTREEITEM hItem;
} TVHITTESTINFO, *LPTVHITTESTINFO;
*/
/*
typedef struct tagNMHDR
{
HWND hwndFrom;
UINT_PTR idFrom;
UINT code; // NM_ code
} NMHDR;
*/
//notify clicks
typedef struct tagTREECLICKA
{
NMHDR hdr;
TVHITTESTINFO hit_info;
UINT mouse_flags;
CPoint ptClick;
CTreeCtrlEx* pClass;
} TREECLICKA, *LPTREECLICKA;
//Used in OnNMClick, as CLVN_CHECKCHANGE
// OnNMRclick, as CLVN_RTLCLK; OnNMDblclk, as CLVN_DBLCLK
// ............................................................
class CTreeCtrlEx;
// ............................................................
class CTreeCursor
{
// Attributes
protected:
HTREEITEM m_hTreeItem;
CTreeCtrlEx *m_pTree;
// Implementation
protected:
CTreeCursor CTreeCursor::_Insert( LPCTSTR strItem, int nImageNorm, int nImageSel, HTREEITEM hAfter );
// Operation
public:
CTreeCursor( );
CTreeCursor( HTREEITEM hTreeItem, CTreeCtrlEx* pTree );
CTreeCursor( const CTreeCursor& posSrc );
CTreeCursor( const TREECLICKA& info );
~CTreeCursor( );
const CTreeCursor& operator = ( const CTreeCursor& posSrc );
operator HTREEITEM( ) const;
bool IsValid( ) const;
void SetInvalid( );
CTreeCursor InsertAfter( LPCTSTR strItem, HTREEITEM hAfter, int nImageNorm= -1, int nImageSel= -1 );
CTreeCursor AddHead( LPCTSTR strItem, int nImageNorm= -1, int nImageSel= -1 );
CTreeCursor AddTail( LPCTSTR strItem, int nImageNorm= -1, int nImageSel= -1 );
int GetImageID( );
int GetImageIDSel( );
BOOL GetRect( LPRECT lpRect, BOOL bTextOnly );
CTreeCursor GetNext( UINT nCode );
CTreeCursor GetChild( );
CTreeCursor GetNextSibling( );
CTreeCursor GetPrevSibling( );
CTreeCursor GetParent( );
CTreeCursor GetFirstVisible( );
CTreeCursor GetNextVisible( );
CTreeCursor GetPrevVisible( );
CTreeCursor GetSelected( );
CTreeCursor GetDropHilight( );
CTreeCursor GetRoot( );
CString GetText( );
BOOL GetImage( int& nImage, int& nSelectedImage );
UINT GetState( UINT nStateMask );
DWORD GetData( ) const;
//BOOL SetItem( UINT nMask, LPCTSTR lpszItem, int nImage,
// int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam );
BOOL SetText( LPCTSTR lpszItem );
BOOL SetImage( int nImage, int nSelectedImage= -1 );
BOOL SetState( UINT nState, UINT nStateMask );
BOOL SetData( DWORD dwData );
BOOL HasChildren( );
//returns count of real children
int GetChildCount( ); //5/31/7
// Operations
BOOL Delete( );
BOOL Expand(UINT nCode= TVE_EXPAND );
BOOL Collapse( );
BOOL Select( UINT nCode );
BOOL Select( );
BOOL SelectDropTarget( );
BOOL SelectSetFirstVisible( );
CEdit* EditLabel( );
CImageList* CreateDragImage( );
BOOL SortChildren( );
BOOL EnsureVisible( );
void DeleteAllChildren( ); //added 3/26/4
CTreeCtrlEx& GetTreeCtrl( ); //added 5/14/7
//will appear as having children [+] without real children
void SetHasChildern( ); //added 5/30/7
bool IsExpanded( ) const;
};
// ............................................................
class CTreeCtrlEx : public CTreeCtrl
{
DECLARE_DYNAMIC( CTreeCtrlEx )
bool IsSelectedItem( HTREEITEM hItem );
public:
CTreeCtrlEx( );
virtual ~CTreeCtrlEx( );
operator CTreeCtrlEx * ( ) { return this; }
CImageList* SetImageList( CImageList* pImageList, int nImageListType = TVSIL_NORMAL );
CTreeCursor GetNextItem( HTREEITEM hItem, UINT nCode );
CTreeCursor GetChildItem( HTREEITEM hItem );
CTreeCursor GetNextSiblingItem( HTREEITEM hItem );
CTreeCursor GetPrevSiblingItem( HTREEITEM hItem );
CTreeCursor GetParentItem( HTREEITEM hItem );
CTreeCursor GetFirstVisibleItem( );
CTreeCursor GetNextVisibleItem( HTREEITEM hItem );
CTreeCursor GetPrevVisibleItem( HTREEITEM hItem );
CTreeCursor GetSelectedItem( );
CTreeCursor GetDropHilightItem( );
CTreeCursor GetRootItem( );
CTreeCursor InsertItem( LPTV_INSERTSTRUCT lpInsertStruct );
CTreeCursor InsertItem( UINT nMask, LPCTSTR lpszItem, int nImage,
int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam,
HTREEITEM hParent, HTREEITEM hInsertAfter );
CTreeCursor InsertItem( LPCTSTR lpszItem, HTREEITEM hParent = TVI_ROOT,
HTREEITEM hInsertAfter = TVI_LAST );
CTreeCursor InsertItem( LPCTSTR lpszItem, int nImage, int nSelectedImage,
HTREEITEM hParent = TVI_ROOT, HTREEITEM hInsertAfter = TVI_LAST );
CTreeCursor HitTest( CPoint pt, UINT* pFlags = NULL );
CTreeCursor HitTest( TV_HITTESTINFO* pHitTestInfo );
//returns true if children and expanded
protected:
DECLARE_MESSAGE_MAP( )
afx_msg BOOL OnNMCustomdrawTreeEx( NMHDR *pNMHDR, LRESULT *pResult );
afx_msg void OnLButtonDown( UINT nFlags, CPoint point );
};
// ............................................................
class CTreeCtrlTraverse
{
CTreeCtrlEx& tree_ctrl;
HTREEITEM root;
HTREEITEM tree_pos;
long depth;
public:
//constructor sets traverse start to root
CTreeCtrlTraverse::CTreeCtrlTraverse( CTreeCtrlEx& inTC )
:tree_ctrl( inTC )
,depth( 1 )
{
ASSERT( (HTREEITEM)inTC.GetRootItem( ) );
root= tree_pos= inTC.GetRootItem( );
}
//constructor sets traverse start to tree cursor
CTreeCtrlTraverse::CTreeCtrlTraverse( CTreeCursor& inPos )
:tree_ctrl( inPos.GetTreeCtrl( ) )
,depth( 1 )
{
ASSERT( (HTREEITEM)inPos );
root= tree_pos= inPos;
}
CTreeCursor GetCurrentNode( ) const { return CTreeCursor( tree_pos, &tree_ctrl ); }
//Return next node and increment
CTreeCursor GetNextNode( );
//Returns root set by instantiation
CTreeCursor GetRootNode( ) const { return CTreeCursor( tree_pos, &tree_ctrl ); }
//Get depth in tree
long GetDepth( ) const { return depth; }
void Reset( ) { depth= 1; tree_pos= root; }
};
// ............................................................
class CViewTreeEx : public CTreeCtrlEx
{
// Construction
public:
CViewTreeEx( );
// Overrides
protected:
virtual BOOL OnNotify( WPARAM wParam, LPARAM lParam, LRESULT* pResult );
// Implementation
public:
virtual ~CViewTreeEx( );
protected:
DECLARE_MESSAGE_MAP( )
};
// ............................................................
// ............................................................
// ............................................................
// ............................................................
// ............................................................
/////////////////////////////////////////////////////////////////////////////
// CListCtrlEx
//class CListCtrlEx : public CListCtrl
//{
// // Attributes
//protected:
//
// // Operation
//public:
// CListCtrlEx();
// ~CListCtrlEx();
// CImageList* SetImageList(CImageList* pImageList, int nImageListType = TVSIL_NORMAL);
// BOOL AddColumn(
// LPCTSTR strItem,int nItem,int nSubItem = -1,
// int nMask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM,
// int nFmt = LVCFMT_LEFT);
// BOOL AddItem(int nItem,int nSubItem,LPCTSTR strItem,int nImageIndex = -1);
//};
/////////////////////////////////////////////////////////////////////////////
#include <CtrlExt.inl>
#endif //__TREECTLX_H__
|
[
"contest@lakeweb.net"
] |
contest@lakeweb.net
|
c0f20caebb91100c777efa5454be08a74d0e5604
|
a5ecbf6067554be101ae81385feb55e54152b144
|
/Tetris/src/Tetromino.h
|
72dd65a036a521678f17ff2ec057d0def9b36856
|
[
"MIT"
] |
permissive
|
beannie-j/tetris
|
0228dea94b15749ccc784c09ec23dd7a685e7240
|
7e2d7f995740f704838551439156e0b2f75c60b2
|
refs/heads/master
| 2022-12-31T17:33:26.851399
| 2020-10-29T22:16:35
| 2020-10-29T22:16:35
| 287,405,033
| 0
| 0
| null | 2021-05-31T05:02:47
| 2020-08-14T00:15:06
|
C++
|
UTF-8
|
C++
| false
| false
| 1,104
|
h
|
#pragma once
#include <SFML/Graphics.hpp>
#include <array>
enum class RotationState : int {
cw0 = 0, cw90 = 1, cw180 = 2, cw270 = 3
};
enum class TetrominoType : int {
I = 0,
O = 1,
T = 2,
S = 3,
Z = 4,
J = 5,
L = 6,
NumberOfTetrominoTypes
};
class Tetromino {
public:
TetrominoType m_type;
static constexpr size_t m_size = 4;
std::array<std::array<int, m_size>, m_size> m_arr;
RotationState m_rotation_state;
float posX = 3.0f;
float posY = 0.f;
sf::Color m_color;
// make it const
float cell_size = 1.0f;
Tetromino(TetrominoType type);
void Draw(sf::RenderWindow& window);
bool MoveDown(float dy);
bool CollisionWithBlocks(float dx, float dy);
bool XBoundsCollision();
bool YBoundsCollision();
bool Y1BoundsCollision();
void Rotate_HardCoded(RotationState rotation_state);
bool TopBoundsCollision();
bool XLeftBoundsCollision();
bool XRightBoundsCollision();
static constexpr float block_size = 40.f;
static sf::Color s_Colors[10];
Tetromino() = default;
private:
};
|
[
"jeanniehjan@gmail.com"
] |
jeanniehjan@gmail.com
|
a58c69f2fc2a9fe04d0aaf8e0f8291d8b5899a83
|
97b0cfdc7eb4230e27598b4823853433909995ce
|
/greedy/canCompleteCircuit.cpp
|
365111e2530263b41f23600cf41baeb84eef6e4c
|
[] |
no_license
|
chenshuyuhhh/acm
|
90e3e0a7031ea343d971ce129da76aa42ee399e8
|
524a2ceb8c366be56f5261bf323407af18e3f437
|
refs/heads/master
| 2021-04-05T05:23:55.589834
| 2020-10-06T04:17:18
| 2020-10-06T04:17:18
| 248,524,127
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 533
|
cpp
|
#include <vector>
using namespace std;
//
// Created by 陈姝宇 on 2020/9/9.
//
class CanCompleteCircuit {
public:
int canCompleteCircuit(vector<int> &gas, vector<int> &cost) {
int sum = 0;
int index = 0;
int minGas = INT32_MAX;
for (int i = 0; i < gas.size(); ++i) {
sum += (gas[i] - cost[i]);
if (sum < minGas) {
index = i;
minGas = sum;
}
}
if (sum >= 0) return index + 1;
else return -1;
}
};
|
[
"3017218119@tju.edu.cn"
] |
3017218119@tju.edu.cn
|
66d4d7c19c47388b735dd28e5a143f5859b1f4aa
|
fb7efe44f4d9f30d623f880d0eb620f3a81f0fbd
|
/chrome/browser/installable/installable_logging.cc
|
7b74f686bb96c2f57196794b4aba1adeefac751c
|
[
"BSD-3-Clause"
] |
permissive
|
wzyy2/chromium-browser
|
2644b0daf58f8b3caee8a6c09a2b448b2dfe059c
|
eb905f00a0f7e141e8d6c89be8fb26192a88c4b7
|
refs/heads/master
| 2022-11-23T20:25:08.120045
| 2018-01-16T06:41:26
| 2018-01-16T06:41:26
| 117,618,467
| 3
| 2
|
BSD-3-Clause
| 2022-11-20T22:03:57
| 2018-01-16T02:09:10
| null |
UTF-8
|
C++
| false
| false
| 6,495
|
cc
|
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/installable/installable_logging.h"
#include "base/macros.h"
#include "base/strings/stringprintf.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
namespace {
const std::string& GetMessagePrefix() {
CR_DEFINE_STATIC_LOCAL(std::string, message_prefix,
("Site cannot be installed: "));
return message_prefix;
}
// Error message strings corresponding to the InstallableStatusCode enum.
static const char kRendererExitingMessage[] =
"the page is in the process of being closed";
static const char kRendererCancelledMessage[] =
"the page has requested the banner prompt be cancelled";
static const char kUserNavigatedMessage[] =
"the page was navigated before the banner could be shown";
static const char kNotInMainFrameMessage[] =
"the page is not loaded in the main frame";
static const char kNotFromSecureOriginMessage[] =
"the page is not served from a secure origin";
static const char kNoManifestMessage[] =
"the page has no manifest <link> URL";
static const char kManifestEmptyMessage[] =
"the manifest could not be fetched, is empty, or could not be parsed";
static const char kStartUrlNotValidMessage[] =
"the start URL in manifest is not valid";
static const char kManifestMissingNameOrShortNameMessage[] =
"one of manifest name or short name must be specified";
static const char kManifestDisplayNotSupportedMessage[] =
"the manifest display property must be set to 'standalone' or 'fullscreen'";
static const char kManifestMissingSuitableIconMessage[] =
"the manifest does not contain a suitable icon - PNG format of at least "
"%spx is required, the sizes attribute must be set, and the purpose "
"attribute, if set, must include \"any\".";
static const char kNoMatchingServiceWorkerMessage[] =
"no matching service worker detected. You may need to reload the page, or "
"check that the service worker for the current page also controls the "
"start URL from the manifest";
static const char kNoAcceptableIconMessage[] =
"a %spx square icon is required, but no supplied icon meets this "
"requirement";
static const char kCannotDownloadIconMessage[] =
"could not download a required icon from the manifest";
static const char kNoIconAvailableMessage[] =
"icon downloaded from the manifest was empty or corrupted";
static const char kPlatformNotSupportedOnAndroidMessage[] =
"the specified application platform is not supported on Android";
static const char kNoIdSpecifiedMessage[] =
"no Play store ID provided";
static const char kIdsDoNotMatchMessage[] =
"a Play Store app URL and Play Store ID were specified in the manifest, "
"but they do not match";
static const char kUrlNotSupportedForWebApkMessage[] =
"a URL in the web manifest contains a username, password, or port";
static const char kInIncognitoMessage[] =
"the page is loaded in an incognito window";
static const char kNotOfflineCapable[] = "the page does not work offline";
static const char kNoGesture[] =
"beforeinstallpromptevent.prompt() was not called with a user gesture";
} // namespace
void LogErrorToConsole(content::WebContents* web_contents,
InstallableStatusCode code,
const std::string& param) {
if (!web_contents)
return;
content::ConsoleMessageLevel severity = content::CONSOLE_MESSAGE_LEVEL_ERROR;
const char* pattern = nullptr;
switch (code) {
case NO_ERROR_DETECTED:
// These codes are solely used for UMA reporting.
case ALREADY_INSTALLED:
case INSUFFICIENT_ENGAGEMENT:
case PACKAGE_NAME_OR_START_URL_EMPTY:
case PREVIOUSLY_BLOCKED:
case PREVIOUSLY_IGNORED:
case SHOWING_NATIVE_APP_BANNER:
case SHOWING_WEB_APP_BANNER:
case FAILED_TO_CREATE_BANNER:
case WAITING_FOR_MANIFEST:
case WAITING_FOR_INSTALLABLE_CHECK:
case WAITING_FOR_NATIVE_DATA:
case MAX_ERROR_CODE:
return;
case RENDERER_EXITING:
pattern = kRendererExitingMessage;
break;
case RENDERER_CANCELLED:
pattern = kRendererCancelledMessage;
severity = content::CONSOLE_MESSAGE_LEVEL_INFO;
break;
case USER_NAVIGATED:
pattern = kUserNavigatedMessage;
severity = content::CONSOLE_MESSAGE_LEVEL_WARNING;
break;
case NOT_IN_MAIN_FRAME:
pattern = kNotInMainFrameMessage;
break;
case NOT_FROM_SECURE_ORIGIN:
pattern = kNotFromSecureOriginMessage;
break;
case NO_MANIFEST:
pattern = kNoManifestMessage;
break;
case MANIFEST_EMPTY:
pattern = kManifestEmptyMessage;
break;
case START_URL_NOT_VALID:
pattern = kStartUrlNotValidMessage;
break;
case MANIFEST_MISSING_NAME_OR_SHORT_NAME:
pattern = kManifestMissingNameOrShortNameMessage;
break;
case MANIFEST_DISPLAY_NOT_SUPPORTED:
pattern = kManifestDisplayNotSupportedMessage;
break;
case MANIFEST_MISSING_SUITABLE_ICON:
pattern = kManifestMissingSuitableIconMessage;
break;
case NO_MATCHING_SERVICE_WORKER:
pattern = kNoMatchingServiceWorkerMessage;
break;
case NO_ACCEPTABLE_ICON:
pattern = kNoAcceptableIconMessage;
break;
case CANNOT_DOWNLOAD_ICON:
pattern = kCannotDownloadIconMessage;
break;
case NO_ICON_AVAILABLE:
pattern = kNoIconAvailableMessage;
break;
case PLATFORM_NOT_SUPPORTED_ON_ANDROID:
pattern = kPlatformNotSupportedOnAndroidMessage;
severity = content::CONSOLE_MESSAGE_LEVEL_WARNING;
break;
case NO_ID_SPECIFIED:
pattern = kNoIdSpecifiedMessage;
break;
case IDS_DO_NOT_MATCH:
pattern = kIdsDoNotMatchMessage;
break;
case URL_NOT_SUPPORTED_FOR_WEBAPK:
pattern = kUrlNotSupportedForWebApkMessage;
break;
case IN_INCOGNITO:
pattern = kInIncognitoMessage;
break;
case NOT_OFFLINE_CAPABLE:
pattern = kNotOfflineCapable;
break;
case NO_GESTURE:
pattern = kNoGesture;
break;
}
if (!pattern)
return;
std::string message = param.empty() ?
pattern : base::StringPrintf(pattern, param.c_str());
web_contents->GetMainFrame()->AddMessageToConsole(
severity, GetMessagePrefix() + message);
}
|
[
"jacob-chen@iotwrt.com"
] |
jacob-chen@iotwrt.com
|
9170ab05e15b23518301f12341d67fdb2142c811
|
1ebc6909a717690b0f5245598069b8ea001a62a1
|
/source/Game/Objects/Gen/Common/FloatingPlatform.cpp
|
03dee2ac1e3e1892be530fab69dcdd78f73247fb
|
[] |
no_license
|
aknetk/Sonic-3-Mixed
|
8342b290bc83abcf3c29a69b4f518addeb3454c3
|
8e5803281669677878d449a0234515654ed958fd
|
refs/heads/master
| 2020-07-18T11:14:42.533813
| 2019-09-04T05:09:03
| 2019-09-04T05:09:03
| 206,234,998
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 9,504
|
cpp
|
// Object ID: 0x51
// Object Name: FloatingPlatform.cpp
#include "FloatingPlatform.h"
typedef IMath Math;
CONSTRUCTER FloatingPlatform::FloatingPlatform() {
if (LevelScene::IsZoneCurrently("AIZ")) {
Act1BinIndex = LevelScene::LoadSpriteBin("AIZ/Floating Platform.bin");
Act2BinIndex = LevelScene::LoadSpriteBin("AIZ/Floating Platform 2.bin");
BinIndex = Act1BinIndex;
}
else if (LevelScene::IsZoneCurrently("HCZ")) {
BinIndex = LevelScene::LoadSpriteBin("HCZ/Platform.bin");
}
else if (LevelScene::IsZoneCurrently("MGZ")) {
BinIndex = LevelScene::LoadSpriteBin("MGZ/Floating Platform.bin");
}
else if (LevelScene::IsZoneCurrently("CNZ")) {
BinIndex = LevelScene::LoadSpriteBin("CNZ/Rising Platform.bin");
}
else if (LevelScene::IsZoneCurrently("ICZ")) {
BinIndex = LevelScene::LoadSpriteBin("ICZ/Platforms.bin");
}
else if (LevelScene::IsZoneCurrently("LBZ")) {
BinIndex = LevelScene::LoadSpriteBin("LBZ/Floating Platform.bin");
}
else {
BinIndex = LevelScene::LoadSpriteBin("AIZ/Floating Platform.bin");
Act1BinIndex = BinIndex;
Act2BinIndex = BinIndex;
}
}
void FloatingPlatform::Create() {
Object::Create();
Active = true;
Priority = true;
DoDeform = true;
IsFloatingPlatform = true;
SolidTop = true;
Scene->AddSelfToRegistry(this, "Solid");
Outliner = Scene->AddNewObject(Obj_PlatformOutliner, 0, X, Y, false, false);
Outliner->Parent = this;
Timer = 0;
LastX = X;
LastY = Y;
YS = 1 - (FlipX << 1);
Vertical = false;
RisingType = false;
Rising = false;
Moving = false;
SizeIndex = (SubType >> 4) & 0x7;
MoveType = (SubType & 0xF) - 0x8;
BackupX = X;
Amplitude = 0;
if (SizeIndex == 0) {
W = 64;
H = 64;
}
else if (SizeIndex == 1) {
W = 48;
H = 24;
}
else if (SizeIndex == 2) {
W = 64;
H = 40;
}
if (MoveType > 0) {
if (MoveType >= 4) {
BackupX += 0x100;
}
}
MoveType = (SubType & 0xF);
if (MoveType == 1 || MoveType == 2) {
Amplitude = 0x20 << MoveType;
}
else if (MoveType == 3 || MoveType == 4) {
Amplitude = 0x08 << MoveType;
}
switch (Scene->ZoneID) {
case 1:
if (Scene->Act == 1) {
BinIndex = Act1BinIndex;
CurrentAnimation = Sprite->FindAnimation("Floating Platform");
Sprite->LinkPalette(Scene->TileSprite);
}
else if (Scene->Act == 2) {
BinIndex = Act2BinIndex;
Sprite = LevelScene::GetSpriteFromBinIndex(BinIndex);
Sprite->LinkPalette(Scene->TileSprite);
CurrentAnimation = Sprite->FindAnimation("Floating Platform 2");
}
Frame = 0;
break;
case 2:
CurrentAnimation = Sprite->FindAnimation("Main");
break;
case 3:
CurrentAnimation = Sprite->FindAnimation("Floating Platform");
break;
case 4:
CurrentAnimation = Sprite->FindAnimation("Rising Platform");
break;
case 5:
CurrentAnimation = Sprite->FindAnimation("Platforms");
Sprite->LinkPalette(Scene->TileSprite);
break;
case 6:
CurrentAnimation = Sprite->FindAnimation("Floating Platform");
break;
case 7:
break;
case 8:
break;
case 9:
break;
case 10:
break;
case 11:
break;
case 12:
break;
case 13:
break;
case 14:
break;
}
}
void FloatingPlatform::Update() {
if (MoveType == 0) {
if (BeingStoodOn) {
if (Timer < 0x40) Timer += 0x4;
}
else {
if (Timer > 0x00) Timer -= 0x4;
}
LastY = Y;
Y = InitialY - (Math::sinHex(Timer) >> 14);
}
else if (MoveType == 1 || MoveType == 2) {
LastX = X;
if (FlipX) X = InitialX + Amplitude / 2 - (Math::sinHex(Scene->Frame) >> (12 - MoveType));
else X = InitialX + Amplitude / 2 + (Math::sinHex(Scene->Frame) >> (12 - MoveType));
XSpeed = (X - LastX) << 8;
}
else if (MoveType == 3 || MoveType == 4) {
LastY = Y;
if (!FlipX) Y = InitialY - Amplitude / 2 - (Math::sinHex(Scene->Frame) >> (14 - MoveType));
else Y = InitialY - Amplitude / 2 + (Math::sinHex(Scene->Frame) >> (14 - MoveType));
if (CollidingWithPlayer) {
if (Scene->Player->Action != ActionType::Dead && Scene->Player->EZY < Y - H / 2) {
if (Scene->CollisionAt(Scene->Player->EZX - 9, Scene->Player->EZY - Scene->Player->H / 2 - 2, NULL, 2, Scene->Player)) {
Scene->Player->Die(false);
}
if (Scene->CollisionAt(Scene->Player->EZX + 9, Scene->Player->EZY - Scene->Player->H / 2 - 2, NULL, 2, Scene->Player)) {
Scene->Player->Die(false);
}
}
}
}
else if (MoveType == 5 || MoveType == 6) {
LastX = X;
LastY = Y;
if (FlipX ^ (MoveType == 6)) X = InitialX + 0x80 / 2 - (Math::sinHex(Scene->Frame) >> 10);
else X = InitialX + 0x80 / 2 + (Math::sinHex(Scene->Frame) >> 10);
if (!FlipX) Y = InitialY - 0x40 / 2 - (Math::sinHex(Scene->Frame) >> 11);
else Y = InitialY - 0x40 / 2 + (Math::sinHex(Scene->Frame) >> 11);
if (CollidingWithPlayer) {
if (Scene->Player->Action != ActionType::Dead && Scene->Player->EZY < Y - H / 2) {
if (Scene->CollisionAt(Scene->Player->EZX, Scene->Player->EZY - Scene->Player->H / 2 - 2, NULL, 2, Scene->Player)) {
Scene->Player->Die(false);
}
}
}
XSpeed = (X - LastX) << 8;
}
else if (MoveType == 7) {
if (BeingStoodOn) {
Rising = true;
}
LastY = Y;
if (Rising && Y > InitialY - 0x140) {
Y -= 1;
}
if (CollidingWithPlayer) {
if (Scene->Player->Action != ActionType::Dead && Scene->Player->EZY < Y - H / 2) {
if (Scene->CollisionAt(Scene->Player->EZX - 9, Scene->Player->EZY - Scene->Player->H / 2 - 2, NULL, 2, Scene->Player)) {
Scene->Player->Die(false);
}
if (Scene->CollisionAt(Scene->Player->EZX + 9, Scene->Player->EZY - Scene->Player->H / 2 - 2, NULL, 2, Scene->Player)) {
Scene->Player->Die(false);
}
}
}
}
if (Moving) {
if (!RisingType) {
LastX = X;
if (Vertical) {
Y = InitialY - 32 * Math::abs(YS) + (Math::cosHex(Scene->Frame + 1) * 32 * YS >> 16);
}
else {
X = InitialX + 32 * Math::abs(YS) + (Math::cosHex(Scene->Frame + 1) * 32 * YS >> 16);
}
XSpeed = (X - LastX) << 8;
}
if (Rising && Y > InitialY - 0x140) {
Y -= 1;
}
}
if (!Scene->maxLayer && !isHeldDebugObject) {
int32_t AnimCount = Sprite->AnimCount;
if (Scene->ZoneID == 3) {
Outliner->W = Sprite->Animations[CurrentAnimation % AnimCount].Frames[0].W;
Outliner->H = Sprite->Animations[CurrentAnimation % AnimCount].Frames[0].H;
}
else if (Scene->ZoneID == 2) {
int32_t FrameCount = Sprite->Animations[CurrentAnimation % AnimCount].FrameCount;
int32_t CaculatedFrame = Frame >> 8;
if (CaculatedFrame >= FrameCount) {
CaculatedFrame = Frame;
}
Outliner->W = Sprite->Animations[CurrentAnimation % AnimCount].Frames[CaculatedFrame % FrameCount].W;
Outliner->H = Sprite->Animations[CurrentAnimation % AnimCount].Frames[CaculatedFrame % FrameCount].H;
}
else {
Outliner->W = Sprite->Animations[CurrentAnimation % AnimCount].Frames[Frame].W;
Outliner->H = Sprite->Animations[CurrentAnimation % AnimCount].Frames[Frame].H;
}
Outliner->Visible = true;
}
else {
Outliner->Visible = false;
}
return;
Object::Update();
}
void FloatingPlatform::Render(int CamX, int CamY) {
int nX = X;
int nY = Y;
if (Moving) {
if (!RisingType) {
if (Vertical) {
nY = InitialY - 32 * Math::abs(YS) + (Math::cosHex(Scene->Frame + 0) * 32 * YS >> 16);
}
else {
nX = InitialX + 32 * Math::abs(YS) + (Math::cosHex(Scene->Frame + 0) * 32 * YS >> 16);
}
}
}
nX = LastX;
nY = LastY;
if (Scene->ZoneID == 1) {
G->DrawSprite(Sprite, CurrentAnimation, 0, nX - CamX, nY - 2 - CamY, 0, IE_NOFLIP);
}
else if (Scene->ZoneID == 2) {
G->DrawSprite(Sprite, CurrentAnimation, Frame >> 8, nX - CamX, nY - CamY, 0, IE_NOFLIP);
}
else if (Scene->ZoneID == 3) {
G->DrawSprite(Sprite, CurrentAnimation, 0, nX - CamX, nY - 2 - CamY, 0, IE_NOFLIP);
}
else {
G->DrawRectangle(nX - CamX - W / 2, nY - CamY - H / 2, W, H, 0xFF0000);
if (App->viewObjectCollision) {
G->SetDrawAlpha(0x80);
G->DrawRectangle(X - (W / 2) - CamX, Y - (H / 2) - CamY, W, H, DrawCollisionsColor);
G->SetDrawAlpha(0xFF);
}
}
}
|
[
"aurumdude@gmail.com"
] |
aurumdude@gmail.com
|
eefee1a9242f13181aa862fc484db77bca7e2280
|
6de7f1f0d9be7d0659902dc60c77dcaf332e927e
|
/src/libtsduck/dtv/descriptors/tsIPSignallingDescriptor.cpp
|
dbf693fed926733df4a6f34e935f647c90337376
|
[
"BSD-2-Clause"
] |
permissive
|
ConnectionMaster/tsduck
|
ed41cd625c894dca96f9b64f7e18cc265ef7f394
|
32732db5fed5f663dfe68ffb6213a469addc9342
|
refs/heads/master
| 2023-08-31T20:01:00.538543
| 2022-09-30T05:25:02
| 2022-09-30T08:14:43
| 183,097,216
| 1
| 0
|
BSD-2-Clause
| 2023-04-03T23:24:45
| 2019-04-23T21:15:45
|
C++
|
UTF-8
|
C++
| false
| false
| 4,085
|
cpp
|
//----------------------------------------------------------------------------
//
// TSDuck - The MPEG Transport Stream Toolkit
// Copyright (c) 2005-2022, Thierry Lelegard
// All rights reserved.
//
// 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.
//
// 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 "tsIPSignallingDescriptor.h"
#include "tsDescriptor.h"
#include "tsTablesDisplay.h"
#include "tsPSIRepository.h"
#include "tsPSIBuffer.h"
#include "tsDuckContext.h"
#include "tsNames.h"
#include "tsxmlElement.h"
#define MY_XML_NAME u"ip_signalling_descriptor"
#define MY_CLASS ts::IPSignallingDescriptor
#define MY_DID ts::DID_AIT_IP_SIGNALLING
#define MY_TID ts::TID_AIT
#define MY_STD ts::Standards::DVB
TS_REGISTER_DESCRIPTOR(MY_CLASS, ts::EDID::TableSpecific(MY_DID, MY_TID), MY_XML_NAME, MY_CLASS::DisplayDescriptor);
//----------------------------------------------------------------------------
// Constructors
//----------------------------------------------------------------------------
ts::IPSignallingDescriptor::IPSignallingDescriptor(uint32_t id) :
AbstractDescriptor(MY_DID, MY_XML_NAME, MY_STD, 0),
platform_id(id)
{
}
ts::IPSignallingDescriptor::IPSignallingDescriptor(DuckContext& duck, const Descriptor& desc) :
IPSignallingDescriptor()
{
deserialize(duck, desc);
}
void ts::IPSignallingDescriptor::clearContent()
{
platform_id = 0;
}
//----------------------------------------------------------------------------
// Serialization
//----------------------------------------------------------------------------
void ts::IPSignallingDescriptor::serializePayload(PSIBuffer& buf) const
{
buf.putUInt24(platform_id);
}
void ts::IPSignallingDescriptor::deserializePayload(PSIBuffer& buf)
{
platform_id = buf.getUInt24();
}
//----------------------------------------------------------------------------
// Static method to display a descriptor.
//----------------------------------------------------------------------------
void ts::IPSignallingDescriptor::DisplayDescriptor(TablesDisplay& disp, PSIBuffer& buf, const UString& margin, DID did, TID tid, PDS pds)
{
if (buf.canReadBytes(3)) {
disp << margin << "Platform id: " << names::PlatformId(buf.getUInt24(), NamesFlags::FIRST) << std::endl;
}
}
//----------------------------------------------------------------------------
// XML serialization
//----------------------------------------------------------------------------
void ts::IPSignallingDescriptor::buildXML(DuckContext& duck, xml::Element* root) const
{
root->setIntAttribute(u"platform_id", platform_id, true);
}
bool ts::IPSignallingDescriptor::analyzeXML(DuckContext& duck, const xml::Element* element)
{
return element->getIntAttribute(platform_id, u"platform_id", true, 0, 0, 0x00FFFFFF);
}
|
[
"thierry@lelegard.fr"
] |
thierry@lelegard.fr
|
ee6b4d3c59d48107a7404abb1e3bf3c5448acc82
|
d9f59c9f35c4e35b07ba757f9c23b3f82aff2f00
|
/HelloWorldOglEs/src/main/jni/Irrlicht/Octree.h
|
7cb64794a6fbed44b238df945a99f0146d612dae
|
[] |
no_license
|
marky0720/irrlicht_Android_ogl_es
|
44d5f9097b4fc328a204e9a98a0ae92dd13471a4
|
4c94b4ba2ee833015ff8e83855e5b92a539bcc6b
|
refs/heads/master
| 2020-04-07T12:27:10.852174
| 2018-03-20T09:52:50
| 2018-03-20T09:52:50
| 124,211,363
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 8,822
|
h
|
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_OCTREE_H_INCLUDED__
#define __C_OCTREE_H_INCLUDED__
#include "SViewFrustum.h"
#include "S3DVertex.h"
#include "aabbox3d.h"
#include "irrArray.h"
#include "CMeshBuffer.h"
/**
Flags for Octree
*/
//! bypass full invisible/visible test
#define OCTREE_PARENTTEST
namespace irr
{
//! template octree.
/** T must be a vertex type which has a member
called .Pos, which is a core::vertex3df position. */
template <class T>
class Octree
{
public:
struct SMeshChunk : public scene::CMeshBuffer<T>
{
SMeshChunk ()
: scene::CMeshBuffer<T>(), MaterialId(0)
{
scene::CMeshBuffer<T>::grab();
}
virtual ~SMeshChunk ()
{
//removeAllHardwareBuffers
}
s32 MaterialId;
};
struct SIndexChunk
{
core::array<u16> Indices;
s32 MaterialId;
};
struct SIndexData
{
u16* Indices;
s32 CurrentSize;
s32 MaxSize;
};
//! Constructor
Octree(const core::array<SMeshChunk>& meshes, s32 minimalPolysPerNode=128) :
IndexData(0), IndexDataCount(meshes.size()), NodeCount(0)
{
IndexData = new SIndexData[IndexDataCount];
// construct array of all indices
core::array<SIndexChunk>* indexChunks = new core::array<SIndexChunk>;
indexChunks->reallocate(meshes.size());
for (u32 i=0; i!=meshes.size(); ++i)
{
IndexData[i].CurrentSize = 0;
IndexData[i].MaxSize = meshes[i].Indices.size();
IndexData[i].Indices = new u16[IndexData[i].MaxSize];
indexChunks->push_back(SIndexChunk());
SIndexChunk& tic = indexChunks->getLast();
tic.MaterialId = meshes[i].MaterialId;
tic.Indices = meshes[i].Indices;
}
// create tree
Root = new OctreeNode(NodeCount, 0, meshes, indexChunks, minimalPolysPerNode);
}
//! returns all ids of polygons partially or fully enclosed
//! by this bounding box.
void calculatePolys(const core::aabbox3d<f32>& box)
{
for (u32 i=0; i!=IndexDataCount; ++i)
IndexData[i].CurrentSize = 0;
Root->getPolys(box, IndexData, 0);
}
//! returns all ids of polygons partially or fully enclosed
//! by a view frustum.
void calculatePolys(const scene::SViewFrustum& frustum)
{
for (u32 i=0; i!=IndexDataCount; ++i)
IndexData[i].CurrentSize = 0;
Root->getPolys(frustum, IndexData, 0);
}
const SIndexData* getIndexData() const
{
return IndexData;
}
u32 getIndexDataCount() const
{
return IndexDataCount;
}
u32 getNodeCount() const
{
return NodeCount;
}
//! for debug purposes only, collects the bounding boxes of the tree
void getBoundingBoxes(const core::aabbox3d<f32>& box,
core::array< const core::aabbox3d<f32>* >&outBoxes) const
{
Root->getBoundingBoxes(box, outBoxes);
}
//! destructor
~Octree()
{
for (u32 i=0; i<IndexDataCount; ++i)
delete [] IndexData[i].Indices;
delete [] IndexData;
delete Root;
}
private:
// private inner class
class OctreeNode
{
public:
// constructor
OctreeNode(u32& nodeCount, u32 currentdepth,
const core::array<SMeshChunk>& allmeshdata,
core::array<SIndexChunk>* indices,
s32 minimalPolysPerNode) : IndexData(0),
Depth(currentdepth+1)
{
++nodeCount;
u32 i; // new ISO for scoping problem with different compilers
for (i=0; i!=8; ++i)
Children[i] = 0;
if (indices->empty())
{
delete indices;
return;
}
bool found = false;
// find first point for bounding box
for (i=0; i<indices->size(); ++i)
{
if (!(*indices)[i].Indices.empty())
{
Box.reset(allmeshdata[i].Vertices[(*indices)[i].Indices[0]].Pos);
found = true;
break;
}
}
if (!found)
{
delete indices;
return;
}
s32 totalPrimitives = 0;
// now lets calculate our bounding box
for (i=0; i<indices->size(); ++i)
{
totalPrimitives += (*indices)[i].Indices.size();
for (u32 j=0; j<(*indices)[i].Indices.size(); ++j)
Box.addInternalPoint(allmeshdata[i].Vertices[(*indices)[i].Indices[j]].Pos);
}
core::vector3df middle = Box.getCenter();
core::vector3df edges[8];
Box.getEdges(edges);
// calculate all children
core::aabbox3d<f32> box;
core::array<u16> keepIndices;
if (totalPrimitives > minimalPolysPerNode && !Box.isEmpty())
for (u32 ch=0; ch!=8; ++ch)
{
box.reset(middle);
box.addInternalPoint(edges[ch]);
// create indices for child
bool added = false;
core::array<SIndexChunk>* cindexChunks = new core::array<SIndexChunk>;
cindexChunks->reallocate(allmeshdata.size());
for (i=0; i<allmeshdata.size(); ++i)
{
cindexChunks->push_back(SIndexChunk());
SIndexChunk& tic = cindexChunks->getLast();
tic.MaterialId = allmeshdata[i].MaterialId;
for (u32 t=0; t<(*indices)[i].Indices.size(); t+=3)
{
if (box.isPointInside(allmeshdata[i].Vertices[(*indices)[i].Indices[t]].Pos) &&
box.isPointInside(allmeshdata[i].Vertices[(*indices)[i].Indices[t+1]].Pos) &&
box.isPointInside(allmeshdata[i].Vertices[(*indices)[i].Indices[t+2]].Pos))
{
tic.Indices.push_back((*indices)[i].Indices[t]);
tic.Indices.push_back((*indices)[i].Indices[t+1]);
tic.Indices.push_back((*indices)[i].Indices[t+2]);
added = true;
}
else
{
keepIndices.push_back((*indices)[i].Indices[t]);
keepIndices.push_back((*indices)[i].Indices[t+1]);
keepIndices.push_back((*indices)[i].Indices[t+2]);
}
}
(*indices)[i].Indices.set_used(keepIndices.size());
memcpy( (*indices)[i].Indices.pointer(), keepIndices.pointer(), keepIndices.size()*sizeof(u16));
keepIndices.set_used(0);
}
if (added)
Children[ch] = new OctreeNode(nodeCount, Depth,
allmeshdata, cindexChunks, minimalPolysPerNode);
else
delete cindexChunks;
} // end for all possible children
IndexData = indices;
}
// destructor
~OctreeNode()
{
delete IndexData;
for (u32 i=0; i<8; ++i)
delete Children[i];
}
// returns all ids of polygons partially or full enclosed
// by this bounding box.
void getPolys(const core::aabbox3d<f32>& box, SIndexData* idxdata, u32 parentTest ) const
{
#if defined (OCTREE_PARENTTEST )
// if not full inside
if ( parentTest != 2 )
{
// partially inside ?
if (!Box.intersectsWithBox(box))
return;
// fully inside ?
parentTest = Box.isFullInside(box)?2:1;
}
#else
if (Box.intersectsWithBox(box))
#endif
{
const u32 cnt = IndexData->size();
u32 i; // new ISO for scoping problem in some compilers
for (i=0; i<cnt; ++i)
{
const s32 idxcnt = (*IndexData)[i].Indices.size();
if (idxcnt)
{
memcpy(&idxdata[i].Indices[idxdata[i].CurrentSize],
&(*IndexData)[i].Indices[0], idxcnt * sizeof(s16));
idxdata[i].CurrentSize += idxcnt;
}
}
for (i=0; i!=8; ++i)
if (Children[i])
Children[i]->getPolys(box, idxdata,parentTest);
}
}
// returns all ids of polygons partially or full enclosed
// by the view frustum.
void getPolys(const scene::SViewFrustum& frustum, SIndexData* idxdata,u32 parentTest) const
{
u32 i; // new ISO for scoping problem in some compilers
// if parent is fully inside, no further check for the children is needed
#if defined (OCTREE_PARENTTEST )
if ( parentTest != 2 )
#endif
{
#if defined (OCTREE_PARENTTEST )
parentTest = 2;
#endif
for (i=0; i!=scene::SViewFrustum::VF_PLANE_COUNT; ++i)
{
core::EIntersectionRelation3D r = Box.classifyPlaneRelation(frustum.planes[i]);
if ( r == core::ISREL3D_FRONT )
return;
#if defined (OCTREE_PARENTTEST )
if ( r == core::ISREL3D_CLIPPED )
parentTest = 1; // must still check children
#endif
}
}
const u32 cnt = IndexData->size();
for (i=0; i!=cnt; ++i)
{
s32 idxcnt = (*IndexData)[i].Indices.size();
if (idxcnt)
{
memcpy(&idxdata[i].Indices[idxdata[i].CurrentSize],
&(*IndexData)[i].Indices[0], idxcnt * sizeof(s16));
idxdata[i].CurrentSize += idxcnt;
}
}
for (i=0; i!=8; ++i)
if (Children[i])
Children[i]->getPolys(frustum, idxdata,parentTest);
}
//! for debug purposes only, collects the bounding boxes of the node
void getBoundingBoxes(const core::aabbox3d<f32>& box,
core::array< const core::aabbox3d<f32>* >&outBoxes) const
{
if (Box.intersectsWithBox(box))
{
outBoxes.push_back(&Box);
for (u32 i=0; i!=8; ++i)
if (Children[i])
Children[i]->getBoundingBoxes(box, outBoxes);
}
}
private:
core::aabbox3df Box;
core::array<SIndexChunk>* IndexData;
OctreeNode* Children[8];
u32 Depth;
};
OctreeNode* Root;
SIndexData* IndexData;
u32 IndexDataCount;
u32 NodeCount;
};
} // end namespace
#endif
|
[
"marky0720@gmail.com"
] |
marky0720@gmail.com
|
4f937fc98ada76a0a2a8c9ccf187bf492e9bddab
|
c49847e64bc31b42cbf5d2ad9199863500cfe50c
|
/Source/SoulslikeAction/Private/CS_CameraShake.cpp
|
1823ec97f17ba0726f5500b4684270c5b286e8f4
|
[] |
no_license
|
Babdodook/UE4_SoulAction_Portfolio
|
f1f4320c2435e1ae2425c73e95956dc66c262a62
|
fe179d848f109772be9052f4c64ce38ac8adf693
|
refs/heads/main
| 2023-06-18T07:40:33.019668
| 2021-07-20T04:16:56
| 2021-07-20T04:16:56
| 372,053,268
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 110
|
cpp
|
// Fill out your copyright notice in the Description page of Project Settings.
#include "CS_CameraShake.h"
|
[
"dol429@naver.com"
] |
dol429@naver.com
|
34935f55226add885e0371a74e0eb1411d410802
|
a8597af16ef33eb2d8d567fbd6923d2a4d3ce9d1
|
/src/activemasternode.h
|
a4b0f3ad6857ff8ec1aa513a02ec69a06005365f
|
[
"MIT"
] |
permissive
|
piklock/authoracoin
|
b086562c7c635e711b5a65a85c88adb338c6884f
|
09c4436d52a67d84ab76b00eaeb2eaa0a1add88b
|
refs/heads/master
| 2020-04-02T03:46:48.737019
| 2018-10-15T12:25:57
| 2018-10-15T12:25:57
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,333
|
h
|
// Copyright (c) 2014-2016 The Dash developers
// Copyright (c) 2015-2017 The PIVX developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef ACTIVEMASTERNODE_H
#define ACTIVEMASTERNODE_H
#include "init.h"
#include "key.h"
#include "masternode.h"
#include "net.h"
#include "sync.h"
#include "wallet.h"
#define ACTIVE_MASTERNODE_INITIAL 0 // initial state
#define ACTIVE_MASTERNODE_SYNC_IN_PROCESS 1
#define ACTIVE_MASTERNODE_INPUT_TOO_NEW 2
#define ACTIVE_MASTERNODE_NOT_CAPABLE 3
#define ACTIVE_MASTERNODE_STARTED 4
// Responsible for activating the Masternode and pinging the network
class CActiveMasternode
{
private:
// critical section to protect the inner data structures
mutable CCriticalSection cs;
/// Ping Masternode
bool SendMasternodePing(std::string& errorMessage);
/// Register any Masternode
bool Register(CTxIn vin, CService service, CKey key, CPubKey pubKey, CKey keyMasternode, CPubKey pubKeyMasternode, std::string& errorMessage);
/// Get ATHR collateral input that can be used for the Masternode
bool GetMasterNodeVin(CTxIn& vin, CPubKey& pubkey, CKey& secretKey, std::string strTxHash, std::string strOutputIndex);
bool GetVinFromOutput(COutput out, CTxIn& vin, CPubKey& pubkey, CKey& secretKey);
public:
// Initialized by init.cpp
// Keys for the main Masternode
CPubKey pubKeyMasternode;
// Initialized while registering Masternode
CTxIn vin;
CService service;
int status;
std::string notCapableReason;
CActiveMasternode()
{
status = ACTIVE_MASTERNODE_INITIAL;
}
/// Manage status of main Masternode
void ManageStatus();
std::string GetStatus();
/// Register remote Masternode
bool Register(std::string strService, std::string strKey, std::string strTxHash, std::string strOutputIndex, std::string& errorMessage);
/// Get ATHR collateral input that can be used for the Masternode
bool GetMasterNodeVin(CTxIn& vin, CPubKey& pubkey, CKey& secretKey);
vector<COutput> SelectCoinsMasternode();
/// Enable cold wallet mode (run a Masternode with no funds)
bool EnableHotColdMasterNode(CTxIn& vin, CService& addr);
};
extern CActiveMasternode activeMasternode;
#endif
|
[
"authoracoin1@gmail.com"
] |
authoracoin1@gmail.com
|
612b5eb615a040b5308d630e6c5e4e5ec5a3284f
|
fec81bfe0453c5646e00c5d69874a71c579a103d
|
/blazetest/src/mathtest/operations/dmatdmatmult/MHbMDa.cpp
|
370e1c14d6afbd65f7cb4b397dfd549a37f55ca2
|
[
"BSD-3-Clause"
] |
permissive
|
parsa/blaze
|
801b0f619a53f8c07454b80d0a665ac0a3cf561d
|
6ce2d5d8951e9b367aad87cc55ac835b054b5964
|
refs/heads/master
| 2022-09-19T15:46:44.108364
| 2022-07-30T04:47:03
| 2022-07-30T04:47:03
| 105,918,096
| 52
| 7
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,863
|
cpp
|
//=================================================================================================
/*!
// \file src/mathtest/operations/dmatdmatmult/MHbMDa.cpp
// \brief Source file for the MHbMDa dense matrix/dense matrix multiplication math test
//
// Copyright (C) 2012-2020 Klaus Iglberger - All Rights Reserved
//
// This file is part of the Blaze library. You can redistribute it and/or modify it under
// the terms of the New (Revised) BSD License. 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.
// 3. Neither the names of the Blaze development group 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 HOLDER 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.
*/
//=================================================================================================
//*************************************************************************************************
// Includes
//*************************************************************************************************
#include <cstdlib>
#include <iostream>
#include <blaze/math/DynamicMatrix.h>
#include <blaze/math/HybridMatrix.h>
#include <blazetest/mathtest/Creator.h>
#include <blazetest/mathtest/operations/dmatdmatmult/OperationTest.h>
#include <blazetest/system/MathTest.h>
#ifdef BLAZE_USE_HPX_THREADS
# include <hpx/hpx_main.hpp>
#endif
//=================================================================================================
//
// MAIN FUNCTION
//
//=================================================================================================
//*************************************************************************************************
int main()
{
std::cout << " Running 'MHbMDa'..." << std::endl;
using blazetest::mathtest::TypeA;
using blazetest::mathtest::TypeB;
try
{
// Matrix type definitions
using MHb = blaze::HybridMatrix<TypeB,64UL,37UL>;
using MDa = blaze::DynamicMatrix<TypeA>;
// Creator type definitions
using CMHb = blazetest::Creator<MHb>;
using CMDa = blazetest::Creator<MDa>;
// Running tests with small matrices
for( size_t i=0UL; i<=6UL; ++i ) {
for( size_t j=0UL; j<=6UL; ++j ) {
for( size_t k=0UL; k<=6UL; ++k ) {
RUN_DMATDMATMULT_OPERATION_TEST( CMHb( i, j ), CMDa( j, k ) );
}
}
}
// Running tests with large matrices
RUN_DMATDMATMULT_OPERATION_TEST( CMHb( 15UL, 37UL ), CMDa( 37UL, 15UL ) );
RUN_DMATDMATMULT_OPERATION_TEST( CMHb( 15UL, 37UL ), CMDa( 37UL, 63UL ) );
RUN_DMATDMATMULT_OPERATION_TEST( CMHb( 37UL, 37UL ), CMDa( 37UL, 37UL ) );
RUN_DMATDMATMULT_OPERATION_TEST( CMHb( 63UL, 37UL ), CMDa( 37UL, 15UL ) );
RUN_DMATDMATMULT_OPERATION_TEST( CMHb( 63UL, 37UL ), CMDa( 37UL, 63UL ) );
RUN_DMATDMATMULT_OPERATION_TEST( CMHb( 16UL, 32UL ), CMDa( 32UL, 16UL ) );
RUN_DMATDMATMULT_OPERATION_TEST( CMHb( 16UL, 32UL ), CMDa( 32UL, 64UL ) );
RUN_DMATDMATMULT_OPERATION_TEST( CMHb( 32UL, 32UL ), CMDa( 32UL, 32UL ) );
RUN_DMATDMATMULT_OPERATION_TEST( CMHb( 64UL, 32UL ), CMDa( 32UL, 16UL ) );
RUN_DMATDMATMULT_OPERATION_TEST( CMHb( 64UL, 32UL ), CMDa( 32UL, 64UL ) );
}
catch( std::exception& ex ) {
std::cerr << "\n\n ERROR DETECTED during dense matrix/dense matrix multiplication:\n"
<< ex.what() << "\n";
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
//*************************************************************************************************
|
[
"klaus.iglberger@gmail.com"
] |
klaus.iglberger@gmail.com
|
1a0568aa65dcbf2eb3fc51b911d88e8416fb50a6
|
f4869f5621db9e9b5fab33395095fa73077a6551
|
/Server/Server/FontManager.h
|
7140e61b328413a4d5e5b09e12f21e2546fe8575
|
[] |
no_license
|
MensInvictaManet/MasterServerList
|
2cb5427bfa6764b43f04e991d2529b215e69e30b
|
c46ca226f2a0a578618757e47586aeaf9cec0efa
|
refs/heads/master
| 2020-07-10T16:58:10.974892
| 2016-09-14T17:40:50
| 2016-09-14T17:40:50
| 67,855,276
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,828
|
h
|
#pragma once
#include "SDL2/SDL_opengl.h"
#pragma comment(lib, "opengl32.lib")
#include "TextureManager.h"
#include "XMLWrapper.h"
#include <unordered_map>
#include <string>
class FontManager;
struct Font
{
friend class FontManager;
public:
Font();
~Font();
void Shutdown();
void RenderText(const char* text, int x, int y, bool x_centered = false, bool y_centered = false, float x_scale = 1.0f, float y_scale = 1.0f) const;
unsigned int GetTextWidth(const char* text) const;
unsigned int GetCharacterCountBeforePassingWidth(const char* text, unsigned int width, bool cut_at_spaces = true) const;
inline unsigned int GetFontHeight(void) const { return m_MaxHeight; }
protected:
TextureManager::ManagedTexture* m_Texture;
unsigned int m_X[95];
unsigned int m_Y[95];
unsigned int m_Width[95];
unsigned int m_Height[95];
unsigned int m_MaxHeight;
};
class FontManager
{
public:
static FontManager& GetInstance() { static FontManager INSTANCE; return INSTANCE; }
void SetFontFolder(const char* folder_name);
bool LoadFont(const char* font_name);
Font* GetFont(const char* font_name);
void Shutdown(void);
private:
FontManager();
~FontManager();
typedef std::unordered_map<std::string, Font> FontListType;
FontListType m_FontList;
std::string m_FontFolder;
};
inline Font::Font() :
m_Texture(nullptr),
m_MaxHeight(0)
{
memset(m_X, 0, sizeof(unsigned int) * 95);
memset(m_Y, 0, sizeof(unsigned int) * 95);
memset(m_Width, 0, sizeof(unsigned int) * 95);
memset(m_Height, 0, sizeof(unsigned int) * 95);
}
inline Font::~Font()
{
}
inline void Font::Shutdown(void)
{
if (m_Texture != nullptr)
{
//textureManager.UnloadTexture(m_Texture);
}
}
inline void Font::RenderText(const char* text, int x, int y, bool x_centered, bool y_centered, float x_scale, float y_scale) const
{
if (m_Texture == nullptr) return;
// Determine the X offset
unsigned int x_offset = x;
if (x_centered) x_offset -= (unsigned int)((GetTextWidth(text) / 2.0f) * x_scale);
// Determine the Y offset
unsigned int y_offset = y;
if (y_centered) y_offset -= (unsigned int)(((m_MaxHeight / 2.0f)) * y_scale);
// Render each character in a line while updating the X offset
for (unsigned int i = 0; i < strlen(text); ++i)
{
m_Texture->RenderTexturePart(x_offset, y_offset, m_X[text[i] - 32], m_Y[text[i] - 32], int(m_Width[text[i] - 32] * x_scale), int(m_Height[text[i] - 32] * y_scale));
x_offset += int(m_Width[text[i] - 32] * x_scale);
}
}
inline unsigned int Font::GetTextWidth(const char* text) const
{
unsigned int width = 0;
for (unsigned int i = 0; i < strlen(text); ++i) width += m_Width[text[i] - 32];
return width;
}
inline unsigned int Font::GetCharacterCountBeforePassingWidth(const char* text, unsigned int width, bool cut_at_spaces) const
{
unsigned int character_count = 0;
std::string new_string("");
for (character_count = 0; character_count < strlen(text); ++character_count)
{
new_string += text[character_count];
if (GetTextWidth(new_string.c_str()) > width) { break; }
}
if (character_count == strlen(text)) { return character_count; }
if (cut_at_spaces)
{
auto new_return_value = new_string.find_last_of(" ");
if ((new_return_value != std::string::npos) && (new_return_value + 1 < new_string.size()))
{
character_count = (unsigned int)(new_return_value + 1);
}
}
return character_count;
}
inline void FontManager::SetFontFolder(const char* folder_name)
{
m_FontFolder = std::string(folder_name);
}
inline bool FontManager::LoadFont(const char* font_name)
{
std::string font_name_string(font_name);
auto existingFont = m_FontList.find(font_name_string);
if (existingFont != m_FontList.end()) return false;
std::string full_file_path(m_FontFolder);
full_file_path.append(font_name);
full_file_path.append("/");
full_file_path.append(font_name);
full_file_path.append(".xml");
auto fontXML = xmlWrapper.LoadXMLFile(full_file_path.c_str());
if (fontXML == nullptr) return false;
const RapidXML_Node* baseNode = fontXML->first_node();
if (baseNode == nullptr || strcmp(baseNode->name(), "BitmapFont") != 0) return false;
auto font_texture(m_FontFolder);
font_texture.append(font_name);
font_texture.append("/");
font_texture.append(font_name);
font_texture.append(".png");
auto fontTexture = textureManager.LoadTexture(font_texture.c_str());
if (fontTexture == nullptr) { return false; }
Font new_font;
new_font.m_Texture = fontTexture;
for (auto iter = baseNode->first_node(); iter != nullptr; iter = iter->next_sibling())
{
auto dataNode = iter->first_node("ID");
unsigned int index = atoi(dataNode->value()) - 32;
dataNode = dataNode->next_sibling("X");
new_font.m_X[index] = atoi(dataNode->value());
dataNode = dataNode->next_sibling("Y");
new_font.m_Y[index] = atoi(dataNode->value());
dataNode = dataNode->next_sibling("W");
new_font.m_Width[index] = atoi(dataNode->value());
dataNode = dataNode->next_sibling("H");
new_font.m_Height[index] = atoi(dataNode->value());
if (new_font.m_MaxHeight < new_font.m_Height[index]) new_font.m_MaxHeight = new_font.m_Height[index];
}
m_FontList[font_name_string] = new_font;
return true;
}
inline Font* FontManager::GetFont(const char* font_name)
{
std::string font_name_string(font_name);
auto iter = m_FontList.find(font_name_string);
if (iter == m_FontList.end()) { return nullptr; }
return &((*iter).second);
}
inline void FontManager::Shutdown(void)
{
for (auto iter = m_FontList.begin(); iter != m_FontList.end(); ++iter)
{
(*iter).second.Shutdown();
}
m_FontList.clear();
}
inline FontManager::FontManager()
{
}
inline FontManager::~FontManager()
{
if (!m_FontList.empty())
{
Shutdown();
}
}
// Instance to be utilized by anyone including this header
FontManager& fontManager = FontManager::GetInstance();
|
[
"MensInvictaManet@gmail.com"
] |
MensInvictaManet@gmail.com
|
63094d72ed0227fae752c36ffe26d1523fa89126
|
b68877cbe9328314a63dcdb6d5e07b53e3e4d82d
|
/EnvironmentString/EnvironmentString.cpp
|
f25dc3493e339f920a9d7bd59cf09e69a818319c
|
[] |
no_license
|
c1xfr2e/windows_snippet
|
64dc133f6842aec4845a70948a786d1403a4a750
|
226e84f786bd76c2e582f14fd9dcea9c5f82af89
|
refs/heads/master
| 2021-05-26T15:25:55.380928
| 2013-12-24T12:44:06
| 2013-12-24T12:44:06
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 229
|
cpp
|
#include <windows.h>
int main() {
const wchar_t* name = L"%ProgramFiles%\\HwAndInstall\\hw_android_usb_driver";
wchar_t buf[MAX_PATH] = {L'\0'};
DWORD count = ::ExpandEnvironmentStrings(name, buf, MAX_PATH);
return 0;
}
|
[
"zhaohao@wandoujia.com"
] |
zhaohao@wandoujia.com
|
aabe60dc49d56ce51d5f3c113136d0e6c0f7c387
|
92682f3d4ce6848550f3ed55e3a441b27f2f3818
|
/leetcode problems/1143. Longest Common Subsequence.cpp
|
70ec39095ca9cebc98aeb91ffaaedfb5af769b4d
|
[] |
no_license
|
Lakshita2002/LeetCode-Problems-Summers-2021
|
24a9332074fa910e62c6f0081383904d4833ad49
|
dfa0143e4133b2ff14ed15d2cc4cc06ad9f17b4d
|
refs/heads/main
| 2023-08-04T00:23:36.574510
| 2021-09-28T13:23:07
| 2021-09-28T13:23:07
| 362,406,470
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 852
|
cpp
|
class Solution {
public:
int dp[1001][1001];
int lcs(string &text1, string &text2, int s1, int s2){
// base case
if(s1==0 or s2==0){
return 0;
}
if(dp[s1][s2] != -1){
return dp[s1][s2];
}
// recursive case
if(text1[s1-1]==text2[s2-1]){
dp[s1][s2] = 1+lcs(text1, text2, s1-1, s2-1);
}
else{
dp[s1][s2] = max(lcs(text1, text2, s1, s2-1),
lcs(text1, text2, s1-1, s2));
}
return dp[s1][s2];
}
int longestCommonSubsequence(string text1, string text2) {
int s1 = text1.length();
int s2 = text2.length();
memset(dp,-1,sizeof(dp));
return lcs(text1, text2, s1, s2);
}
};
|
[
"lakshitamohanty2002@gmail.com"
] |
lakshitamohanty2002@gmail.com
|
d074ba6ebb80dc989e874229a77c3e68130c3050
|
5799ac9ab66ba6c3ac4f01088f61b3f70840d22a
|
/widget-game-process.cpp
|
ffb3e32e7ccb13ea3a69352b37a980a8d97261db
|
[] |
no_license
|
look919/Chess-game-Qt
|
67ed7b4c28b7d92c4da9ac98bc4bd6cf512c2f86
|
85e4027441304012d0b183f7124aa80472685333
|
refs/heads/master
| 2020-08-29T03:11:18.088297
| 2019-10-27T19:42:49
| 2019-10-27T19:42:49
| 217,906,494
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 8,952
|
cpp
|
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
disableAllButons();
setStartingParameters();
placePiecesOnBoard();
setFiguresPosition();
}
void Widget::on_startGameButton_clicked(){
ui->startGameButton->setEnabled(false);
ui->startGameButton->setText("White move!");
enableWhiteButtons();
}
void Widget::on_any_button_clicked(QPushButton *button)
{
if(!action) //1st pressing
{
possibleMoves.clear();
qDebug()<<whiteFiguresButtons;
action=true;
currentFigureButton=button; //needed to clean the field after move
currentFigureStyleSheet=button->styleSheet();
getFigureName(button); //setting currentFigure
if(currentFigure=="King"){
kingMovement(button);
} else if(currentFigure == "poon"){
if(whiteMove) poonMovementWhite(button);
else if(!whiteMove) poonMovementBlack(button);
} else if(currentFigure == "Knight"){
knightMovement(button);
} else if(currentFigure == "Bishop"){
bishopMovement(button);
} else if(currentFigure == "Rook"){
rookMovement(button);
} else if(currentFigure == "Queen"){
queenMovement(button);
}
}
else if(action) //2nd pressing
{
action=false;
cleanCoordinates();
if(whiteMove)
{
if(currentFigure == "King")
{
if(currentFigureButton == button){
goBack(button);
}else if(button == ui->g1 && whiteCastleShort){
castleMove("short");
switchPlayers(button);
}else if(button == ui->c1 && whiteCastleLong){
castleMove("long");
switchPlayers(button);
}
else{
whiteCastleLong = false;
whiteCastleShort = false;
move(button,"whiteKing");
switchPlayers(button);
}
}
else if(currentFigure == "poon")
{
if(currentFigureButton == button){
goBack(button);
}
else if(enPassant && (button->objectName() == enPassantLeft || button->objectName()==enPassantRight)){
enPassant = false;
enPassantMove(button,"whitePoon","5");
switchPlayers(button);
}
else if (button->objectName()[1]=="8") {
poonPromotion(button,"white");
switchPlayers(button);
}
else{
move(button,"whitePoon");
switchPlayers(button);
}
}
else if (currentFigure == "Knight")
{
if(currentFigureButton == button){
goBack(button);
}
else {
move(button,"whiteKnight");
switchPlayers(button);
}
}
else if (currentFigure == "Bishop")
{
if(currentFigureButton == button){
goBack(button);
}
else {
move(button,"whiteBishop");
switchPlayers(button);
}
}
else if (currentFigure == "Rook")
{
if(currentFigureButton == button){
goBack(button);
}
else {
if(currentFigureButton == whiteFiguresButtons[12]) whiteCastleLong = false;
else if(currentFigureButton == whiteFiguresButtons[13]) whiteCastleShort = false;
move(button,"whiteRook");
switchPlayers(button);
}
}
else if (currentFigure == "Queen")
{
if(currentFigureButton == button){
goBack(button);
}
else {
move(button,"whiteQueen");
switchPlayers(button);
}
}
}
else if(!whiteMove)
{
if(currentFigure == "King")
{
if(currentFigureButton == button){
goBack(button);
}else if(button == ui->g8 && blackCastleShort){
castleMove("short");
switchPlayers(button);
}else if(button == ui->c8 && blackCastleLong){
castleMove("long");
switchPlayers(button);
}
else{
blackCastleLong = false;
blackCastleShort = false;
move(button,"blackKing");
switchPlayers(button);
}
}
else if(currentFigure == "poon")
{
if(currentFigureButton == button){
goBack(button);
}else if(enPassant && (button->objectName() == enPassantLeft || button->objectName()==enPassantRight)){
enPassant = false;
enPassantMove(button,"blackPoon","4");
switchPlayers(button);
}
else if (button->objectName()[1]=="1") {
poonPromotion(button,"black");
switchPlayers(button);
}
else {
move(button,"blackPoon");
switchPlayers(button);
}
}
else if (currentFigure == "Knight")
{
if(currentFigureButton == button){
goBack(button);
}
else {
move(button,"blackKnight");
switchPlayers(button);
}
}
else if (currentFigure == "Bishop")
{
if(currentFigureButton == button){
goBack(button);
}
else {
move(button,"blackBishop");
switchPlayers(button);
}
}
else if (currentFigure == "Rook")
{
if(currentFigureButton == button){
goBack(button);
}
else {
if(currentFigureButton == blackFiguresButtons[12]) blackCastleLong = false;
else if(currentFigureButton == blackFiguresButtons[13]) blackCastleShort = false;
move(button,"blackRook");
switchPlayers(button);
}
}
else if (currentFigure == "Queen")
{
if(currentFigureButton == button){
goBack(button);
}
else {
move(button,"blackQueen");
switchPlayers(button);
}
}
}
}
}
void Widget::switchPlayers(QPushButton *button)
{
if(whiteMove)
{
whiteHistory(button);
isItCheck = false;
pinnedFigures.clear(); //clearing pinned figures and opponent possible moves from previous move
attackingFigures.clear();
opponentPossibleMoves.clear();
opponentPossibleMovesStorage.clear();
checkingMoves.clear();
protectingMoves.clear();
allPossibleMovesFromOpponentSide();
qDebug()<<"pinned"<<pinnedFigures<<"attacking"<<attackingFigures;
qDebug()<<"checking"<<checkingMoves;
whiteMove = false;
ui->startGameButton->setText("Black move!");
disableAllButons();
if(isItCheck) enableProtectingFigures();
else enableBlackButtons();
markKings();
pinnedFigues();
possibleMoves.clear();
possibleMovesStorage.clear();
}
else if(!whiteMove)
{
blackHistory(button);
numberOfMove++;
isItCheck = false;
pinnedFigures.clear();
attackingFigures.clear();
opponentPossibleMoves.clear();
opponentPossibleMovesStorage.clear();
checkingMoves.clear();
protectingMoves.clear();
allPossibleMovesFromOpponentSide();
qDebug()<<"pinned"<<pinnedFigures<<"attacking"<<attackingFigures;
qDebug()<<"checking"<<checkingMoves;
whiteMove = true;
ui->startGameButton->setText("White move!");
disableAllButons();
if(isItCheck) enableProtectingFigures();
else enableWhiteButtons();
markKings();
pinnedFigues();
possibleMoves.clear();
possibleMovesStorage.clear();
}
}
|
[
"wirkus919@gmail.com"
] |
wirkus919@gmail.com
|
78d9afd3686ff0b02831e3ab482834bf877662fa
|
aaa082df58a8220bbba511fcf9313078bf442e33
|
/src/menu/TextLabel.cpp
|
5baedbe57bd24fa2cfdff2f43a0a7d8dede71e91
|
[] |
no_license
|
terrence2/cognition
|
485082d234e0dd63791de8248e55725534b92b40
|
7e911cb6dda022134dc898dd1d818dce6516fb04
|
refs/heads/master
| 2021-05-15T23:10:37.346831
| 2017-10-15T06:17:43
| 2017-10-15T06:17:43
| 106,767,724
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,195
|
cpp
|
// This program 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 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 Library 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.
// INCLUDES
/////////////
#include "CogMenuGlobal.h"
#include "TextLabel.h"
// NAMESPACE
//////////////
namespace CW {
/* ------------
Constructor
------------ */
TextLabel::TextLabel() : Widget()
{
}
/* ------------
Constructor
------------ */
TextLabel::TextLabel( const string &newLabel, const string &newName, Widget *newParent,
const int &newX, const int &newY )
: Widget( newName, newParent, newX, newY, 10, 10 ), m_label(newLabel), m_size(12)
{
// Set Widget Properties
SetUnfocusable();
SetUnpushable();
// SetTextlabel Properties
m_clr[0] = m_clr[1] = m_clr[2] = m_clr[3] = 255;
m_label = newLabel;
m_size = 14;
}
/* ------------
Destructor
------------ */
bool TextLabel::Create( const string &newLabel, const string &newName,
Widget *newParent, const int &newX, const int &newY )
{
// Constructor Stuff
SetName( newName );
SetParent( newParent );
SetPosition( newX, newY );
// Widget Properties
SetUnfocusable();
SetUnpushable();
// Set TextLabel Properties
m_clr[0] = m_clr[1] = m_clr[2] = m_clr[3] = 255;
m_label = newLabel;
m_size = 14;
// Return Success
Enable();
return true;
}
/* ------------
Destructor
------------ */
TextLabel::~TextLabel()
{
}
/* ------------
Draw
------------ */
void TextLabel::Draw()
{
if( !IsEnabled() ) return;
ei()->d_TextLineColor( (char*)m_label.c_str(), m_size, m_clr, m_X, m_Y );
}
}
|
[
"terrence.d.cole@gmail.com"
] |
terrence.d.cole@gmail.com
|
141d0fc83ba83bc80b9f4b02a6330c3b57384d09
|
e0d6fd9e1c6f5401810f97ded178c4dcebd15f2b
|
/POJ/POJ1936.cpp
|
0eb81ec96a0136ef0b723d666d8e7773c4cee53d
|
[] |
no_license
|
yangzebin001/OJ
|
3d03edcb7133b974202fdceeba68f9d51724a055
|
34a4f03793f358d3770336af3e624feddfb3e9b3
|
refs/heads/master
| 2021-06-28T02:18:14.067208
| 2021-01-13T06:51:23
| 2021-01-13T06:51:23
| 202,832,472
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 489
|
cpp
|
/*
* @Date: 2019-09-09 15:53:22
* @LastEditors: BeckoninGshy
* @LastEditTime: 2019-09-09 15:58:06
*/
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
int main(){
string a,b;
freopen("in.txt","r",stdin);
while(cin >> a >> b){
int ai = 0;
for(int i = 0; i < b.size(); i++){
if(b[i] == a[ai]) ai++;
}
if(ai == a.size()) cout << "Yes" << endl;
else cout << "No" << endl;
}
return 0;
}
|
[
"405678856@qq.com"
] |
405678856@qq.com
|
cb388cd8a3a2aeda205b8933bec3bd019376b6be
|
a2111a80faf35749d74a533e123d9da9da108214
|
/raw/pmbs12/pmsb13-data-20120615/sources/brbym28nz827lxic/279/sandbox/meyerclp/apps/dreme/dreme.h
|
891aa1f1dd2e700f1057d0ac751d079cd59f1383
|
[
"MIT"
] |
permissive
|
bkahlert/seqan-research
|
f2c550d539f511825842a60f6b994c1f0a3934c2
|
21945be863855077eec7cbdb51c3450afcf560a3
|
refs/heads/master
| 2022-12-24T13:05:48.828734
| 2015-07-01T01:56:22
| 2015-07-01T01:56:22
| 21,610,669
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 39,883
|
h
|
#ifndef SANDBOX_MEYERCLP_APPS_DREME_H_
#define SANDBOX_MEYERCLP_APPS_DREME_H_
#include <fstream>
#include <iostream>
#include <map>
#include <vector>
#include <math.h>
#include <seqan/basic.h>
#include <seqan/file.h>
#include <seqan/find.h>
#include <seqan/stream.h>
#include <seqan/index.h>
#include <seqan/sequence.h>
using namespace seqan;
struct Seq
{
StringSet<CharString> ids;
StringSet<String<Dna> > seqs;//
Index< StringSet<String<Dna> > > SArray;
unsigned int SeqsNumber;
std::map<String<Dna>,unsigned int > seqCounter;//maps the Sequence-Kmere to a Counter for the Sequence
std::map<String<Iupac>,unsigned int> generalizedKmer;
std::map<String<Iupac>,double > SortedPValueReversed;
std::multimap<double,String<Dna> > SortedPValue;
std::multimap<double,String<Iupac> > generalizedSortedPValue;
};
struct IupacMaps
{
std::map<unsigned int,char> IupacMap;
std::map<char,unsigned int> IupacMapReversed;
std::map<char,String<Iupac> > IupacMapReplace; //stores the replacement-chars
std::map<char,String<Dna> > IupacMapReplaceReversed;
};
void readFastA(struct Seq &seq, CharString fname);
template <typename TStream>
void PrintFastA(TStream & stream, Seq &seq);
void initST(Seq &seq);
void PrintST(Seq &seq);
void initExactKmer(Seq &seq,Seq &back,unsigned int kmer_len,unsigned int kmer_len_end);
void CountKmer(Seq &seq, Finder<Index<StringSet<String<Dna> > > > &finder, String<Dna> &Kmer);
void CountKmer(std::map<String<Iupac>,unsigned int > &Dna5CounterMap, Finder<Index<StringSet<String<Iupac> > > > &finder, String<Iupac> &Kmer,Seq &seq,IupacMaps &IMap);
void PrintMap(std::map<String<Dna>,unsigned int > &Dna5CounterMap,unsigned int SeqsNumber);
void PrintMap(std::map<String<Iupac>,unsigned int > &Dna5CounterMap,unsigned int SeqsNumber);
void PrintMap(std::multimap<double,String<Dna> > &pValueMap);
void PrintMap(std::map<String<Iupac>,unsigned int> &generalizedKmer);
void PrintMap(std::map<unsigned int,std::map<Iupac,double> > freqMatrix,unsigned int Kmerlength,bool foreground);
void DebugMap(Seq &seq,Seq &back,std::map<String<Dna>,unsigned int > &sequencesCounter,std::map<String<Dna>,unsigned int > &backgroundCounter);
void DebugMultiMap(std::map<String<Dna>,unsigned int > &sequencesCounter,std::multimap<double,String<Dna> > &SortedPValue);
double* logFac;
void logFactorial(unsigned int len);
double calcFET(unsigned int a,unsigned int b,unsigned int c,unsigned int d);
void modifyFET(unsigned int a,unsigned int b,unsigned int c,unsigned int d, double &pValue);
void DebugFisherExact(unsigned int a,unsigned int b,unsigned int c,unsigned int d);
void FisherExactTest(Seq &seq, Seq &back);
void FisherExactTest(std::map<String<Iupac>,unsigned int > &SequenceCounter,std::map<String<Iupac>,unsigned int > &BackgroundCounter, Seq &seq, Seq &back);
double FisherExactTest(Seq &seq, Seq &back,std::multimap<double,String<Dna> > &GeneralizedSortedPValueTemp);
void MapIupac(IupacMaps &IMaps);
void InitGeneralization(IupacMaps &IMaps,Seq &seq, Seq &back);
void loopOverKmer(Seq &seq,String<Iupac> &temp,String<Iupac> &Kmer,Iterator<String<Iupac> >::Type &tempIt,Finder<Index<StringSet<String<Dna> > > > &finder,unsigned int &counter,std::vector<int> &CounterV,IupacMaps &IMap);
void FindKmer(Seq &seq,String<Iupac> &temp,Finder<Index<StringSet<String<Dna> > > > &finder,unsigned int &counter,std::vector<int> &CounterV);
void GeneralizeKmer(String<Dna> Kmer, IupacMaps &IMaps,Seq &seq, Seq &back);
void GeneralizeKmer(String<Iupac> Kmer,std::map<String<Iupac>,unsigned int> &generalizedKmerTemp,std::map<String<Iupac>,unsigned int> &generalizedKmerBackgroundTemp,IupacMaps &IMaps,Seq &seq, Seq &back);
void estimateCounter(Seq &seq,String<Iupac> temp,String<Iupac> temp2,unsigned int &counter);
void estimateCounter(Seq &seq,std::map<String<Iupac>,unsigned int> &generalizedKmer,String<Iupac> temp,String<Iupac> temp2,unsigned int &counter);
void exactGeneralizeCount(std::multimap<double,String<Iupac> > &SortedPValueG,std::map<String<Iupac>,unsigned int > &seqCounter,std::map<String<Iupac>,unsigned int > &backCounter,Finder<Index<StringSet<String<Dna> > > > &finder,Finder<Index<StringSet<String<Dna> > > > &finderB,Seq &seq, Seq &back,IupacMaps &IMap);
void BuildFrequencyMatrix(std::map<unsigned int,std::map<Iupac,double> > &freqMatrix,std::map<String<Iupac>,unsigned int > &seqCounter, Finder<Index<StringSet<String<Dna> > > > &finder, String<Iupac> &Kmer,Seq &seq, IupacMaps &IMaps,String<unsigned int> &replaceString);
void replaceKmer(Seq &seq,unsigned int stringNumber, unsigned int begin, unsigned int end);
void readFastA( struct Seq &seq,
CharString fname){
//########### einlesen in ids und seqs
//Variable um Sequenz und ID zu speichern
std::fstream fasta(toCString(fname), std:: ios_base::in | std::ios_base::binary);
if(!fasta.good()){
std::cerr << "Could not open file: \"" << fname << "\"" << std::endl;
std::exit(1);
}
typedef String<char,MMap<> > TMMapString;
TMMapString mmapString;
if(!open(mmapString, toCString(fname), OPEN_RDONLY))
std::exit(1);
RecordReader<TMMapString, DoublePass<Mapped> > reader(mmapString);
AutoSeqStreamFormat formatTag;
if(!checkStreamFormat(reader,formatTag)){
std::cerr<<"Could not determine file format!"<<std::endl;
std::exit(1);
}
std::cout<<"File format is "<<getAutoSeqStreamFormatName(formatTag)<<'\n';
StringSet<CharString> ids;
StringSet<String<Dna> > seqs;//
if(read2(ids,seqs,reader,formatTag) !=0){
std::cerr<<"ERROR reading FASTA"<<std::endl;
std::exit(1);
}
seq.ids = ids;
seq.seqs = seqs;
}
template <typename TStream>
void PrintFastA(TStream & stream,
Seq &seq){
SEQAN_ASSERT_EQ(length(seq.ids), length(seq.seqs));
typedef Iterator<StringSet<CharString>, Rooted>::Type TIdIter;
typedef Iterator<StringSet<String<Dna> >, Standard>::Type TSeqIter;//Dna5Q
TIdIter idIt =begin(seq.ids, Rooted());
TSeqIter seqIt=begin(seq.seqs, Standard());
for(;!atEnd(idIt);++idIt,++seqIt){
stream <<*idIt<<'\t'<<*seqIt<<std::endl;
}
}
void initST(Seq &seq){
//creates a index based on an enhanced suffix array
indexText(seq.SArray) = seq.seqs;
}
void PrintST(Seq &seq){
typedef Index<StringSet<String<Dna> > > TMyIndex;//Dna5Q
Iterator<TMyIndex, BottomUp<> >::Type myIterator(seq.SArray);
for(;!atEnd(myIterator);++myIterator){
std::cout<<representative(myIterator)<<std::endl;
}
}
//iniate Search in Fore- and Background
void initExactKmer( Seq &seq,
Seq &back,
unsigned int kmer_len,
unsigned int kmer_len_end){
Finder<Index<StringSet<String<Dna> > > > finder(seq.SArray);
Finder<Index<StringSet<String<Dna> > > > finderB(back.SArray);//finder background
typedef Index< StringSet<String<Dna> > > TMyIndex;
//kmer_len= 3;//minimal kmer-length
//kmer_len_end=8;//maximal length
if(kmer_len<1) kmer_len=3;
if(kmer_len_end<kmer_len) kmer_len_end=kmer_len+1;
//std::cout<<"kmer: "<<kmer_len<<std::endl;
//std::cout<<"end: "<<kmer_len_end<<std::endl;
typedef Iterator<StringSet<String<Dna> > >::Type TStringSetIterator;
unsigned int slen=0;
String<Dna> Kmer;//current Kmer
std::cout<<std::endl<<std::endl;
for(;kmer_len<=kmer_len_end;++kmer_len){//loop over all possible Kmer-length -->3-8
for(TStringSetIterator it=begin(seq.seqs);it!=end(seq.seqs);++it){//loop over all sequences
slen=length(value(it));//length of the current seq
if(slen==0) continue;
else if(slen<kmer_len) continue;
//std::cout<<"Sequence: "<<value(it)<<std::endl;
for(unsigned int i=0;i<slen-kmer_len+1;++i){//loop over all Kmere in the current sequence
Kmer=infix(value(it),i,i+kmer_len);//optimieren
//std::cout<<Kmer<<" ";
//if(Kmer[kmer_len-1]=='N'){//'AAAN'AAAA ---> AAA'NAAA'A --> after continue AAAN'AAAA'
// i+=kmer_len;
// continue;
//}
if(seq.seqCounter.find(Kmer)!=seq.seqCounter.end()) continue;// if Kmer is in the Map -->nothing to do
// //Pattern<String<Dna> > pattern(Kmer);
// std::cout<<"count";
CountKmer(back,finderB,Kmer);
CountKmer(seq,finder,Kmer);
}
}
}
//}
}
//gets the current Kmer and searches it in the index
//max(cumulated sum of the counter)=SeqsNumber --> counts number of sequences containing the motif
void CountKmer( Seq &seq,
Finder<Index<StringSet<String<Dna> > > > &finder,
String<Dna> &Kmer){
std::vector<int> CounterV(seq.SeqsNumber+1,0);//counter for storing 1 or 0 for each Seq + the cumulated sum of the counter in the last field
//std::cout<<"vor while ";
clear(finder);
while(find(finder,Kmer)){//search the current Kmer in all sequences
//std::cout<<'[' <<beginPosition(finder)<<','<<endPosition(finder)<<")\t"<<infix(finder)<<std::endl;//Debug
if(CounterV[beginPosition(finder).i1] == 0){//count number of sequences containing the motif, not the occurrences to avoid problems with self-overlapping
++CounterV[beginPosition(finder).i1];
++CounterV[seq.SeqsNumber];//last Position in CounterV is cumulated sum
}
}
seq.seqCounter[Kmer]=CounterV[seq.SeqsNumber];
CounterV.clear();
}
void loopOverKmer( Seq &seq,
String<Iupac> &temp,
String<Iupac> &Kmer,
Iterator<String<Iupac> >::Type &tempIt,
Finder<Index<StringSet<String<Dna> > > > &finder,
unsigned int &counter,
std::vector<int> &CounterV,
IupacMaps &IMap){
String<Dna> replace;
Iterator<String<Dna> >::Type replaceIt;
Iterator<String<Iupac> >::Type tempIttemp;
//std::cout<<Kmer;
//for(;tempIt!=end(temp);++tempIt){//loop over each position in kmer
//std::cout<<std::endl;
//std::cout<<" 0. "<<temp<<" "<<tempIt<<" ";
if(tempIt==end(temp)) return;//&&(tempIt+1!=end(temp))
if((*tempIt == 'A' || *tempIt == 'C' ||*tempIt == 'G' ||*tempIt == 'T')) loopOverKmer(seq,temp,temp,++tempIt,finder,counter,CounterV,IMap);//only replace the position with a wildcard
//else if((*tempIt == 'A' || *tempIt == 'C' ||*tempIt == 'G' ||*tempIt == 'T') && (tempIt+1 ==end(temp))){
// FindKmer(seq,temp,finder,counter,CounterV);//wenn der letzte ACGT danns suche auch
// return;
//}
replace=IMap.IupacMapReplaceReversed[*tempIt];
replaceIt = begin(replace);
//std::cout<<" 1. "<<temp<<" "<<tempIt<<" ";
for(;replaceIt!=end(replace);++replaceIt){
temp = Kmer;// reset temp
*tempIt = *replaceIt;
//if not end call fkt. with temp
// if end call find --> &counter
tempIttemp=tempIt;//der rekursive aufruf mit diesem, da die schleife mit tempIt weitergehen soll
if(tempIt+1!=end(temp)){
//++tempIt;
//std::cout<<tempIttemp<<" "<<tempIttemp+1<<" "<<tempIt<<" "<<end(temp)<<std::endl;
loopOverKmer(seq,temp,temp,++tempIttemp,finder,counter,CounterV,IMap);
}
//std::cout<<" 2. "<<*replaceIt<<" "<<temp<<" "<<tempIt<<std::endl;
FindKmer(seq,temp,finder,counter,CounterV);
}
//}
}
void FindKmer( Seq &seq,
String<Iupac> &temp,
Finder<Index<StringSet<String<Dna> > > > &finder,
unsigned int &counter,
std::vector<int> &CounterV){
clear(finder);
while(find(finder,temp)){//search the current Kmer in all sequences
//std::cout<<'[' <<beginPosition(finder)<<','<<endPosition(finder)<<")\t"<<infix(finder)<<std::endl;//Debug
if(CounterV[beginPosition(finder).i1] == 0){//count number of sequences containing the motif, not the occurrences to avoid problems with self-overlapping
//ansonsten müsste das array noch einmal durch gegangen werden und an jeder stellt !=0 ++
++CounterV[beginPosition(finder).i1];
++CounterV[seq.SeqsNumber];//last Position in CounterV is cumulated sum
++counter;
}
}
}
/*
for counting the top 100 generalizedKmere exact
todo -->template
*/
void CountKmer( std::map<String<Iupac>,unsigned int > &seqCounter,
Finder<Index<StringSet<String<Dna> > > > &finder,
String<Iupac> &Kmer,
Seq &seq,
IupacMaps &IMap){
String<Iupac> temp;
Iterator<String<Iupac> >::Type tempIt;
temp=Kmer;
tempIt = begin(temp);
unsigned int counter=0;
std::vector<int> CounterV(seq.SeqsNumber+1,0);//counter for storing 1 or 0 for each Seq + the cumulated sum of the counter in the last field
loopOverKmer(seq,temp,Kmer,tempIt,finder,counter,CounterV,IMap);
seqCounter[Kmer]=counter;
//std::cout<<temp<<" "<<CounterV[SeqsNumber]<<std::endl;
CounterV.clear();
/*
Der clear hier bewirkt, dass bei ASG entweder ACG oder AGG vorkommen darf,
falls beide vorkommen(in einer Sequenz) wird der counter trotzdem nur um 1 erhöht
-->Counter für AGG ist falsch, ASG stimmt jedoch wieder. Counter[AGG] --> irrelevant
-->AGG wird jedes mal wenns benötigt wird neu berechnet-->optimieren
*/
}
void replaceKmer( Seq &seq,
String<unsigned int> &replaceString){
unsigned int beg =0;
unsigned int endP =0;
unsigned int Snumber =0;
//std::cout<<stringNumber<<" "<<begin<<" "<<end<<std::endl;
Iterator<String<unsigned int> >::Type StringIt;
StringIt = begin(replaceString);
for(;StringIt!=end(replaceString);++StringIt){
Snumber = *StringIt;
++StringIt;
beg = *StringIt;
++StringIt;
endP = *StringIt;
//std::cout<<Snumber<<" "<<beg<<" "<<endP<<std::endl;
for(;beg<endP;++beg)
{
seq.seqs[Snumber][beg]='N';
}
//replace(seq.seqs[*StringIt],*(++StringIt),*(++StringIt),'N');
}
}
void BuildFrequencyMatrix( std::map<unsigned int,
std::map<Iupac,double> > &freqMatrix,
std::map<String<Iupac>,unsigned int > &seqCounter,
Finder<Index<StringSet<String<Dna> > > > &finder,
String<Iupac> &Kmer,
Seq &seq,
IupacMaps &IMaps,
String<unsigned int> &replaceString){
//std::cout<<Kmer<<std::endl;
//freqMatrix -->unsigned int = position in Kmer, position 1 in map = prob. for A, pos. 2 = prob. for C...
String<Iupac> temp;
String<Dna> replace;
Iterator<String<Iupac> >::Type tempIt;
Iterator<String<Dna> >::Type replaceIt;
temp=Kmer;
tempIt = begin(temp);
unsigned int counter=0;
unsigned int pos = 0;
std::map<Iupac,double> freq;//4= ACGT
for(;tempIt!=end(temp);++tempIt,++pos){//loop over each position in kmer
freq[*tempIt]=1;
freqMatrix[pos]=freq;
freq.clear();
if(*tempIt == 'A' || *tempIt == 'C' ||*tempIt == 'G' ||*tempIt == 'T') continue;//only replace the position with a wildcard
//std::cout<<temp<<" "<<Kmer<<" "<<IupacMapReplaceReversed[*tempIt]<<" ";
replace=IMaps.IupacMapReplaceReversed[*tempIt];
replaceIt = begin(replace);
for(;replaceIt!=end(replace);++replaceIt){
std::vector<int> CounterV(seq.SeqsNumber+1,0);//counter for storing 1 or 0 for each Seq + the cumulated sum of the counter in the last field
temp = Kmer;// reset temp
//std::cout<<" "<<temp<<" "<<Kmer<<" "<<*replaceIt<<std::endl;
*tempIt = *replaceIt;
//2vector für expression
clear(finder);
while(find(finder,temp)){//search the current Kmer in all sequences
//std::cout<<" "<<temp<<" "<<Kmer<<" "<<*replaceIt<<std::endl;
//std::cout<<'[' <<beginPosition(finder)<<','<<endPosition(finder)<<")\t"<<infix(finder)<<std::endl;//Debug
//replaceKmer(seq,beginPosition(finder).i1, beginPosition(finder).i2, endPosition(finder).i2);
appendValue(replaceString,beginPosition(finder).i1);
appendValue(replaceString,beginPosition(finder).i2);
appendValue(replaceString,endPosition(finder).i2);
if(CounterV[beginPosition(finder).i1] == 0){//count number of sequences containing the motif, not the occurrences to avoid problems with self-overlapping
++CounterV[beginPosition(finder).i1];
++CounterV[seq.SeqsNumber];//last Position in CounterV is cumulated sum
++counter;
}
}
//Durch die wildcards mehrere Vorkommen pro Sequence möglich:
seqCounter[temp]=CounterV[seq.SeqsNumber];
//std::cout<<temp<<" "<<*replaceIt<<" ";
freq[*tempIt]=CounterV[seq.SeqsNumber];
CounterV.clear();
}
if(counter>0){
freq['A']=freq['A']/counter;
freq['C']=freq['C']/counter;
freq['G']=freq['G']/counter;
freq['T']=freq['T']/counter;
}
else{
freqMatrix.clear();
}
freqMatrix[pos]=freq;
freq.clear();
}
}
//FreqMatrix output
void PrintMap( std::map<unsigned int,std::map<Iupac,double> > freqMatrix,
unsigned int Kmerlength,
bool foreground){
std::map<Iupac,double> freq;
std::cout<<std::endl;
if(foreground)
std::cout<<"foreground: "<<std::endl;
else
std::cout<<"background: "<<std::endl;
for(unsigned int j=0;j<Kmerlength;++j){
freq=freqMatrix[j];
std::cout<<"Position: "<<j<<" A: "<<freq['A']<<std::endl;
std::cout<<"Position: "<<j<<" C: "<<freq['C']<<std::endl;
std::cout<<"Position: "<<j<<" G: "<<freq['G']<<std::endl;
std::cout<<"Position: "<<j<<" T: "<<freq['T']<<std::endl;
std::cout<<std::endl;
}
}
/*Prints the Mapping:
Kmer Seq1 Seq2 ... Seqn CumulatedCounter
-->Template
*/
void PrintMap( std::map<String<Dna>,unsigned int> &Dna5CounterMap,
unsigned int SeqsNumber){
std::cout<<std::endl;
std::map<String<Dna>,unsigned int>::iterator MapIterator;
for(MapIterator=Dna5CounterMap.begin(); MapIterator !=Dna5CounterMap.end();++MapIterator){
std::cout<<(*MapIterator).first<<" ";
std::cout<<(*MapIterator).second<<" ";
std::cout<<std::endl;
}
}
void PrintMap( std::map<String<Iupac>,unsigned int > &Dna5CounterMap,
unsigned int SeqsNumber){
std::cout<<std::endl;
std::map<String<Iupac>,unsigned int >::iterator MapIterator;
for(MapIterator=Dna5CounterMap.begin(); MapIterator !=Dna5CounterMap.end();++MapIterator){
std::cout<<(*MapIterator).first<<" ";
std::cout<<(*MapIterator).second<<" ";
std::cout<<std::endl;
}
}
void PrintMap(std::multimap<double,String<Dna> > &pValueMap){
std::multimap<double,String<Dna> >::iterator MapIterator;
for(MapIterator=pValueMap.begin();MapIterator !=pValueMap.end();++MapIterator){
std::cout<<(*MapIterator).first<<" ";
std::cout<<(*MapIterator).second<<std::endl;
}
}
void PrintMap(std::multimap<double,String<Iupac> > &pValueMap){
std::multimap<double,String<Iupac> >::iterator MapIterator;
//std::cout<<pValueMap.size()<<std::endl;
int i=0;
for(MapIterator=pValueMap.begin();MapIterator !=pValueMap.end() && i<10;++MapIterator,++i){
std::cout<<(*MapIterator).first<<" ";
std::cout<<(*MapIterator).second<<std::endl;
}
}
//to print the generalizedKmerMap
void PrintMap(std::map<String<Iupac>,unsigned int> &generalizedKmer){
std::map<String<Iupac>, unsigned int>::iterator MapIterator;
int i=0;
for(MapIterator=generalizedKmer.begin();MapIterator!=generalizedKmer.end() && i<20;++MapIterator,++i){
std::cout<<(*MapIterator).first<<" ";
std::cout<<(*MapIterator).second<<" ";
}
}
//Test the Map-lengths match eachother and with the sequences
void DebugMap( Seq &seq,
Seq &back,
std::map<String<Dna>,std::vector<int> > &sequencesCounter,
std::map<String<Dna>,std::vector<int> > &backgroundCounter){
typedef std::map<String<Dna>,std::vector<int> > Dna5CounterMap;
Dna5CounterMap::iterator MapIterator;
MapIterator=sequencesCounter.begin();
Dna5CounterMap::iterator MapIteratorB;
MapIteratorB=backgroundCounter.begin();
SEQAN_ASSERT_EQ(length(sequencesCounter),length(backgroundCounter));
SEQAN_ASSERT_EQ(length((*MapIterator).second),(length(seq.ids)+1));//+1, because of the last field in vector
SEQAN_ASSERT_EQ(length((*MapIteratorB).second),(length(back.ids)+1));
//std::cout<<length(sequencesCounter)<<std::endl;
//std::cout<<length((*MapIterator).second)<<std::endl;
//std::cout<<length(backgroundCounter)<<std::endl;
//std::cout<<length((*MapIteratorB).second)<<std::endl;
//std::cout<<length(seq.ids)<<std::endl;
//std::cout<<length(back.ids)<<std::endl;
}
void DebugMultiMap( std::map<String<Dna>,std::vector<int> > &sequencesCounter,
std::multimap<double,String<Dna> > &SortedPValue){
SEQAN_ASSERT_EQ(length(sequencesCounter),SortedPValue.size());
}
void logFactorial(unsigned int len){
double* p;
unsigned int i=1;
p = (double*)malloc(sizeof(double)*(len+1));
p[0]=0;
for(;i<=len;++i){
p[i]= p[i-1] + log(i);
}
logFac =p;
}
double calcFET( unsigned int a,
unsigned int b,
unsigned int c,
unsigned int d){
return exp(logFac[a+b] + logFac[c+d] + logFac[a+c] + logFac[b+d] -
(logFac[a+b+c+d] + logFac[a]+ logFac[b] + logFac[c] +logFac[d]));
}
void modifyFET( unsigned int a,
unsigned int b,
unsigned int c,
unsigned int d,
double &pValue){
pValue= calcFET(a,b,c,d);
// //std::cout<<(*MapI).first<<" "<<pValue<<" ";
//
while(b!=0 && c!=0){//modify to be more extrem
++a;
--b;
--c;
++d;
pValue += calcFET(a,b,c,d);
// //std::cout<<pValue<<" ";
}
}
/***************************
log((a+b)!(c+d)!(a+c)!(b+d)!/a!b!c!d!n!) = logFactorial(a+b) + logFactorial(c+d) +
logFactorial(a+c) + logFactorial(b+d) -
(logFactorial(a+b+c+d) + logFactorial(a)+
logFactorial(b) + logFactorial(c) +
logFactorial(d))
pValue = exp(log((a+b)!(c+d)!(a+c)!(b+d)!/a!b!c!d!n!))
a=In Sequenz gefunden b=In Background gefunden
c=In Sequenz !gefunden d=In Background !gefunden
a = sequenceCounter b= backgroundCounter
a+c=SeqsNumber b+d=backgroundNumber
--> c= SeqsNumber - cumulated(sequenceCounter)
d= backgroundNumber - cumulated(backgroundCounter)
Für den einseitigen Test zusätzlich:
++a und --c
Für den zweiseitigen Test:
++a und --c
--a und ++c
****************************/
void FisherExactTest(Seq &seq,
Seq &back){
double pValue=0;
typedef std::map<String<Dna>,unsigned int >::iterator MapIterator;
MapIterator MapI=seq.seqCounter.begin();
MapIterator MapIB=back.seqCounter.begin();
//std::cout<<(*MapI).first<<" "<<(*MapI).second.back()<<std::endl;
//std::cout<<(*MapIB).first<<" "<<(*MapIB).second.back()<<std::endl;
for(;MapI!=seq.seqCounter.end();++MapI,++MapIB){
modifyFET((*MapI).second,(*MapIB).second,(seq.SeqsNumber - (*MapI).second),(back.SeqsNumber - (*MapIB).second),pValue);
//std::cout<<pValue<<std::endl;
//SortedPValue[pValue]=(*MapI).first;
seq.SortedPValue.insert(std::pair<double,String<Dna> > (pValue, (*MapI).first));
seq.SortedPValueReversed.insert(std::pair<String<Iupac>,double > ((*MapI).first,pValue));
}
}
//--> templates verwenden
void FisherExactTest(std::map<String<Iupac>,unsigned int > &SequenceCounter,
std::map<String<Iupac>,unsigned int > &BackgroundCounter,
Seq &seq,
Seq &back){
double pValue=0;
typedef std::map<String<Iupac>,unsigned int >::iterator MapIterator;
MapIterator MapI=SequenceCounter.begin();
MapIterator MapIB=BackgroundCounter.begin();
//std::cout<<(*MapI).first<<" "<<(*MapI).second.back()<<std::endl;
//std::cout<<(*MapIB).first<<" "<<(*MapIB).second.back()<<std::endl;
for(;MapI!=SequenceCounter.end();++MapI,++MapIB){
modifyFET((*MapI).second,(*MapIB).second,(seq.SeqsNumber - (*MapI).second),(back.SeqsNumber - (*MapIB).second),pValue);
seq.generalizedSortedPValue.insert(std::pair<double,String<Iupac> > (pValue, (*MapI).first));
seq.SortedPValueReversed.insert(std::pair< String<Iupac>,double> ((*MapI).first,pValue));
}
}
/*
Fisher-Exact-Test for generalized Kmere
*/
double FisherExactTest( Seq &seq,
Seq &back,
std::multimap<double,String<Iupac> > &GeneralizedSortedPValueTemp){
//std::cout<<"begin"<<std::endl;
if(seq.generalizedKmer.size()==0)
return 2;
typedef std::map<String<Iupac>,unsigned int >::iterator MapIterator;
std::multimap<double,String<Iupac> >::iterator MapIterator2;
MapIterator MapI = seq.generalizedKmer.begin();
MapIterator MapIB= back.generalizedKmer.begin();
double pValue=0;
//std::cout<<generalizedKmerSequence.size();
for(;MapI!=seq.generalizedKmer.end();++MapI,++MapIB){
modifyFET((*MapI).second,(*MapIB).second,seq.SeqsNumber - (*MapI).second,back.SeqsNumber - (*MapIB).second,pValue);
GeneralizedSortedPValueTemp.insert(std::pair<double,String<Iupac> > (pValue, (*MapI).first));//not seq.generalizedSortedPValue, because this is the temp one
seq.SortedPValueReversed.insert(std::pair<String<Iupac>,double > ((*MapI).first,pValue));
}
return GeneralizedSortedPValueTemp.begin()->first;
}
//void DebugFisherExact(unsigned int a,unsigned int b,unsigned int c,unsigned int d){
//
// double pValue=0;
// if(c<a || d < b){
// std::cerr<<"Cumulated Counter too large";
// exit(1);
// }
// c=c-a;
// d=d-b;
// SEQAN_ASSERT_EQ((logFactorial(2+1+4+2)),(logFactorial(9)));
//
// std::cout<<"a: "<<a<<" b: "<<b<<" c: "<<c<<" d: "<<d<<std::endl;
// pValue= logFactorial(a+b) + logFactorial(c+d) + logFactorial(a+c) + logFactorial(b+d) - (logFactorial(a+b+c+d) + logFactorial(a)+ logFactorial(b) + logFactorial(c) +logFactorial(d));
// std::cout<<"log(pValue) "<<pValue<<std::endl;
// pValue=logFactorial(a+b) + logFactorial(c+d) + logFactorial(a+c) + logFactorial(b+d) ;
// std::cout<<"the dividend: "<<pValue<<std::endl;
// pValue=- (logFactorial(2+1+4+2) + logFactorial(2)+ logFactorial(1) + logFactorial(4) +logFactorial(2));
// std::cout<<"the divisor: "<<pValue<<std::endl;
// pValue= (logFactorial(1));
// std::cout<<"logFactorial(1): "<<pValue<<std::endl;
// pValue= (logFactorial(0));
// std::cout<<"logFactorial(0): "<<pValue<<std::endl;
//
//
//}
void MapIupac(IupacMaps &IMaps ){
IMaps.IupacMap.get_allocator().allocate(16);
IMaps.IupacMap[0]='U';
IMaps.IupacMap[1]='T';
IMaps.IupacMap[2]='A';
IMaps.IupacMap[3]='W';
IMaps.IupacMap[4]='C';
IMaps.IupacMap[5]='Y';
IMaps.IupacMap[6]='M';
IMaps.IupacMap[7]='H';
IMaps.IupacMap[8]='G';
IMaps.IupacMap[9]='K';
IMaps.IupacMap[10]='R';
IMaps.IupacMap[11]='D';
IMaps.IupacMap[12]='S';
IMaps.IupacMap[13]='B';
IMaps.IupacMap[14]='V';
IMaps.IupacMap[15]='N';
IMaps.IupacMapReversed.get_allocator().allocate(16);
IMaps.IupacMapReversed['U']=0;
IMaps.IupacMapReversed['T']=1;
IMaps.IupacMapReversed['A']=2;
IMaps.IupacMapReversed['W']=3;
IMaps.IupacMapReversed['C']=4;
IMaps.IupacMapReversed['Y']=5;
IMaps.IupacMapReversed['M']=6;
IMaps.IupacMapReversed['H']=7;
IMaps.IupacMapReversed['G']=8;
IMaps.IupacMapReversed['K']=9;
IMaps.IupacMapReversed['R']=10;
IMaps.IupacMapReversed['D']=11;
IMaps.IupacMapReversed['S']=12;
IMaps.IupacMapReversed['B']=13;
IMaps.IupacMapReversed['V']=14;
IMaps.IupacMapReversed['N']=15;
IMaps.IupacMapReplace.get_allocator().allocate(14);
IMaps.IupacMapReplace['R']="CT";//in Iupac-notation R=AG --> CT left
IMaps.IupacMapReplace['Y']="AG";
IMaps.IupacMapReplace['S']="AT";
IMaps.IupacMapReplace['W']="CG";
IMaps.IupacMapReplace['K']="AC";
IMaps.IupacMapReplace['M']="GT";
IMaps.IupacMapReplace['D']="C";
IMaps.IupacMapReplace['H']="G";
IMaps.IupacMapReplace['B']="A";
IMaps.IupacMapReplace['V']="T";
IMaps.IupacMapReplace['A']="CGT";
IMaps.IupacMapReplace['C']="AGT";
IMaps.IupacMapReplace['G']="ACT";
IMaps.IupacMapReplace['T']="ACG";
IMaps.IupacMapReplaceReversed.get_allocator().allocate(11);
IMaps.IupacMapReplaceReversed['R']="AG";
IMaps.IupacMapReplaceReversed['Y']="CT";
IMaps.IupacMapReplaceReversed['S']="CG";
IMaps.IupacMapReplaceReversed['W']="AT";
IMaps.IupacMapReplaceReversed['K']="GT";
IMaps.IupacMapReplaceReversed['M']="AC";
IMaps.IupacMapReplaceReversed['D']="AGT";
IMaps.IupacMapReplaceReversed['H']="ACT";
IMaps.IupacMapReplaceReversed['B']="CGT";
IMaps.IupacMapReplaceReversed['V']="ACG";
IMaps.IupacMapReplaceReversed['N']="ACGT";
}
/* - initiate by repeatedly picking the top motifs from SortedPValue
- calls GeneralizeKmer and the EstimateFunction
*/
void InitGeneralization(IupacMaps &IMaps,
Seq &seq,
Seq &back){
std::multimap<double,String<Dna> >::iterator MapIterator;
std::multimap<double,String<Iupac> >::iterator MapIteratorT;
std::multimap<double,String<Iupac> > generalizedSortedPValueTemp;
std::map<String<Iupac>,unsigned int> generalizedKmerTemp;
std::map<String<Iupac>,unsigned int> generalizedKmerBackgroundTemp;
unsigned int i=0;
unsigned int limit;
if(seq.SortedPValue.size()>100) limit=100;
else limit = seq.SortedPValue.size();
for(MapIterator=seq.SortedPValue.begin();i<limit;++MapIterator,++i){//iterate over Top100
GeneralizeKmer((*MapIterator).second,IMaps,seq,back);
}
/*
- only do the next function call, if in the last at least one pValue<treshold
- call GeneralizeKmer in loop
*/
PrintMap(seq.generalizedKmer);
//seq.generalizedSortedPValue.insert(seq.SortedPValue.begin(),seq.SortedPValue.end());
double topPValue = FisherExactTest(seq,back,generalizedSortedPValueTemp);// lowest pValue from the first generalization
double topPValueOld =seq.SortedPValue.begin()->first;//lowest pValue before generalization
while(topPValue<0.05 && topPValue<topPValueOld){//only start a new round, if the top PValue is an improvement of the old one
//std::cout<<"test";
/*
while wird das erste mal mit generalizedKmer aufgerufen und dem tempor√§ren mapping der pValues
das tempor√§re mapping wird in das richtige mapping gemerged und gecleant, damit geschaut werden kann, ob bei den neuen pValues ein wert
über dem treshold ist --> falls nicht bricht die while ab
falls doch wird generalizedKmer kopiert und gecleant aus dem gleichen grund, damit, nur die neuen generalisierten Kmere untersucht werden
--> das Temp hier, um über alle alten zu gehen, um diese weiter zu generalisieren
*/
seq.generalizedSortedPValue.insert(generalizedSortedPValueTemp.begin(),generalizedSortedPValueTemp.end());
generalizedKmerTemp.clear();
generalizedKmerBackgroundTemp.clear();
generalizedKmerTemp=seq.generalizedKmer;
generalizedKmerBackgroundTemp=back.generalizedKmer;
back.generalizedKmer.clear();
seq.generalizedKmer.clear();
// generalizedMapIterator= generalizedKmerTemp.begin();
if(generalizedSortedPValueTemp.size()>100) limit=100;
else limit = generalizedSortedPValueTemp.size();
i=0;//only Top100
for(MapIteratorT=generalizedSortedPValueTemp.begin();i<limit;++MapIteratorT,++i){//iterate over Top100
//Temp ums zu finden, aber das normale auch übergeben, zum neu befüllen
GeneralizeKmer((*MapIteratorT).second,generalizedKmerTemp,generalizedKmerBackgroundTemp,IMaps,seq,back);
}
generalizedSortedPValueTemp.clear();
topPValueOld =topPValue;
topPValue = FisherExactTest(seq,back,generalizedSortedPValueTemp);
}
}
/* - gets a Kmer and replaces each position successively with each possible ambiguity Code(Iupac)
- only one wildcard per String at one time
- the unsigned int corresponds to the estimated counter
- String<Dna> for initialization
*/
void GeneralizeKmer(String<Dna> Kmer,
IupacMaps &IMaps,
Seq &seq,
Seq &back){
String<Iupac> temp;//temporary String --> generalizedKmer[temp]
String<Iupac> temp2;//Kmer with replaced position--> relevant for estimateCounter
Iterator<String<Iupac> >::Type tempIt;//Iterator over temp --> same length as Kmer
String<Dna> replace = "ACGT";//replace the current position with each possible ambiguity code --> A,C,G or T
Iterator<String<Dna> >::Type replaceIt;
unsigned int counter =0;
char tempChar;
//replaceIt = begin(replace);
temp = Kmer;
temp2=Kmer;
tempIt = begin(temp);
for(;tempIt!=end(temp);++tempIt){//loop over each position in kmer
replaceIt = begin(replace);
for(;replaceIt!=end(replace);++replaceIt){// loop over ACGT
temp = Kmer;// reset temp
if(*tempIt == *replaceIt) continue; // there is no Iupac for "AA", in return "AG" = "R"
//std::cout<<temp<<" ";
tempChar =*tempIt;//stores the current char because of temp2
*tempIt=*replaceIt;
temp2=temp;
*tempIt=tempChar;
*tempIt =IMaps.IupacMap[IMaps.IupacMapReversed[*tempIt] + IMaps.IupacMapReversed[*replaceIt]];//compute Iupac-letter--> A + G = R and replace the current location in temp
//std::cout<<Kmer<<" "<<temp<<" "<<temp2<<std::endl;
if(seq.generalizedKmer.find(temp)!=seq.generalizedKmer.end()) continue;// if Kmer is in the Map -->nothing to do
//estimateCounter mit Kmer und temp2 aufrufen
estimateCounter(seq,Kmer,temp2,counter);
//std::cout<<temp<<" ";
seq.generalizedKmer[temp]=counter;
estimateCounter(back,Kmer,temp2,counter);
back.generalizedKmer[temp]=counter;
}
}
//PrintMap(seq.generalizedKmer);
}
/* - the same as above except that each String has already a wildcard
*/
void GeneralizeKmer(String<Iupac> Kmer,
std::map<String<Iupac>,unsigned int> &generalizedKmerTemp,
std::map<String<Iupac>,unsigned int> &generalizedKmerBackgroundTemp,
IupacMaps &IMaps,
Seq &seq,
Seq &back){
String<Iupac> temp;//temporary String --> generalizedKmer[temp]
String<Iupac> temp2;//Kmer with replaced position--> relevant for estimateCounter
Iterator<String<Iupac> >::Type tempIt;//Iterator over temp --> same length as Kmer
String<Iupac> replace;
Iterator<String<Iupac> >::Type replaceIt;
unsigned int counter =0;
char tempChar;
temp = Kmer;
tempIt = begin(temp);
//std::cout<<temp<<" ";
for(;tempIt!=end(temp);++tempIt){//loop over each position in kmer
//if(*tempIt == 'A' || *tempIt == 'C' ||*tempIt == 'G' ||*tempIt == 'T') continue;//only replace the position with a wildcard
replace=IMaps.IupacMapReplace[*tempIt];
replaceIt = begin(replace);
for(;replaceIt!=end(replace);++replaceIt){// loop over the replacement-chars
temp = Kmer;// reset temp
//std::cout<<*replaceIt<<std::endl;
tempChar =*tempIt;//stores the current char because of temp2
*tempIt=*replaceIt;//replace the current char for temp2
temp2=temp;
*tempIt=tempChar;
*tempIt =IMaps.IupacMap[IMaps.IupacMapReversed[*tempIt] + IMaps.IupacMapReversed[*replaceIt]];
if(seq.SortedPValueReversed[Kmer] >= 0.05 || seq.SortedPValueReversed[temp2] >= 0.05) continue;//only if Kmer and temp2 are significant estimate the counter
if(generalizedKmerTemp.find(temp)!=generalizedKmerTemp.end()) continue;
estimateCounter(seq,generalizedKmerTemp,Kmer,temp2,counter);
seq.generalizedKmer[temp]=counter;
estimateCounter(back,generalizedKmerBackgroundTemp,Kmer,temp2,counter);
back.generalizedKmer[temp]=counter;
//std::cout<<temp<<" "<<counter<<std::endl;
}
}
/**
- gehe über Kmer --> if ACGT continue
- else rufe IupacMapReplace auf
- -->for(;replaceIt!=end(replace);++replaceIt) --> loop über den String aus IupacMapReplace
- temp ist das neue Kmer und temp2 die neue wildcard--> estimateCounter aufrufen --> für fore- und background
- funktion wird in for-schleife aufgerufen --> geht über alle
- clear generaliedKmer vor der for-schleife
- --> wird neu befüllt und kann mit FisherExact aufgerufen werden
- SortedPValue wird berechnet (in temp) und überprüft ob noch ein wert drunter ist-->falls ja insertiere temp in den rest
- falls nein nehme die top100 und rufe exactSearch auf
**/
}
//void loopOverRecplacement(String<Iupac> &temp,String<Iupac> &temp2,String<Iupac> Kmer,Iterator<String<Iupac> >::Type tempIt,unsigned int counter){
// char tempChar;
// String<Iupac> replace;
// Iterator<String<Iupac> >::Type replaceIt;
//
// replace=IupacMapReplace[*tempIt];
// replaceIt = begin(replace);
//
// for(;replaceIt!=end(replace);++replaceIt){// loop over the replacement-chars
// temp = Kmer;// reset temp
// tempChar =*tempIt;//stores the current char because of temp2
// *tempIt=*replaceIt;//replace the current char for temp2
// temp2=temp;
// *tempIt=tempChar;
//
// *tempIt =IupacMap[IupacMapReversed[*tempIt] + IupacMapReversed[*replaceIt]];
// //only if Kmer and temp2 are significant estimate the counter
// if(generalizedKmerTemp.find(temp)!=generalizedKmerTemp.end()) continue;
// estimateCounter(SequenceCounter,generalizedKmerTemp,Kmer,temp2,counter,SeqsNumber);
// generalizedKmer[temp]=counter;
// estimateCounter(BackgroundCounter,generalizedKmerBackgroundTemp,Kmer,temp2,counter,BackgroundNumber);
// generalizedKmerBackground[temp]=counter;
// //std::cout<<temp<<" "<<counter<<std::endl;
// }
//
//}
/*
- estimates the Counter for the initial wildcard-Kmere
- SequencesCounter and BackgroundCounter
*/
void estimateCounter(Seq &seq,
String<Iupac> temp,String<Iupac> temp2,
unsigned int &counter){
//std::cout<<temp<<" "<<temp2<<std::endl;
unsigned int RE1=seq.seqCounter.find(temp)->second;
unsigned int RE2=0;//counter for the second regular expression(Kmer)-->may be new
if(seq.seqCounter.find(temp2)!=seq.seqCounter.end()){
counter= RE1+ seq.seqCounter.find(temp2)->second - (RE1*seq.seqCounter.find(temp2)->second)/seq.SeqsNumber;
//std::cout<<temp<<" "<<temp2<<" "<<RE1<<" "<<SequenceCounter.find(temp2)->second.back()<<" "<<counter<<std::endl;
}
else{
counter=RE1 + RE2;
//std::cout<<"else "<<counter<<std::endl;
}
}
/*
- estimated the Counter for the next Kmer
*/
void estimateCounter(Seq &seq,
std::map<String<Iupac>,unsigned int> &generalizedKmer,
String<Iupac> temp,
String<Iupac> temp2,
unsigned int &counter){
if(generalizedKmer.find(temp)== generalizedKmer.end()){
std::cerr<<"Error, could not find "<<temp<<" in generalizedKmer"<<std::endl;
std::exit(1);
}
unsigned int RE1=(*generalizedKmer.find(temp)).second;//the new seed RE is a Kmer with wildcard
unsigned int RE2=0;//temp2 may be in generalizedKmer or in SequenceCounter
if(seq.seqCounter.find(temp2)!=seq.seqCounter.end()){// if temp2 is in SequenceCounter do the same as above --> has no wildcard
counter= RE1+ seq.seqCounter.find(temp2)->second- (RE1*seq.seqCounter.find(temp2)->second)/seq.SeqsNumber;
//std::cout<<temp<<" "<<temp2<<" "<<RE1<<" "<<SequenceCounter.find(temp2)->second.back()<<" "<<counter<<std::endl;
}
else if(generalizedKmer.find(temp2)!=generalizedKmer.end()){//if temp2 has a wildcard and is found in generalizedKmer
counter= RE1+ generalizedKmer.find(temp2)->second - (RE1*generalizedKmer.find(temp2)->second)/seq.SeqsNumber;
//std::cout<<temp<<" "<<temp2<<" "<<RE1<<" "<<generalizedKmer.find(temp2)->second<<" "<<counter<<std::endl;
}
else{//if temp2 is not found
counter= RE1 + RE2;
}
}
void exactGeneralizeCount( std::map<String<Iupac>,unsigned int > &seqCounter,
std::map<String<Iupac>,unsigned int > &backCounter,
Finder<Index<StringSet<String<Dna> > > > &finder,
Finder<Index<StringSet<String<Dna> > > > &finderB,
Seq &seq,
Seq &back,
IupacMaps &IMap){
std::multimap<double,String<Iupac> >::iterator generalizedSortedPValueIt;
//std::map<String<Iupac>,double > generalizedSortedPValueReversed;
generalizedSortedPValueIt = seq.generalizedSortedPValue.begin();
for(unsigned int i=0;i<100 && generalizedSortedPValueIt!=seq.generalizedSortedPValue.end() ;++i,++generalizedSortedPValueIt){
//std::cout<<length(seq.generalizedSortedPValue)<<" "<<seq.generalizedSortedPValue.size()<<" ";
std::cout<<(*generalizedSortedPValueIt).second<<" ";
if(seqCounter.find((*generalizedSortedPValueIt).second)!=seqCounter.end()) continue;
CountKmer(seqCounter,finder,(*generalizedSortedPValueIt).second,seq,IMap);
CountKmer(backCounter,finderB,(*generalizedSortedPValueIt).second,back,IMap);
}
seq.generalizedSortedPValue.clear();
//PrintMap(seqCounter,seq.SeqsNumber);
FisherExactTest(seqCounter,backCounter,seq,back);//computes the pValue of each Motif due to the counter
std::cout<<std::endl;
//PrintMap(seq.generalizedSortedPValue);
seqCounter.clear();
backCounter.clear();
}
#endif // #ifndef SANDBOX_MEYERCLP_APPS_DREME_H_
|
[
"mail@bkahlert.com"
] |
mail@bkahlert.com
|
a2236a870060d7e26fecef5b81fa79e56f29eb0b
|
1de331d068456cedbd2a5b4d4a6b16145646f97d
|
/test/libv/ctrl/test_control.cpp
|
398256dc4f872c3fcec84623118fc67d46c1ae04
|
[
"Zlib"
] |
permissive
|
sheerluck/libv
|
ed37015aeeb49ea8504d7b3aa48a69bde754708f
|
293e382f459f0acbc540de8ef6283782b38d2e63
|
refs/heads/master
| 2023-05-26T01:18:50.817268
| 2021-04-18T01:06:51
| 2021-04-27T03:20:36
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 45,136
|
cpp
|
// Project: libv.ctrl, File: test/libv/ctrl/test_control.cpp, Author: Császár Mátyás [Vader]
// hpp
#include <catch/catch.hpp>
// libv
#include <libv/input/event.hpp>
#include <libv/input/input.hpp>
#include <libv/utility/approx.hpp>
// pro
#include <libv/ctrl/combination.hpp>
#include <libv/ctrl/controls.hpp>
#include <libv/ctrl/input.hpp>
#include <libv/ctrl/parse.hpp>
#include <libv/ctrl/sequence.hpp>
#include "mock_feature.hpp"
// -------------------------------------------------------------------------------------------------
namespace {
namespace lc = libv::ctrl;
namespace li = libv::input;
auto parse(std::string_view str) {
return lc::parse_sequence_or_throw(str);
}
using MockFeatureAction = MockFeature<lc::arg_action_t>;
using MockFeatureAnalog = MockFeature<lc::arg_analog_t>;
using MockFeatureBinary = MockFeature<lc::arg_binary_t>;
const auto event_key_a_press = li::EventKey{li::Keycode::A, li::Scancode{30}, li::Action::press};
const auto event_key_a_release = li::EventKey{li::Keycode::A, li::Scancode{30}, li::Action::release};
const auto event_key_a_repeat = li::EventKey{li::Keycode::A, li::Scancode{30}, li::Action::repeat};
const auto event_key_s_press = li::EventKey{li::Keycode::S, li::Scancode{31}, li::Action::press};
const auto event_key_s_release = li::EventKey{li::Keycode::S, li::Scancode{31}, li::Action::release};
const auto event_key_s_repeat = li::EventKey{li::Keycode::S, li::Scancode{31}, li::Action::repeat};
//const auto event_key_d_press = li::EventKey{li::Keycode::D, li::Scancode{32}, li::Action::press};
//const auto event_key_d_release = li::EventKey{li::Keycode::D, li::Scancode{32}, li::Action::release};
//const auto event_key_d_repeat = li::EventKey{li::Keycode::D, li::Scancode{32}, li::Action::repeat};
//const auto event_key_f_press = li::EventKey{li::Keycode::F, li::Scancode{33}, li::Action::press};
//const auto event_key_f_release = li::EventKey{li::Keycode::F, li::Scancode{33}, li::Action::release};
//const auto event_key_f_repeat = li::EventKey{li::Keycode::F, li::Scancode{33}, li::Action::repeat};
const auto event_key_ctrl_press = li::EventKey{li::Keycode::ControlLeft, li::Scancode{29}, li::Action::press};
const auto event_key_ctrl_release = li::EventKey{li::Keycode::ControlLeft, li::Scancode{29}, li::Action::release};
const auto event_key_ctrl_repeat = li::EventKey{li::Keycode::ControlLeft, li::Scancode{29}, li::Action::repeat};
const auto event_mouse_x71_y73 = li::EventMousePosition{71.0, 73.0};
const auto event_mouse_x_p = li::EventMousePosition{1.0, 0.0};
const auto event_mouse_y_p = li::EventMousePosition{0.0, 1.0};
const auto event_mouse_x_m = li::EventMousePosition{-1.0, 0.0};
const auto event_mouse_y_m = li::EventMousePosition{0.0, -1.0};
const auto event_mouse_xy = li::EventMousePosition{1.0, 1.0};
const auto event_mouse_left_press = li::EventMouseButton{li::MouseButton::Left, li::Action::press};
const auto event_mouse_left_release = li::EventMouseButton{li::MouseButton::Left, li::Action::release};
} // namespace
// -------------------------------------------------------------------------------------------------
TEST_CASE("Control shall not execute any feature without input event", "[libv.control]") {
MockContext context;
lc::Controls controls;
MockFeatureAction feature_action;
MockFeatureAnalog feature_analog;
MockFeatureBinary feature_binary;
controls.feature_action<MockContext>("test.action", feature_action.callback());
controls.feature_analog<MockContext>("test.analog", feature_analog.callback());
controls.feature_binary<MockContext>("test.binary", feature_binary.callback());
controls.context_enter(&context);
controls.bind("test.action", parse("A"));
controls.bind("test.analog", parse("S"));
controls.bind("test.binary", parse("D"));
CHECK(feature_action.empty());
CHECK(feature_analog.empty());
CHECK(feature_binary.empty());
CHECK(context.access_count == 0);
}
TEST_CASE("Control shall execute features", "[libv.control]") {
MockContext context;
lc::Controls controls;
MockFeatureAction feature_action;
MockFeatureAnalog feature_analog;
MockFeatureBinary feature_binary;
MockFeatureAction feature_never_action;
MockFeatureAnalog feature_never_analog;
MockFeatureBinary feature_never_binary;
controls.feature_action<MockContext>("test.action", feature_action.callback());
controls.feature_analog<MockContext>("test.analog", feature_analog.callback());
controls.feature_binary<MockContext>("test.binary", feature_binary.callback());
controls.feature_action<MockContext>("never.action", feature_action.callback());
controls.feature_analog<MockContext>("never.analog", feature_analog.callback());
controls.feature_binary<MockContext>("never.binary", feature_binary.callback());
controls.context_enter(&context);
// --- Single Button -------------------------------------------------------------------------------
SECTION("Button [auto] bindings with press-T-repeat-T-release pass") {
controls.bind("test.action", parse("A [auto]"));
controls.bind("test.analog", parse("A [auto]"));
controls.bind("test.binary", parse("A [auto]"));
controls.bind("never.action", parse("B [auto]"));
controls.bind("never.analog", parse("B [auto]"));
controls.bind("never.binary", parse("B [auto]"));
controls.input(event_key_a_press);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
controls.update(std::chrono::seconds{1});
CHECK(feature_analog.consume_first());
controls.input(event_key_a_repeat);
CHECK(feature_action.consume_first());
controls.update(std::chrono::seconds{1});
CHECK(feature_analog.consume_first());
controls.input(event_key_a_release);
CHECK(feature_binary.consume_first() == lc::arg_binary_t{false});
controls.update(std::chrono::seconds{1});
CHECK(context.access_count == 6);
}
SECTION("Button [press] bindings with press-T-repeat-T-release pass") {
controls.bind("test.action", parse("A [press]"));
controls.bind("test.analog", parse("A [press]"));
controls.bind("test.binary", parse("A [press]"));
controls.bind("never.action", parse("B [press]"));
controls.bind("never.analog", parse("B [press]"));
controls.bind("never.binary", parse("B [press]"));
controls.input(event_key_a_press);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
CHECK(feature_analog.consume_first());
controls.update(std::chrono::seconds{1});
controls.input(event_key_a_repeat);
controls.update(std::chrono::seconds{1});
controls.input(event_key_a_release);
controls.update(std::chrono::seconds{1});
CHECK(context.access_count == 3);
}
SECTION("Button [repeat] bindings with press-T-repeat-T-release pass") {
controls.bind("test.action", parse("A [repeat]"));
controls.bind("test.analog", parse("A [repeat]"));
controls.bind("test.binary", parse("A [repeat]"));
controls.bind("never.action", parse("B [repeat]"));
controls.bind("never.analog", parse("B [repeat]"));
controls.bind("never.binary", parse("B [repeat]"));
controls.input(event_key_a_press);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
CHECK(feature_analog.consume_first());
controls.update(std::chrono::seconds{1});
controls.input(event_key_a_repeat);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
CHECK(feature_analog.consume_first());
controls.update(std::chrono::seconds{1});
controls.input(event_key_a_release);
controls.update(std::chrono::seconds{1});
CHECK(context.access_count == 6);
}
SECTION("Button [release] bindings with press-T-repeat-T-release pass") {
controls.bind("test.action", parse("A [release]"));
controls.bind("test.analog", parse("A [release]"));
controls.bind("test.binary", parse("A [release]"));
controls.bind("never.action", parse("B [release]"));
controls.bind("never.analog", parse("B [release]"));
controls.bind("never.binary", parse("B [release]"));
controls.input(event_key_a_press);
controls.update(std::chrono::seconds{1});
controls.input(event_key_a_repeat);
controls.update(std::chrono::seconds{1});
controls.input(event_key_a_release);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{false});
CHECK(feature_analog.consume_first());
controls.update(std::chrono::seconds{1});
CHECK(context.access_count == 3);
}
SECTION("Button [any] bindings with press-T-repeat-T-release pass") {
controls.bind("test.action", parse("A [any]"));
controls.bind("test.analog", parse("A [any]"));
controls.bind("test.binary", parse("A [any]"));
controls.bind("never.action", parse("B [any]"));
controls.bind("never.analog", parse("B [any]"));
controls.bind("never.binary", parse("B [any]"));
controls.input(event_key_a_press);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
CHECK(feature_analog.consume_first());
controls.update(std::chrono::seconds{1});
controls.input(event_key_a_repeat);
controls.update(std::chrono::seconds{1});
controls.input(event_key_a_release);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{false});
CHECK(feature_analog.consume_first());
controls.update(std::chrono::seconds{1});
CHECK(context.access_count == 6);
}
SECTION("Button [hold] bindings with press-T-repeat-T-release pass") {
controls.bind("test.action", parse("A [hold]"));
controls.bind("test.analog", parse("A [hold]"));
controls.bind("test.binary", parse("A [hold]"));
controls.bind("never.action", parse("B [hold]"));
controls.bind("never.analog", parse("B [hold]"));
controls.bind("never.binary", parse("B [hold]"));
controls.input(event_key_a_press);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
controls.update(std::chrono::seconds{1});
CHECK(feature_analog.consume_first());
controls.input(event_key_a_repeat);
CHECK(feature_action.consume_first());
controls.update(std::chrono::seconds{1});
CHECK(feature_analog.consume_first());
controls.input(event_key_a_release);
CHECK(feature_binary.consume_first() == lc::arg_binary_t{false});
controls.update(std::chrono::seconds{1});
CHECK(context.access_count == 6);
}
// SECTION("Button [free] bindings with press-T-repeat-T-release pass") {
// controls.bind("test.action", parse("A [free]"));
// controls.bind("test.analog", parse("A [free]"));
// controls.bind("test.binary", parse("A [free]"));
// controls.bind("never.action", parse("B [free]"));
// controls.bind("never.analog", parse("B [free]"));
// controls.bind("never.binary", parse("B [free]"));
//
// controls.input(event_key_a_press);
// CHECK(feature_binary.consume_first() == lc::arg_binary_t{false});
//
// controls.update(std::chrono::seconds{1});
// controls.input(event_key_a_repeat);
// controls.update(std::chrono::seconds{1});
//
// controls.input(event_key_a_release);
// CHECK(feature_action.consume_first());
// CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
//
// controls.update(std::chrono::seconds{1});
// CHECK(feature_analog.consume_first());
//
// CHECK(context.access_count == 4);
// }
SECTION("Analog [X] bindings with plus-T-minus pass") {
controls.bind("test.action", parse("MX"));
controls.bind("test.analog", parse("MX"));
controls.bind("test.binary", parse("MX"));
controls.bind("never.action", parse("MY"));
controls.bind("never.analog", parse("MY"));
controls.bind("never.binary", parse("MY"));
controls.input(event_mouse_x_p);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
CHECK(feature_analog.consume_first());
controls.update(std::chrono::seconds{1});
controls.input(event_mouse_x_m);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{false});
CHECK(feature_analog.consume_first());
controls.update(std::chrono::seconds{1});
CHECK(context.access_count == 6);
}
SECTION("Analog [X+] bindings with plus-T-minus pass") {
controls.bind("test.action", parse("MX+"));
controls.bind("test.analog", parse("MX+"));
controls.bind("test.binary", parse("MX+"));
controls.bind("never.action", parse("MY+"));
controls.bind("never.analog", parse("MY+"));
controls.bind("never.binary", parse("MY+"));
controls.input(event_mouse_x_p);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
CHECK(feature_analog.consume_first());
controls.update(std::chrono::seconds{1});
controls.input(event_mouse_x_m);
CHECK(feature_binary.consume_first() == lc::arg_binary_t{false});
controls.update(std::chrono::seconds{1});
CHECK(context.access_count == 4);
}
SECTION("Analog [X-] bindings with plus-T-minus pass") {
controls.bind("test.action", parse("MX-"));
controls.bind("test.analog", parse("MX-"));
controls.bind("test.binary", parse("MX-"));
controls.bind("never.action", parse("MY-"));
controls.bind("never.analog", parse("MY-"));
controls.bind("never.binary", parse("MY-"));
controls.input(event_mouse_x_p);
CHECK(feature_binary.consume_first() == lc::arg_binary_t{false});
controls.update(std::chrono::seconds{1});
controls.input(event_mouse_x_m);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
CHECK(feature_analog.consume_first());
controls.update(std::chrono::seconds{1});
CHECK(context.access_count == 4);
}
// --- Modifier with Single Button -----------------------------------------------------------------
SECTION("Modifier + Button [auto] bindings with press-T-repeat-T-release pass") {
controls.bind("test.action", parse("Ctrl [auto] + A [auto]"));
controls.bind("test.analog", parse("Ctrl [auto] + A [auto]"));
controls.bind("test.binary", parse("Ctrl [auto] + A [auto]"));
controls.bind("never.action", parse("Ctrl [auto] + B [auto]"));
controls.bind("never.analog", parse("Ctrl [auto] + B [auto]"));
controls.bind("never.binary", parse("Ctrl [auto] + B [auto]"));
controls.bind("never.action", parse("Shft [auto] + A [auto]"));
controls.bind("never.analog", parse("Shft [auto] + A [auto]"));
controls.bind("never.binary", parse("Shft [auto] + A [auto]"));
controls.input(event_key_ctrl_press);
controls.input(event_key_a_press);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
controls.update(std::chrono::seconds{1});
CHECK(feature_analog.consume_first());
controls.input(event_key_a_repeat);
CHECK(feature_action.consume_first());
controls.update(std::chrono::seconds{1});
CHECK(feature_analog.consume_first());
controls.input(event_key_a_release);
CHECK(feature_binary.consume_first() == lc::arg_binary_t{false});
controls.input(event_key_ctrl_release);
controls.update(std::chrono::seconds{1});
CHECK(context.access_count == 6);
}
SECTION("Modifier + Button [press] bindings with press-T-repeat-T-release pass") {
controls.bind("test.action", parse("Ctrl [auto] + A [press]"));
controls.bind("test.analog", parse("Ctrl [auto] + A [press]"));
controls.bind("test.binary", parse("Ctrl [auto] + A [press]"));
controls.bind("never.action", parse("Ctrl [auto] + B [press]"));
controls.bind("never.analog", parse("Ctrl [auto] + B [press]"));
controls.bind("never.binary", parse("Ctrl [auto] + B [press]"));
controls.bind("never.action", parse("Shft [auto] + A [press]"));
controls.bind("never.analog", parse("Shft [auto] + A [press]"));
controls.bind("never.binary", parse("Shft [auto] + A [press]"));
controls.input(event_key_ctrl_press);
controls.input(event_key_a_press);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
CHECK(feature_analog.consume_first());
controls.update(std::chrono::seconds{1});
controls.input(event_key_a_repeat);
controls.update(std::chrono::seconds{1});
controls.input(event_key_a_release);
controls.input(event_key_ctrl_release);
controls.update(std::chrono::seconds{1});
CHECK(context.access_count == 3);
}
SECTION("Modifier + Button [repeat] bindings with press-T-repeat-T-release pass") {
controls.bind("test.action", parse("Ctrl [auto] + A [repeat]"));
controls.bind("test.analog", parse("Ctrl [auto] + A [repeat]"));
controls.bind("test.binary", parse("Ctrl [auto] + A [repeat]"));
controls.bind("never.action", parse("Ctrl [auto] + B [repeat]"));
controls.bind("never.analog", parse("Ctrl [auto] + B [repeat]"));
controls.bind("never.binary", parse("Ctrl [auto] + B [repeat]"));
controls.bind("never.action", parse("Shft [auto] + A [repeat]"));
controls.bind("never.analog", parse("Shft [auto] + A [repeat]"));
controls.bind("never.binary", parse("Shft [auto] + A [repeat]"));
controls.input(event_key_ctrl_press);
controls.input(event_key_a_press);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
CHECK(feature_analog.consume_first());
controls.update(std::chrono::seconds{1});
controls.input(event_key_a_repeat);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
CHECK(feature_analog.consume_first());
controls.update(std::chrono::seconds{1});
controls.input(event_key_a_release);
controls.input(event_key_ctrl_release);
controls.update(std::chrono::seconds{1});
CHECK(context.access_count == 6);
}
SECTION("Modifier + Button [release] bindings with press-T-repeat-T-release pass") {
controls.bind("test.action", parse("Ctrl [auto] + A [release]"));
controls.bind("test.analog", parse("Ctrl [auto] + A [release]"));
controls.bind("test.binary", parse("Ctrl [auto] + A [release]"));
controls.bind("never.action", parse("Ctrl [auto] + B [release]"));
controls.bind("never.analog", parse("Ctrl [auto] + B [release]"));
controls.bind("never.binary", parse("Ctrl [auto] + B [release]"));
controls.bind("never.action", parse("Shft [auto] + A [release]"));
controls.bind("never.analog", parse("Shft [auto] + A [release]"));
controls.bind("never.binary", parse("Shft [auto] + A [release]"));
controls.input(event_key_ctrl_press);
controls.input(event_key_a_press);
controls.update(std::chrono::seconds{1});
controls.input(event_key_a_repeat);
controls.update(std::chrono::seconds{1});
controls.input(event_key_a_release);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{false});
CHECK(feature_analog.consume_first());
controls.input(event_key_ctrl_release);
controls.update(std::chrono::seconds{1});
CHECK(context.access_count == 3);
}
SECTION("Modifier + Button [any] bindings with press-T-repeat-T-release pass") {
controls.bind("test.action", parse("Ctrl [auto] + A [any]"));
controls.bind("test.analog", parse("Ctrl [auto] + A [any]"));
controls.bind("test.binary", parse("Ctrl [auto] + A [any]"));
controls.bind("never.action", parse("Ctrl [auto] + B [any]"));
controls.bind("never.analog", parse("Ctrl [auto] + B [any]"));
controls.bind("never.binary", parse("Ctrl [auto] + B [any]"));
controls.bind("never.action", parse("Shft [auto] + A [any]"));
controls.bind("never.analog", parse("Shft [auto] + A [any]"));
controls.bind("never.binary", parse("Shft [auto] + A [any]"));
controls.input(event_key_ctrl_press);
controls.input(event_key_a_press);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
CHECK(feature_analog.consume_first());
controls.update(std::chrono::seconds{1});
controls.input(event_key_a_repeat);
controls.update(std::chrono::seconds{1});
controls.input(event_key_a_release);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{false});
CHECK(feature_analog.consume_first());
controls.input(event_key_ctrl_release);
controls.update(std::chrono::seconds{1});
CHECK(context.access_count == 6);
}
SECTION("Modifier + Button [hold] bindings with press-T-repeat-T-release pass") {
controls.bind("test.action", parse("Ctrl [auto] + A [hold]"));
controls.bind("test.analog", parse("Ctrl [auto] + A [hold]"));
controls.bind("test.binary", parse("Ctrl [auto] + A [hold]"));
controls.bind("never.action", parse("Ctrl [auto] + B [hold]"));
controls.bind("never.analog", parse("Ctrl [auto] + B [hold]"));
controls.bind("never.binary", parse("Ctrl [auto] + B [hold]"));
controls.bind("never.action", parse("Shft [auto] + A [hold]"));
controls.bind("never.analog", parse("Shft [auto] + A [hold]"));
controls.bind("never.binary", parse("Shft [auto] + A [hold]"));
controls.input(event_key_ctrl_press);
controls.input(event_key_a_press);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
controls.update(std::chrono::seconds{1});
CHECK(feature_analog.consume_first());
controls.input(event_key_a_repeat);
CHECK(feature_action.consume_first());
controls.update(std::chrono::seconds{1});
CHECK(feature_analog.consume_first());
controls.input(event_key_a_release);
CHECK(feature_binary.consume_first() == lc::arg_binary_t{false});
controls.input(event_key_ctrl_release);
controls.update(std::chrono::seconds{1});
CHECK(context.access_count == 6);
}
// SECTION("Modifier + Button [free] bindings with press-T-repeat-T-release pass") {
// controls.bind("test.action", parse("Ctrl [auto] + A [free]"));
// controls.bind("test.analog", parse("Ctrl [auto] + A [free]"));
// controls.bind("test.binary", parse("Ctrl [auto] + A [free]"));
// controls.bind("never.action", parse("Ctrl [auto] + B [free]"));
// controls.bind("never.analog", parse("Ctrl [auto] + B [free]"));
// controls.bind("never.binary", parse("Ctrl [auto] + B [free]"));
// controls.bind("never.action", parse("Shft [auto] + A [free]"));
// controls.bind("never.analog", parse("Shft [auto] + A [free]"));
// controls.bind("never.binary", parse("Shft [auto] + A [free]"));
//
// controls.input(event_key_ctrl_press);
// controls.input(event_key_a_press);
// CHECK(feature_binary.consume_first() == lc::arg_binary_t{false});
//
// controls.update(std::chrono::seconds{1});
// controls.input(event_key_a_repeat);
// controls.update(std::chrono::seconds{1});
//
// controls.input(event_key_a_release);
// CHECK(feature_action.consume_first());
// CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
//
// controls.input(event_key_ctrl_release);
// controls.update(std::chrono::seconds{1});
// CHECK(feature_analog.consume_first());
//
// CHECK(context.access_count == 4);
// }
SECTION("Modifier + Analog [X] bindings with plus-T-minus pass") {
controls.bind("test.action", parse("Ctrl + MX"));
controls.bind("test.analog", parse("Ctrl + MX"));
controls.bind("test.binary", parse("Ctrl + MX"));
controls.bind("never.action", parse("Ctrl + A"));
controls.bind("never.analog", parse("Ctrl + A"));
controls.bind("never.binary", parse("Ctrl + A"));
controls.bind("never.action", parse("Ctrl + MY"));
controls.bind("never.analog", parse("Ctrl + MY"));
controls.bind("never.binary", parse("Ctrl + MY"));
controls.bind("never.action", parse("Shft + MX"));
controls.bind("never.analog", parse("Shft + MX"));
controls.bind("never.binary", parse("Shft + MX"));
controls.input(event_key_ctrl_press);
controls.input(event_mouse_x_p);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
CHECK(feature_analog.consume_first());
controls.update(std::chrono::seconds{1});
controls.input(event_mouse_x_m);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{false});
CHECK(feature_analog.consume_first());
controls.input(event_key_ctrl_release);
controls.update(std::chrono::seconds{1});
CHECK(context.access_count == 6);
}
SECTION("Modifier + Analog [X+] bindings with plus-T-minus pass") {
controls.bind("test.action", parse("Ctrl + MX+"));
controls.bind("test.analog", parse("Ctrl + MX+"));
controls.bind("test.binary", parse("Ctrl + MX+"));
controls.bind("never.action", parse("Ctrl + A"));
controls.bind("never.analog", parse("Ctrl + A"));
controls.bind("never.binary", parse("Ctrl + A"));
controls.bind("never.action", parse("Ctrl + MY+"));
controls.bind("never.analog", parse("Ctrl + MY+"));
controls.bind("never.binary", parse("Ctrl + MY+"));
controls.bind("never.action", parse("Shft + MX+"));
controls.bind("never.analog", parse("Shft + MX+"));
controls.bind("never.binary", parse("Shft + MX+"));
controls.input(event_key_ctrl_press);
controls.input(event_mouse_x_p);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
CHECK(feature_analog.consume_first());
controls.update(std::chrono::seconds{1});
controls.input(event_mouse_x_m);
CHECK(feature_binary.consume_first() == lc::arg_binary_t{false});
controls.input(event_key_ctrl_release);
controls.update(std::chrono::seconds{1});
CHECK(context.access_count == 4);
}
SECTION("Modifier + Analog [X-] bindings with plus-T-minus pass") {
controls.bind("test.action", parse("Ctrl + MX-"));
controls.bind("test.analog", parse("Ctrl + MX-"));
controls.bind("test.binary", parse("Ctrl + MX-"));
controls.bind("never.action", parse("Ctrl + A"));
controls.bind("never.analog", parse("Ctrl + A"));
controls.bind("never.binary", parse("Ctrl + A"));
controls.bind("never.action", parse("Ctrl + MY-"));
controls.bind("never.analog", parse("Ctrl + MY-"));
controls.bind("never.binary", parse("Ctrl + MY-"));
controls.bind("never.action", parse("Shft + MX-"));
controls.bind("never.analog", parse("Shft + MX-"));
controls.bind("never.binary", parse("Shft + MX-"));
controls.input(event_key_ctrl_press);
controls.input(event_mouse_x_p);
CHECK(feature_binary.consume_first() == lc::arg_binary_t{false});
controls.update(std::chrono::seconds{1});
controls.input(event_mouse_x_m);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
CHECK(feature_analog.consume_first());
controls.input(event_key_ctrl_release);
controls.update(std::chrono::seconds{1});
CHECK(context.access_count == 4);
}
// --- Modifier + Single Button into Single Button sequence ---------------------------------
SECTION("Modifier + Button [auto], Button [auto] bindings with press-T-repeat-T-release pass") {
controls.bind("test.action", parse("Ctrl [auto] + A [auto], A [auto]"));
controls.bind("test.analog", parse("Ctrl [auto] + A [auto], A [auto]"));
controls.bind("test.binary", parse("Ctrl [auto] + A [auto], A [auto]"));
controls.bind("never.action", parse("Ctrl [auto] + A [auto], B [auto]"));
controls.bind("never.analog", parse("Ctrl [auto] + A [auto], B [auto]"));
controls.bind("never.binary", parse("Ctrl [auto] + A [auto], B [auto]"));
controls.bind("never.action", parse("Ctrl [auto] + B [auto], A [auto]"));
controls.bind("never.analog", parse("Ctrl [auto] + B [auto], A [auto]"));
controls.bind("never.binary", parse("Ctrl [auto] + B [auto], A [auto]"));
controls.bind("never.action", parse("Shft [auto] + A [auto], A [auto]"));
controls.bind("never.analog", parse("Shft [auto] + A [auto], A [auto]"));
controls.bind("never.binary", parse("Shft [auto] + A [auto], A [auto]"));
controls.bind("never.action", parse("Shft [auto] + A [auto]"));
controls.bind("never.analog", parse("Shft [auto] + A [auto]"));
controls.bind("never.binary", parse("Shft [auto] + A [auto]"));
SECTION("Sequence activation 1a") {
controls.input(event_key_ctrl_press);
controls.input(event_key_a_press);
}
SECTION("Sequence activation 1b") {
controls.input(event_key_a_press);
controls.input(event_key_ctrl_press);
}
SECTION("Sequence activation 2a") {
controls.input(event_key_ctrl_press);
controls.input(event_key_a_press);
controls.input(event_key_ctrl_release);
}
SECTION("Sequence activation 2b") {
controls.input(event_key_a_press);
controls.input(event_key_ctrl_press);
controls.input(event_key_ctrl_release);
}
SECTION("Sequence activation 3a") {
controls.input(event_key_ctrl_press);
controls.input(event_key_a_press);
controls.input(event_key_a_release);
}
SECTION("Sequence activation 3b") {
controls.input(event_key_a_press);
controls.input(event_key_ctrl_press);
controls.input(event_key_a_release);
}
SECTION("Sequence activation 4a") {
controls.input(event_key_ctrl_press);
controls.input(event_key_a_press);
controls.input(event_key_a_release);
controls.input(event_key_ctrl_release);
}
SECTION("Sequence activation 4b") {
controls.input(event_key_a_press);
controls.input(event_key_ctrl_press);
controls.input(event_key_ctrl_release);
controls.input(event_key_a_release);
}
SECTION("Sequence activation 5a") {
controls.input(event_key_ctrl_press);
controls.input(event_key_a_press);
controls.input(event_key_ctrl_release);
controls.input(event_key_a_release);
}
SECTION("Sequence activation 5b") {
controls.input(event_key_a_press);
controls.input(event_key_ctrl_press);
controls.input(event_key_a_release);
controls.input(event_key_ctrl_release);
}
controls.input(event_key_a_press);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
controls.update(std::chrono::seconds{1});
CHECK(feature_analog.consume_first());
controls.input(event_key_a_repeat);
CHECK(feature_action.consume_first());
controls.update(std::chrono::seconds{1});
CHECK(feature_analog.consume_first());
controls.input(event_key_a_release);
CHECK(feature_binary.consume_first() == lc::arg_binary_t{false});
controls.update(std::chrono::seconds{1});
CHECK(context.access_count == 6);
}
SECTION("Modifier + Button [press], Button [auto] bindings with press-T-repeat-T-release pass") {
controls.bind("test.action", parse("Ctrl [auto] + A [press], A [auto]"));
controls.bind("test.analog", parse("Ctrl [auto] + A [press], A [auto]"));
controls.bind("test.binary", parse("Ctrl [auto] + A [press], A [auto]"));
controls.bind("never.action", parse("Ctrl [auto] + A [press], B [auto]"));
controls.bind("never.analog", parse("Ctrl [auto] + A [press], B [auto]"));
controls.bind("never.binary", parse("Ctrl [auto] + A [press], B [auto]"));
controls.bind("never.action", parse("Ctrl [auto] + B [press], A [auto]"));
controls.bind("never.analog", parse("Ctrl [auto] + B [press], A [auto]"));
controls.bind("never.binary", parse("Ctrl [auto] + B [press], A [auto]"));
controls.bind("never.action", parse("Shft [auto] + A [press], A [auto]"));
controls.bind("never.analog", parse("Shft [auto] + A [press], A [auto]"));
controls.bind("never.binary", parse("Shft [auto] + A [press], A [auto]"));
controls.bind("never.action", parse("Shft [auto] + A [press]"));
controls.bind("never.analog", parse("Shft [auto] + A [press]"));
controls.bind("never.binary", parse("Shft [auto] + A [press]"));
SECTION("Sequence activation 1a") {
controls.input(event_key_ctrl_press);
controls.input(event_key_a_press);
}
SECTION("Sequence activation 2a") {
controls.input(event_key_ctrl_press);
controls.input(event_key_a_press);
controls.input(event_key_ctrl_release);
}
SECTION("Sequence activation 3a") {
controls.input(event_key_ctrl_press);
controls.input(event_key_a_press);
controls.input(event_key_a_release);
}
SECTION("Sequence activation 4a") {
controls.input(event_key_ctrl_press);
controls.input(event_key_a_press);
controls.input(event_key_a_release);
controls.input(event_key_ctrl_release);
}
SECTION("Sequence activation 5a") {
controls.input(event_key_ctrl_press);
controls.input(event_key_a_press);
controls.input(event_key_ctrl_release);
controls.input(event_key_a_release);
}
controls.input(event_key_a_press);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
controls.update(std::chrono::seconds{1});
CHECK(feature_analog.consume_first());
controls.input(event_key_a_repeat);
CHECK(feature_action.consume_first());
controls.update(std::chrono::seconds{1});
CHECK(feature_analog.consume_first());
controls.input(event_key_a_release);
CHECK(feature_binary.consume_first() == lc::arg_binary_t{false});
controls.update(std::chrono::seconds{1});
CHECK(context.access_count == 6);
}
SECTION("Modifier + Button [release], Button [repeat] bindings with press-T-repeat-T-release pass") {
controls.bind("test.action", parse("Ctrl [auto] + A [release], A [repeat]"));
controls.bind("test.analog", parse("Ctrl [auto] + A [release], A [repeat]"));
controls.bind("test.binary", parse("Ctrl [auto] + A [release], A [repeat]"));
controls.bind("never.action", parse("Ctrl [auto] + A [release], B [repeat]"));
controls.bind("never.analog", parse("Ctrl [auto] + A [release], B [repeat]"));
controls.bind("never.binary", parse("Ctrl [auto] + A [release], B [repeat]"));
controls.bind("never.action", parse("Ctrl [auto] + B [release], A [repeat]"));
controls.bind("never.analog", parse("Ctrl [auto] + B [release], A [repeat]"));
controls.bind("never.binary", parse("Ctrl [auto] + B [release], A [repeat]"));
controls.bind("never.action", parse("Shft [auto] + A [release], A [repeat]"));
controls.bind("never.analog", parse("Shft [auto] + A [release], A [repeat]"));
controls.bind("never.binary", parse("Shft [auto] + A [release], A [repeat]"));
controls.bind("never.action", parse("Shft [auto] + A [release]"));
controls.bind("never.analog", parse("Shft [auto] + A [release]"));
controls.bind("never.binary", parse("Shft [auto] + A [release]"));
SECTION("Sequence activation 3a") {
controls.input(event_key_ctrl_press);
controls.input(event_key_a_press);
controls.input(event_key_a_release);
}
SECTION("Sequence activation 3b") {
controls.input(event_key_a_press);
controls.input(event_key_ctrl_press);
controls.input(event_key_a_release);
}
SECTION("Sequence activation 4a") {
controls.input(event_key_ctrl_press);
controls.input(event_key_a_press);
controls.input(event_key_a_release);
controls.input(event_key_ctrl_release);
}
SECTION("Sequence activation 5b") {
controls.input(event_key_a_press);
controls.input(event_key_ctrl_press);
controls.input(event_key_a_release);
controls.input(event_key_ctrl_release);
}
controls.input(event_key_a_press);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
CHECK(feature_analog.consume_first());
controls.update(std::chrono::seconds{1});
controls.input(event_key_a_repeat);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
CHECK(feature_analog.consume_first());
controls.update(std::chrono::seconds{1});
controls.input(event_key_a_release);
controls.update(std::chrono::seconds{1});
CHECK(context.access_count == 6);
}
// -------------------------------------------------------------------------------------------------
CHECK(feature_action.empty());
CHECK(feature_analog.empty());
CHECK(feature_binary.empty());
CHECK(feature_never_action.empty());
CHECK(feature_never_analog.empty());
CHECK(feature_never_binary.empty());
}
TEST_CASE("Select more specialized binding in case of collision", "[libv.control]") {
MockContext context;
lc::Controls controls;
MockFeatureAction feature_action;
MockFeatureAction feature_never_action;
controls.feature_action<MockContext>("test.action", feature_action.callback());
controls.feature_action<MockContext>("never.action", feature_action.callback());
controls.context_enter(&context);
controls.bind("test.action", parse("Ctrl + A"));
controls.bind("never.action", parse("A"));
controls.input(event_key_ctrl_press);
controls.input(event_key_a_press);
controls.input(event_key_a_release);
controls.input(event_key_ctrl_release);
CHECK(feature_action.consume_first());
CHECK(context.access_count == 1);
CHECK(feature_action.empty());
CHECK(feature_never_action.empty());
}
TEST_CASE("Reset sequence on unrelated event", "[libv.control]") {
MockContext context;
lc::Controls controls;
MockFeatureAction feature_action;
MockFeatureAnalog feature_analog;
MockFeatureBinary feature_binary;
MockFeatureAction feature_never_action;
MockFeatureAnalog feature_never_analog;
MockFeatureBinary feature_never_binary;
controls.feature_action<MockContext>("test.action", feature_action.callback());
controls.feature_analog<MockContext>("test.analog", feature_analog.callback());
controls.feature_binary<MockContext>("test.binary", feature_binary.callback());
controls.feature_action<MockContext>("never.action", feature_action.callback());
controls.feature_analog<MockContext>("never.analog", feature_analog.callback());
controls.feature_binary<MockContext>("never.binary", feature_binary.callback());
controls.context_enter(&context);
SECTION("Unrelated event and timeout cancels sequence") {
controls.bind("test.action", parse("Ctrl + A, A"));
controls.bind("test.analog", parse("Ctrl + A, A"));
controls.bind("test.binary", parse("Ctrl + A, A"));
{
controls.input(event_key_ctrl_press);
controls.input(event_key_a_press);
controls.input(event_key_a_release);
controls.input(event_key_ctrl_release);
controls.input(event_key_s_press); // <- unrelated button event
controls.input(event_key_a_press);
controls.update(std::chrono::seconds{1});
controls.input(event_key_a_repeat);
controls.update(std::chrono::seconds{1});
controls.input(event_key_a_release);
controls.update(std::chrono::seconds{1});
}
// Nothing so far, try again
{
controls.input(event_key_ctrl_press);
controls.input(event_key_a_press);
controls.input(event_key_a_release);
controls.input(event_key_ctrl_release);
controls.input(event_key_a_press);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
controls.update(std::chrono::seconds{1});
CHECK(feature_analog.consume_first());
controls.input(event_key_a_repeat);
CHECK(feature_action.consume_first());
controls.update(std::chrono::seconds{1});
CHECK(feature_analog.consume_first());
controls.input(event_key_a_release);
CHECK(feature_binary.consume_first() == lc::arg_binary_t{false});
controls.update(std::chrono::seconds{1});
}
// Try again with cancelling
{
controls.input(event_key_ctrl_press);
controls.input(event_key_a_press);
controls.input(event_key_a_release);
controls.input(event_key_ctrl_release);
controls.input(event_mouse_x_p); // <- unrelated analog event
controls.input(event_key_a_press);
controls.update(std::chrono::seconds{1});
controls.input(event_key_a_repeat);
controls.update(std::chrono::seconds{1});
controls.input(event_key_a_release);
controls.update(std::chrono::seconds{1});
}
// Nothing so far, try again
{
controls.input(event_key_ctrl_press);
controls.input(event_key_a_press);
controls.input(event_key_a_release);
controls.input(event_key_ctrl_release);
controls.input(event_key_a_press);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
controls.update(std::chrono::seconds{1});
CHECK(feature_analog.consume_first());
controls.input(event_key_a_repeat);
CHECK(feature_action.consume_first());
controls.update(std::chrono::seconds{1});
CHECK(feature_analog.consume_first());
controls.input(event_key_a_release);
CHECK(feature_binary.consume_first() == lc::arg_binary_t{false});
controls.update(std::chrono::seconds{1});
}
// Try again with cancelling
{
controls.input(event_key_ctrl_press);
controls.input(event_key_a_press);
controls.input(event_key_a_release);
controls.input(event_key_ctrl_release);
controls.update(std::chrono::seconds{300}); // <- timeout
controls.input(event_key_a_press);
controls.update(std::chrono::seconds{1});
controls.input(event_key_a_repeat);
controls.update(std::chrono::seconds{1});
controls.input(event_key_a_release);
controls.update(std::chrono::seconds{1});
}
// Nothing so far, try again
{
controls.input(event_key_ctrl_press);
controls.input(event_key_a_press);
controls.input(event_key_a_release);
controls.input(event_key_ctrl_release);
controls.input(event_key_a_press);
CHECK(feature_action.consume_first());
CHECK(feature_binary.consume_first() == lc::arg_binary_t{true});
controls.update(std::chrono::seconds{1});
CHECK(feature_analog.consume_first());
controls.input(event_key_a_repeat);
CHECK(feature_action.consume_first());
controls.update(std::chrono::seconds{1});
CHECK(feature_analog.consume_first());
controls.input(event_key_a_release);
CHECK(feature_binary.consume_first() == lc::arg_binary_t{false});
controls.update(std::chrono::seconds{1});
}
CHECK(context.access_count == 18);
}
CHECK(feature_action.empty());
CHECK(feature_analog.empty());
CHECK(feature_binary.empty());
CHECK(feature_never_action.empty());
CHECK(feature_never_analog.empty());
CHECK(feature_never_binary.empty());
}
TEST_CASE("Routing scale and impulse", "[libv.control]") {
MockContext context;
lc::Controls controls;
MockFeatureAnalog feature_abi;
MockFeatureAnalog feature_abt0;
MockFeatureAnalog feature_abt1;
MockFeatureAnalog feature_aas;
controls.feature_analog<MockContext>("test.abi", feature_abi.callback(), 2, 3, 59);
controls.feature_analog<MockContext>("test.abt0", feature_abt0.callback(), 5, 7, 61);
controls.feature_analog<MockContext>("test.abt1", feature_abt1.callback(), 83, 89, 97);
controls.feature_analog<MockContext>("test.aas", feature_aas.callback(), 11, 13, 67);
controls.context_enter(&context);
// 2, 3, 5, 7, 11, 13,
// 17, 19, 23, 29, 37, 41,
// 43, 47, 53,
// 59, 61, 67,
// 71, 73,
// 79, 83, 89, 97,
// 101,
// 31, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151,
// 157, 163, 167, 173, 179, 181, 191, 193, 197, 199
controls.bind("test.abi", parse("A [repeat]"), 17);
controls.bind("test.abt0", parse("A [hold]"), 19);
controls.bind("test.abt1", parse("LMB"), 79);
controls.bind("test.aas", parse("Mouse X"), 23);
using ap = libv::Approx<lc::scale_type>;
const auto get_or_nan = [](auto& feature) {
const auto value = feature.consume_first();
return value ? value->value : std::numeric_limits<lc::scale_type>::quiet_NaN();
};
controls.impulse_keyboard(29);
controls.impulse_mouse_button(101);
controls.scale_mouse_move(37);
controls.scale_time(41);
{
controls.input(event_key_a_press);
CHECK(get_or_nan(feature_abi) == ap(2 * 17 * 29));
controls.input(event_mouse_x71_y73);
CHECK(get_or_nan(feature_aas) == ap(67 * 23 * 37 * 71 * lc::MOUSE_NORMALIZATION_SCALE));
controls.update(std::chrono::seconds{43});
CHECK(get_or_nan(feature_abt0) == ap(7 * 19 * 41 * 43));
controls.input(event_key_a_repeat);
CHECK(get_or_nan(feature_abi) == ap(2 * 17 * 29));
controls.update(std::chrono::seconds{47});
CHECK(get_or_nan(feature_abt0) == ap(7 * 19 * 41 * 47));
controls.input(event_key_a_release);
controls.input(event_mouse_left_press);
controls.update(std::chrono::seconds{107});
CHECK(get_or_nan(feature_abt1) == ap(41 * 107 * 79 * 89));
controls.input(event_mouse_left_release);
controls.update(std::chrono::seconds{53});
CHECK(context.access_count == 6);
}
CHECK(feature_abi.empty());
CHECK(feature_abt0.empty());
CHECK(feature_aas.empty());
}
//TEST_CASE("Feature execution with context", "[libv.control]") { }
//TEST_CASE("Feature execution with overloaded context", "[libv.control]") { }
//TEST_CASE("Feature execution with void context", "[libv.control]") { }
//TEST_CASE("Feature no execution without context", "[libv.control]") { }
//
//TEST_CASE("Context overloading features with the same names", "[libv.control]") { }
//TEST_CASE("Context overloading features stack push", "[libv.control]") { }
//TEST_CASE("Context overloading features stack pop", "[libv.control]") { }
//
//TEST_CASE("Missing context means no features activity", "[libv.control]") { }
//TEST_CASE("Enter context with instant binding fulfilment causes features activity", "[libv.control]") { }
//TEST_CASE("Leave context with fulfilled bindings causes features activity", "[libv.control]") { }
//TEST_CASE("New binding with instant fulfilment causes features activity", "[libv.control]") { }
|
[
"vaderhun@gmail.com"
] |
vaderhun@gmail.com
|
77dcdd2161e34f499654fd72ac479e499ccede05
|
7d9234263d39268430c7447fad7981c4bd10fed3
|
/Welfare/PrePrintDlg.cpp
|
16018a54b27f4e76787aab316a01b74b076326f2
|
[] |
no_license
|
shallots/welfare_wyf
|
ebba6b71b29a577d047bdc9bb4a214abb194e41c
|
dee085dec47d7dce279ddf7902da9b4b81ca57a6
|
refs/heads/master
| 2021-01-17T10:06:35.708346
| 2016-04-25T02:34:35
| 2016-04-25T02:34:35
| 18,440,920
| 3
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 9,775
|
cpp
|
// PrePrintDlg.cpp : 实现文件
//
#include "stdafx.h"
#include "Welfare.h"
#include "PrePrintDlg.h"
#include "afxdialogex.h"
// 定义控件ID
//#define IDC_RSC_PAIRS 5201
//#define IDC_RSC_PLIST 5202
//#define IDC_RSC_NONPAIRS 5203
//#define IDC_RSC_NLIST 5204
//#define IDC_GOS_PAIRS 5205
//#define IDC_GOS_PLIST 5206
//#define IDC_GOS_NONPAIRS 5202
//#define IDC_GOS_NLIST 5207
// CPrePrintDlg 对话框
IMPLEMENT_DYNAMIC(CPrePrintDlg, CDialogEx)
CPrePrintDlg::CPrePrintDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(CPrePrintDlg::IDD, pParent)
{
}
CPrePrintDlg::~CPrePrintDlg()
{
}
void CPrePrintDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_EXPORT2, m_export2);
DDX_Control(pDX, IDC_GOS, m_gos);
DDX_Control(pDX, IDC_PREVIEW, m_preView);
DDX_Control(pDX, IDC_RSC, m_rsc);
DDX_Control(pDX, IDC_STATIC_GOS, m_static_gos);
DDX_Control(pDX, IDC_STATIC_RSC, m_static_rsc);
DDX_Control(pDX, IDC_GOS_NLIST, m_gosNList);
//DDX_Control(pDX, IDC_GOS_PLIST, m_gosPList);
DDX_Control(pDX, IDC_RSC_NLIST, m_rscNList);
//DDX_Control(pDX, IDC_RSC_PLIST, m_rscPList);
DDX_Control(pDX, IDC_STATIC_GOS_NONPAIR, m_sgosNonpair);
//DDX_Control(pDX, IDC_STATIC_GOS_PAIR, m_sgosPair);
DDX_Control(pDX, IDC_STATIC_RSC_NONPAIR, m_srscNonpair);
//DDX_Control(pDX, IDC_STATIC_RSC_PAIR, m_srscPair);
}
BEGIN_MESSAGE_MAP(CPrePrintDlg, CDialogEx)
ON_BN_CLICKED(IDC_PREVIEW, &CPrePrintDlg::OnBnClickedPreview)
ON_BN_CLICKED(IDC_EXPORT2, &CPrePrintDlg::OnBnClickedExport2)
END_MESSAGE_MAP()
void CPrePrintDlg::OnOK()
{
NextDlgCtrl();
}
void CPrePrintDlg::OnCancel()
{
//if (CanExit())
// CDialogEx::OnCancel();
int key=0;
if(!resSave)
{
key = MessageBox(_T("不导出结果关闭?"),_T("关闭?"),MB_OKCANCEL);
}else{
key = IDOK;
}
if(key == IDOK)
CDialog::OnCancel();
}
//BOOL IsPair(CString code)
//{
// int length = code.GetLength();
// if(length <= 0)
// return false;
// char *p = (LPSTR)(LPCTSTR)code;
// if( *p == *(p+2) || *p == *(p+4) || *(p+2) == *(p+4))
// {
// return true;
// }
// return false;
//}
// CPrePrintDlg 消息处理程序
BOOL CPrePrintDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: 在此添加额外的初始化
resSave = TRUE;
totalAmount = 0;
totalCount = 0;
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
BOOL isInPlusTail(int tailVal, vector<int> plusTail)
{
for(vector<int>::iterator it = plusTail.begin(); it != plusTail.end(); it++)
{
if(tailVal == *it)
return TRUE;
}
return FALSE;
}
BOOL isPair(vector<CodeType>::iterator code)
{
if(code->codeSeq[0] == code->codeSeq[1] || code->codeSeq[0] == code->codeSeq[2]
|| code->codeSeq[1] == code->codeSeq[2])
return TRUE;
return FALSE;
}
void CPrePrintDlg::OnBnClickedPreview()
{
// TODO: 在此添加控件通知处理程序代码
vector<int> arrkc[2]; // 单选单复式和组选和尾值数字序列
CString csstr[2]; // 单选单复式和组选和尾值
m_rsc.GetWindowTextW(csstr[0]);
m_gos.GetWindowTextW(csstr[1]);
// 取得两组筛选码
if(csstr[0].GetLength()||csstr[1].GetLength())
{
for(int i=0; i<2; i++)
{
int length = csstr[i].GetLength();
char *p = (LPSTR)(LPCTSTR)csstr[i];
for(int j=0; j<2*length; j=j+2)
{
int tmp = *(p+j) - 48;
arrkc[i].push_back(tmp);
}
}
}else{
MessageBox(_T("请输入筛选和值尾!"));
return;
}
m_rscNList.ResetContent();
m_gosNList.ResetContent();
// 遍历3D码,分别插入对应的列表中
for(vector<CodeType>::iterator it = cParentWnd->ec->dvCode.begin(); it!=cParentWnd->ec->dvCode.end(); it++)
{
CString tmp;
tmp.Format(_T("%d%d%d-%d"),it->codeSeq[0],it->codeSeq[1],it->codeSeq[2],it->mantissa);
if(isInPlusTail(it->mantissa,arrkc[0]))
{
if(isPair(it))
{
//m_rscPList.AddString(tmp);
}else{
m_rscNList.AddString(tmp);
}
}else if(isInPlusTail(it->mantissa,arrkc[1]))
{
if(isPair(it))
{
//m_gosPList.AddString(tmp);
}else{
m_gosNList.AddString(tmp);
}
}
}
// 统计信息
//int nrscPList = m_rscPList.GetCount(); // 单选单复式对子3D码个数
//int nrscPAmount = nrscPList * 6 ; // 单选单复式对子3D码投注金额
int nrscNList = m_rscNList.GetCount(); // 单选单复式非对子3D码个数
int nrscNAmount = nrscNList * 12 ; // 单选单复式非对子3D码投注金额
int nrscTAmount = nrscNAmount; // 单选单复式3D码投注金额小计
//int ngosPList = m_gosPList.GetCount(); // 组选对子个数
//int ngosPAmount = ngosPList * 2; // 组选对子金额
int ngosNList = m_gosNList.GetCount(); // 组选非对子个数
int ngosNAmount = ngosNList * 2; // 组选非对子金额
int ngosTAmount = ngosNAmount; // 组选非对子金额小计
totalCount = nrscNList + ngosNList;
totalAmount = nrscTAmount + ngosTAmount;
CString text;
CString tmp;
tmp.Format(_T("※ 单选单复式 ( 共 %d 注,投注金额: ¥%d.00 )"),nrscNList,nrscTAmount);
text += tmp;
m_static_rsc.SetWindowTextW(text);
text.Empty();
tmp.Empty();
tmp.Format(_T("非对子 ( 共 %d 注,投注金额: ¥%d.00 )"),nrscNList,nrscNAmount);
text += tmp;
m_srscNonpair.SetWindowTextW(text);
text.Empty();
tmp.Empty();
/*
m_srscPair.GetWindowTextW(text);
tmp.Format(_T(" ( 共 %d 注,投注金额: ¥%d.00 )"),nrscPList,nrscPAmount);
text += tmp;
m_srscPair.SetWindowTextW(text);
text.Empty();
tmp.Empty();
*/
//m_sgosNonpair.GetWindowTextW(text);
tmp.Format(_T(" 非对子( 共 %d 注,投注金额: ¥%d.00 )"),ngosNList,ngosNAmount);
text += tmp;
m_sgosNonpair.SetWindowTextW(text);
text.Empty();
tmp.Empty();
/*
m_sgosPair.GetWindowTextW(text);
tmp.Format(_T(" ( 共 %d 注,投注金额: ¥%d.00 )"),ngosPList,ngosPAmount);
text += tmp;
m_sgosPair.SetWindowTextW(text);
text.Empty();
tmp.Empty();
*/
//m_static_gos.GetWindowTextW(text);
tmp.Format(_T(" ※ 组选 ( 共 %d 注,投注金额: ¥%d.00 )"),ngosNList,ngosTAmount);
text += tmp;
m_static_gos.SetWindowTextW(text);
text.Empty();
tmp.Empty();
UpdateWindow();
resSave = FALSE;
}
void CPrePrintDlg::OnBnClickedExport2()
{
// TODO: 在此添加控件通知处理程序代码
if(resSave)
{
MessageBox(_T("请预览后再导出,^_^!!"));
return;
}
int countnrsc = m_rscNList.GetCount();
//int countprsc = m_rscPList.GetCount();
int countngos = m_gosNList.GetCount();
//int countpgos = m_gosPList.GetCount();
if(totalCount <= 0)
{
MessageBox(_T("列表3D编码为空,无需导出"));
return;
}
TCHAR szFilter[] = _T("Word文件(*.doc)|*.doc|文本文件(*.txt)|*.txt|所有文件(*.*)|*.*||");
TCHAR *filename = NULL;
CString cf;
cParentWnd->m_issue.GetWindowTextW(cf);
int issue = 888;
if(cf.GetLength())
{
cf += _T("期3D码预测");
issue = _ttoi(cf);
filename = cf.GetBuffer(cf.GetLength());
}
CFileDialog f_Export(FALSE,
_T("doc"),
filename,
OFN_OVERWRITEPROMPT |OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_CREATEPROMPT,
szFilter,
this);
CString fpath;
if(f_Export.DoModal() == IDOK)
{
fpath = f_Export.GetPathName();
}else{
MessageBox(_T("请输入导出文件名"),_T("导出"),MB_OK);
return;
}
CFile fout(fpath,CFile::modeCreate | CFile::modeReadWrite);
fout.Write("\xff\xfe",2);
CString str;
//str.Format(_T("\t\t\t\t\t第 %d 期 福彩3D码预测打印报表\n\t\t共计 %d 个3D码.杀码 %d 个.余码 %d 个 建议投注金额: ¥%d.00 \n\n"),issue,cParentWnd->totalCodeCount,
// cParentWnd->totalCodeCount-totalCount,totalCount,totalAmount);
str.Format(_T("\t\t\t\t\t第 %d 期 福彩3D码预测打印报表\n\t\t\t\t\t\t(共计 %d 注3D码)\n\n\n"),issue,cParentWnd->totalCodeCount);
fout.Write(str,sizeof(TCHAR)*str.GetLength());
CString codeString;
CString itemString;
CString subitem;
int sizetchar = sizeof(TCHAR);
// 导出单选单复式
//m_static_rsc.GetWindowTextW(itemString);
//m_srscNonpair.GetWindowTextW(subitem);
//itemString += _T("\n") + subitem + _T("\n");
itemString.Format(_T("单选单复式: %d 注\n"),countnrsc);
fout.Write(itemString, sizetchar*itemString.GetLength());
itemString.Empty();
subitem.Empty();
for(int i=0; i<countnrsc; i++)
{
m_rscNList.GetText(i,codeString);
if(1 + i != countnrsc)
codeString += _T(" ");
fout.Write(codeString,sizetchar * codeString.GetLength());
}
fout.Write(_T("\n\n\n\n"),sizetchar);
/* 关于对子的预测另有程式预测
m_srscPair.GetWindowTextW(subitem);
subitem += _T("\n");
fout.Write(subitem, sizetchar * subitem.GetLength());
for(int i=0; i<countprsc; i++)
{
m_rscPList.GetText(i,codeString);
if(1 + i != countprsc)
codeString += _T(" ");
fout.Write(codeString,sizetchar * codeString.GetLength());
}
fout.Write(_T("\n\n"),sizetchar*2);
*/
// 导出组选
/*
m_static_gos.GetWindowTextW(itemString);
m_sgosNonpair.GetWindowTextW(subitem);
itemString += _T("\n") + subitem + _T("\n");
*/
itemString.Format(_T("\n\n组选: %d 注 \n"),countngos);
fout.Write(itemString, sizetchar*itemString.GetLength());
itemString.Empty();
subitem.Empty();
for(int i=0; i<countngos; i++)
{
m_gosNList.GetText(i,codeString);
if(1 + i != countngos)
codeString += _T(" ");
fout.Write(codeString,sizetchar * codeString.GetLength());
}
fout.Write(_T("\n"),sizetchar);
/*
m_sgosPair.GetWindowTextW(subitem);
subitem += _T("\n");
fout.Write(subitem, sizetchar * subitem.GetLength());
for(int i=0; i<countpgos; i++)
{
m_gosPList.GetText(i,codeString);
if(1 + i != countpgos)
codeString += _T(" ");
fout.Write(codeString,sizetchar * codeString.GetLength());
}
fout.Write(_T("\n"),sizetchar);
*/
fout.Close();
resSave = TRUE;
MessageBox(_T("导出成功"),_T("提示"));
}
|
[
"shallots@163.com"
] |
shallots@163.com
|
5ae591a392328cbc24688390f02e5eb9358788da
|
bdb4d14a742eeccfee35247068f03be09fac1eba
|
/src/ITCSetModes2.cpp
|
e7748180a60871fba86fac448d5cb8e7ee91cf4c
|
[
"BSD-3-Clause"
] |
permissive
|
AllenInstitute/ITCXOP2
|
e27f39073146590fcda82d9f3f0357af122229ca
|
85011152ce86d13da1e39c93e57f3fc78f0dfdea
|
refs/heads/main
| 2023-04-13T07:05:51.072017
| 2023-03-14T11:34:32
| 2023-03-14T11:34:32
| 97,766,508
| 2
| 3
|
BSD-3-Clause
| 2023-03-14T11:34:33
| 2017-07-19T22:28:02
|
C
|
UTF-8
|
C++
| false
| false
| 3,305
|
cpp
|
#include "ITC_StandardHeaders.h"
// This file is part of the `ITCXOP2` project and licensed under BSD-3-Clause.
// Operation template:
// ITCSetModes2/Z[=number:displayErrors]/DEV=number:deviceID/I=number:DigitalInputMode/E=number:ExternalTriggerMode/T=number:ExternalTrigger/C[=number:EnableExternalClock]/D=number:DACShiftValue/R=number:InputRange/P=number:TriggerOutPosition/O[=number:OutputEnable]/F[=number:ResetFIFOFlag]/L=number:ControlLight/S=number:SamplingInterval
extern "C" int ExecuteITCSetModes2(ITCSetModes2RuntimeParamsPtr p)
{
BEGIN_OUTER_CATCH
DeviceIDHelper DeviceID(p);
ITCPublicConfig lConfig;
lConfig.DigitalInputMode = (DWORD) -1;
lConfig.ExternalTriggerMode = (DWORD) -1;
lConfig.ExternalTrigger = (DWORD) -1;
lConfig.EnableExternalClock = (DWORD) -1;
lConfig.DACShiftValue = (DWORD) -1;
lConfig.InputRange = (DWORD) -1;
lConfig.TriggerOutPosition = (DWORD) -1;
lConfig.OutputEnable = (DWORD) -1;
lConfig.SequenceLength = (DWORD) -1;
lConfig.Sequence = NULL;
lConfig.SequenceLengthIn = (DWORD) -1;
lConfig.SequenceIn = NULL;
lConfig.ResetFIFOFlag = (DWORD) -1;
lConfig.ControlLight = (DWORD) -1;
lConfig.SamplingInterval = (DWORD) -1;
if(p->IFlagEncountered)
{
// Parameter: p->DigitalInputMode
lConfig.DigitalInputMode = lockToIntegerRange<DWORD>(p->DigitalInputMode);
}
if(p->EFlagEncountered)
{
// Parameter: p->ExternalTriggerMode
lConfig.ExternalTriggerMode =
lockToIntegerRange<DWORD>(p->ExternalTriggerMode);
}
if(p->TFlagEncountered)
{
// Parameter: p->ExternalTrigger
lConfig.ExternalTrigger = lockToIntegerRange<DWORD>(p->ExternalTrigger);
}
if(p->CFlagEncountered)
{
if(p->CFlagParamsSet[0])
{
// Optional parameter: p->EnableExternalClock
lConfig.EnableExternalClock =
lockToIntegerRange<DWORD>(p->EnableExternalClock);
}
else
{
lConfig.EnableExternalClock = 1;
}
}
if(p->DFlagEncountered)
{
// Parameter: p->DACShiftValue
lConfig.DACShiftValue = lockToIntegerRange<DWORD>(p->DACShiftValue);
}
if(p->RFlagEncountered)
{
// Parameter: p->InputRange
lConfig.InputRange = lockToIntegerRange<DWORD>(p->InputRange);
}
if(p->PFlagEncountered)
{
// Parameter: p->TriggerOutPosition
lConfig.TriggerOutPosition =
lockToIntegerRange<DWORD>(p->TriggerOutPosition);
}
if(p->OFlagEncountered)
{
if(p->OFlagParamsSet[0])
{
// Optional parameter: p->OutputEnable
lConfig.OutputEnable = lockToIntegerRange<DWORD>(p->OutputEnable);
}
else
{
lConfig.OutputEnable = 1;
}
}
if(p->FFlagEncountered)
{
if(p->FFlagParamsSet[0])
{
// Optional parameter: p->ResetFIFOFlag
lConfig.ResetFIFOFlag = lockToIntegerRange<DWORD>(p->ResetFIFOFlag);
}
else
{
lConfig.ResetFIFOFlag = 1;
}
}
if(p->LFlagEncountered)
{
// Parameter: p->ControlLight
lConfig.ControlLight = lockToIntegerRange<DWORD>(p->ControlLight);
}
if(p->SFlagEncountered)
{
// Parameter: p->SamplingInterval
lConfig.SamplingInterval = p->SamplingInterval;
}
ITCDLL::ITC_ConfigDevice(DeviceID, &lConfig);
END_OUTER_CATCH
}
|
[
"thomas.braun@byte-physics.de"
] |
thomas.braun@byte-physics.de
|
88b412ce2bd7331cde6c5b474b20e2f80c155a02
|
4c794caf8377faa985ed74446107a62e41b8d774
|
/C++_old_tasks/Time_measurment/chrono_measurer.cc
|
7fa9788d7ab90b7b5d8f6f73b1461a1de2f6111d
|
[] |
no_license
|
MichaelSolotky/sandbox
|
49dbe628f7b0247b42ae864ae4ebc03f08bec504
|
817ea6d03b68d6db7edbcb11cc44bbb08993dc4f
|
refs/heads/master
| 2022-09-11T04:07:10.085475
| 2022-08-29T11:28:18
| 2022-08-29T11:28:18
| 103,974,884
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 372
|
cc
|
#include <chrono>
#include <iostream>
void func() {
for (int i = 0; i < 2000000000; ++i) { }
}
int main() {
auto start = std::chrono::high_resolution_clock::now();
func();
auto finish = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = finish - start;
std::cout << "elapsed time: " << elapsed.count() << "s\n";
}
|
[
"25284863+MichaelSolotky@users.noreply.github.com"
] |
25284863+MichaelSolotky@users.noreply.github.com
|
d9d25149351d5b384b4f1566fb6e6d148a8da755
|
14f9c2a10af87b7ac11f4629e46e3ac8e0561cab
|
/mainwindow.cpp
|
29778d7881b1cd6de5d1ea9b10c700370b4d7b0f
|
[] |
no_license
|
shgw/chat_client
|
0388cc68a6ecb55ce21808abe3438bc10aa467f5
|
9ee62dd2265d216f9027e71a14c9c629cfcb6ae0
|
refs/heads/master
| 2020-04-28T19:49:35.769977
| 2019-03-27T07:34:27
| 2019-03-27T07:34:27
| 175,523,589
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 9,131
|
cpp
|
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <qmessagebox.h>
#include "socketmessage.h"
#include <qscrollbar.h>
#include <qsettings.h>
#include <qlayout.h>
#include <qshortcut.h>
#include <qtimer.h>
#define TIMER 100
#define MSG_MAX_BUFF 2048
#define INI_FILENAME "./ChatClient.ini"
#define LIMIT_USERNAME 20
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
setFixedSize(this->size());
m_bScroll = false;
#ifndef __LINUX
WSADATA wsa;
WSAStartup(MAKEWORD(2,2), &wsa);
#endif
QSettings readini( INI_FILENAME, QSettings::IniFormat );
m_strUserName = readini.value( "USER/DEFAULT_NAME").toString();
m_strSvrIP = readini.value("NETWORK/IP").toString();
ui->lineEdit->setText( m_strUserName);
//ui->scrollArea->setStyleSheet("background-color:white");
m_log = new CLog();
m_log->SetOption( LOG_LEVEL_NORMAL, "./", "MainWindow.txt");
m_log->WriteLog(LOG_LEVEL_NOTICE, "==========START MAINWINDOW=============");
m_central = new QWidget;
m_layout = new QVBoxLayout(m_central);
m_layout->setAlignment(Qt::AlignTop);
ui->scrollArea->setWidget(m_central);
ui->scrollArea->setWidgetResizable(true);
ui->scrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
m_UIMgr.SetInterface( this );
m_timer = new QTimer();
connect( m_timer, SIGNAL(timeout()), this, SLOT(OnTimer()));
m_scSendBtn1 = new QShortcut(Qt::Key_Return, this);
QPushButton::connect( m_scSendBtn1, SIGNAL( activated() ), this, SLOT( on_sendBtn_clicked() ) );
m_scSendBtn2 = new QShortcut(Qt::Key_Enter, this);
QPushButton::connect( m_scSendBtn2, SIGNAL( activated() ), this, SLOT( on_sendBtn_clicked() ) );
}
MainWindow::~MainWindow()
{
m_ComMgr.SetThreadState( false );
#ifndef __LINUX
CloseHandle( m_hthread );
#endif
delete m_scSendBtn1;
delete m_scSendBtn2;
delete m_timer;
delete m_log;
delete m_layout;
delete m_central;
delete ui;
}
void MainWindow::on_settingBtn_clicked()
{
m_setDlg.SetParents(this);
m_setDlg.show();
}
void MainWindow::on_connectBtn_clicked()
{
if ( m_ComMgr.GetConnectionState() == true)
{
QMessageBox box;
box.information(this, "Error", "이미 접속 중 입니다.");
return;
}
if( m_strSvrIP.length() <= 0)
{
QMessageBox box;
box.information(this, "Error", "IP를 입력해주세요.");
return;
}
m_strUserName = ui->lineEdit->text();
if( m_strUserName.length() <= 0 )
{
QMessageBox box;
box.information(this, "Error", "이름을 입력해주세요.");
return;
}
else
{
QSettings writeini( INI_FILENAME, QSettings::IniFormat );
writeini.setValue("USER/DEFAULT_NAME", m_strUserName);
}
if( m_strUserName.toStdString().length() >= 20)
{
QMessageBox box;
box.information(this, "Error", "이름이 너무 깁니다.(한글6자이하)");
return;
}
char szBuff[MSG_MAX_BUFF] = { 0 };
if ( m_ComMgr.ConnectSocket( m_strSvrIP, m_strUserName, szBuff ) == CSOCKET_SUCC )
{
ComMsg* msg = (ComMsg*)szBuff;
BODY_RESP_CONN* body = (BODY_RESP_CONN*)msg->body;
if( strcmp( body->result, MSG_RESULT_FAIL ) == 0 )
{
QMessageBox box;
box.information(this, "Error", QString::fromLocal8Bit(body->reason));
m_ComMgr.SetConnectionState( false );
}
else
{
if( m_ComMgr.GetThreadState() == false )
{
m_ComMgr.SetThreadState(true);
#ifndef __LINUX
m_hthread = (HANDLE)_beginthreadex( NULL, 0, m_ComMgr.ProcThread, (void*)&m_ComMgr, 0, &m_threadID );
#else
m_threaID = pthread_create( &m_pthread, NULL, m_ComMgr.ProcThread, (void*)&m_ComMgr );
#endif
m_timer->start( TIMER );
}
m_log->WriteLog( LOG_LEVEL_NORMAL, "on_connectBtn_clicked : 접속 성공 IP[%s] ID[%s]",
m_strSvrIP.toStdString().c_str(),
m_strUserName.toStdString().c_str());
QWidget* p1 = new QWidget;
QVBoxLayout *hl = new QVBoxLayout(p1);
QLabel* pb = new QLabel("접속 했습니다.", p1);
pb->setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum);
QFont font;
font.setFamily(FONT_FAMILY);
font.setBold(true);
font.setPointSize(10);
pb->setFont(font);
hl->addWidget(pb);
hl->setAlignment(Qt::AlignCenter);
m_layout->addWidget(p1);
m_UIMgr.SetConnectionGUIData( p1, hl, pb );
}
}
else
{
QMessageBox box;
box.information(this, "Error", "접속하지 못했습니다.");
}
}
void MainWindow::on_sendBtn_clicked()
{
QString strMsg = ui->chatline->text();
std::string str = strMsg.toStdString();
if( str.length() == 0 )
{
return;
}
if( str.length() >= 1024 )
{
QString msg;
msg.sprintf("메시지가 너무 깁니다.(길이 1024이하) 길이[%d]", str.length());
QMessageBox box;
box.information( this, "Error", msg);
ui->chatline->setText("");
return;
}
if(str.compare("/clear") == 0 )
{
m_UIMgr.DeleteConnectionGUIData();
m_UIMgr.DeleteChatData();
ui->chatline->setText("");
return;
}
else if (str.compare("/save") == 0 )
{
m_UIMgr.SaveMessage();
ui->chatline->setText("");
return;
}
ComMsg msg = { 0 };
m_ComMgr.MakeHeader( &msg, m_strUserName.toStdString().c_str(), SERVER_NAME, MSGKIND_RQST, MSGID_SENDMSG );
strcpy( msg.body, str.c_str());
int nlength = str.length();
if ( m_ComMgr.SendMsg( &msg, HEADER_SIZE + nlength ) == CSOCKET_FAIL )
{
m_log->WriteLog( LOG_LEVEL_ERROR, "on_sendBtn_clicked : Send Error");
QMessageBox box;
box.information( this, "Error", "전송하지 못했습니다.");
}
else
{
m_log->WriteLog( LOG_LEVEL_NORMAL, "on_sendBtn_clicked : Send Success");
ui->chatline->setText("");
}
}
void MainWindow::SetServerIP( QString strIP )
{
m_strSvrIP = strIP;
}
void MainWindow::SetUserName()
{
m_strUserName = ui->lineEdit->text();
}
void MainWindow::ProcRecv( ComMsg* msg)
{
m_log->WriteLog( LOG_LEVEL_NORMAL, "ProcRecv : Recv src[%s] dest[%s] msgkind [%s] msgid[%s]", msg->src, msg->dest, msg->msgkind, msg->msgid);
if( strcmp( msg->msgkind, MSGKIND_RESP ) == 0 )
{
ProcResp( msg );
}
else if (strcmp ( msg->msgkind, MSGKIND_EVT) == 0 )
{
ProcEvt( msg );
}
else
{
m_log->WriteLog( LOG_LEVEL_WARN, "Unknown msgkind [%s]", msg->msgkind);
}
}
void MainWindow::ProcResp( ComMsg* msg)
{
if( strcmp( msg->msgid, MSGID_SENDMSG ) == 0 )
{
//ui->lineEdit->setText(msg->msgid);
m_UIMgr.RecvChat( msg );
}
else
{
m_log->WriteLog( LOG_LEVEL_WARN, "ProcResp : Unknown msg id [%s]", msg->msgid);
}
}
void MainWindow::ProcEvt( ComMsg* msg)
{
if( strcmp( msg->msgid, MSGID_CONN ) == 0 )
{
m_UIMgr.ConnClient( msg );
}
else if( strcmp( msg->msgid, MSGID_DISCON ) == 0 )
{
m_UIMgr.DisconClient( msg );
}
else if( strcmp( msg->msgid, MSGID_SENDMSG ) == 0 )
{
m_UIMgr.RecvChat( msg );
}
else
{
m_log->WriteLog( LOG_LEVEL_WARN, "Unknown msg id [%s]", msg->msgid);
}
}
void MainWindow::AddChatBox(QWidget* pb, ChatData* data)
{
m_layout->addWidget(pb);
m_bScroll = true;
if( data->state < 0 )
{
connect(data->pBtn, SIGNAL(clicked()), this, SLOT(ProcLongMsg()));
}
}
void MainWindow::AddMsgBox(QWidget* pb )
{
m_layout->addWidget(pb);
m_bScroll = true;
}
void MainWindow::OnTimer()
{
if ( m_bScroll == true )
{
ui->scrollArea->verticalScrollBar()->setValue(ui->scrollArea->verticalScrollBar()->maximum());
m_bScroll = false;
}
if( m_ComMgr.GetMsgSize() > 0 )
{
ComMsg msg = { 0 };
m_ComMgr.GetMsg(&msg);
ProcRecv( &msg );
}
}
void MainWindow::ProcLongMsg()
{
QPushButton* pButton = qobject_cast<QPushButton*>(sender());
ChatData* data = m_UIMgr.FindChat(pButton);
if( data == NULL )
{
m_log->WriteLog( LOG_LEVEL_ERROR , "cant find btn");
return;
}
if( data->state > 0 )
{
FoldLongMsg( data );
}
else
{
SpreadLongMsg(data);
}
}
void MainWindow::SpreadLongMsg(ChatData* data)
{
QString str;
m_UIMgr.ConvertMsg( data->chat, false, str);
data->pBtn->setText( str );
data->state *= -1;
}
void MainWindow::FoldLongMsg(ChatData* data)
{
QString str;
m_UIMgr.ConvertMsg( data->chat, true, str);
data->pBtn->setText( str );
data->state *= -1;
}
|
[
"shj@geonwoo.com"
] |
shj@geonwoo.com
|
f41f5ea9572019481e7c36e36b7810b62d2e537c
|
742840920c3dc182edcfe09a76ca30168799ba39
|
/CupheadBotDLL/d3d11_hook.cpp
|
d5dd7f7e4b6f92187b884136ad11e85036d47cb0
|
[] |
no_license
|
mare5x/CupheadBot
|
06e84568ec9e100df8fa6d107223c9f59e766bfc
|
02f0b68eebacb90330b648d7c7b3dd6d0e4b7704
|
refs/heads/master
| 2020-05-01T11:22:19.905750
| 2019-04-18T17:45:58
| 2019-04-18T17:45:58
| 177,441,307
| 1
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,643
|
cpp
|
// Based off:
// https://github.com/Rebzzel/Universal-D3D11-Hook
// https://bitbucket.org/rafzi/hacklib
// https://www.unknowncheats.me/forum/d3d-tutorials-and-source/88369-universal-d3d11-hook.html
#include "memory_tools.h"
#include "d3d11_hook.h"
d3d11_Present d3d11_hook::g_p_present = nullptr;;
d3d11_Present p_post_present_hook = nullptr;
d3d11_present_impl p_present_impl = nullptr;
IDXGISwapChain* d3d11_hook::g_p_swapchain;
ID3D11Device*d3d11_hook:: g_p_device;
ID3D11DeviceContext* d3d11_hook::g_p_device_context;
BYTE* post_detour_cave = nullptr;
bool _unhook_requested = false;
bool _is_hooked = false;
HRESULT __stdcall d3d11_hook::present_hooked(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags)
{
// this function's declaration/signature must be identical to the original Present function's signature
g_p_swapchain = pSwapChain;
pSwapChain->GetDevice(__uuidof(g_p_device), (void**)&g_p_device);
g_p_device->GetImmediateContext(&g_p_device_context);
// call the user defined implementation
if (p_present_impl(g_p_device, g_p_device_context, pSwapChain)) {
request_unhook_d3d11();
}
return 1;
}
/** Save execution state before calling the hooked Present function and then restore it
and return to the original code through the post detour cave. Also handles unhooking.
__declspec(naked) tells the compiler not to generate function prolog and epilog code
(code that handles the stack frame, ie. push ebp, mov ebp, esp ...).
Calling conventions information: https://en.wikipedia.org/wiki/X86_calling_conventions
(for __stdcall ...)
*/
void __declspec(naked) present_hook_trampoline()
{
if (_unhook_requested) {
// restore original code and jump directly to the original instead of going through the post detour cave
d3d11_hook::unhook_d3d11();
__asm {
JMP [d3d11_hook::g_p_present]
}
}
__asm {
PUSH EBP
MOV EBP, ESP
PUSHFD
PUSHAD
PUSH [EBP + 0x10] // Push the arguments in reverse order
PUSH [EBP + 0xC]
PUSH [EBP + 0x8]
CALL d3d11_hook::present_hooked // because it's __stdcall it'll clean after itself
POPAD
POPFD
POP EBP
JMP p_post_present_hook
}
}
void d3d11_hook::hook_d3d11(d3d11_present_impl cb)
{
p_present_impl = cb;
// these are all things necessary to create a device and swap chain
DummyWindow window = DummyWindow();
auto feature_level = D3D_FEATURE_LEVEL_11_0;
DXGI_SWAP_CHAIN_DESC swapChainDesc = { 0 };
swapChainDesc.BufferCount = 1;
swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.OutputWindow = window.m_hWnd;
swapChainDesc.SampleDesc.Count = 1;
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
swapChainDesc.Windowed = TRUE;
IDXGISwapChain* p_swapchain;
ID3D11Device* p_device;
ID3D11DeviceContext* p_device_context;
D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, &feature_level, 1, D3D11_SDK_VERSION,
&swapChainDesc, &p_swapchain, &p_device, NULL, &p_device_context);
// Since a vtable is shared by all instances of the same class, we can use our
// dummy device/swapchain to get the address of the present function used by the d3d11 program's swapchain.
// The Present function is used to render content to the display, so it is called every frame by every program
// that uses d3d11.
g_p_present = (d3d11_Present)get_VF((DWORD)p_swapchain, 8);
// with the address of the Present function, we can apply a jump/detour hook so that the Present function will
// immediately jump first to the present_hook_trampoline function and from there to the present_hooked function.
// From there we jump to the post_detour code cave which contains the original code replaced by the
// jump/detour hook and then from there we jump back to the original Present function
post_detour_cave = detour_hook((DWORD)g_p_present, (DWORD)&present_hook_trampoline, 5);
p_post_present_hook = (d3d11_Present)post_detour_cave;
_is_hooked = true;
// the dummy device, swapchain ... isn't necessary anymore -> we only needed to get the address of the Present function
p_device->Release();
p_device_context->Release();
p_swapchain->Release();
while (!g_p_device) { Sleep(10); }
}
void d3d11_hook::unhook_d3d11()
{
// restore the Present detour hook by writing the original code back to its original place in the Present function
remove_detour_hook((DWORD)g_p_present, post_detour_cave, 5);
if (post_detour_cave)
delete[] post_detour_cave;
_is_hooked = false;
}
void d3d11_hook::request_unhook_d3d11()
{
_unhook_requested = true;
}
bool d3d11_hook::is_hooked()
{
return _is_hooked;
}
|
[
"mare5x.mare5x@gmail.com"
] |
mare5x.mare5x@gmail.com
|
ba108d30758c32bd500166326e5728e02901d27c
|
8c26f11c10de03956e4aff5c9883f4d5758ffd81
|
/StageEditorTool/StageEditorTool/Source/Object/MouseObject.cpp
|
77d8b08ff1e0ab4d5cbee763de7bf5fbc5b9825e
|
[] |
no_license
|
AnanMatumoto/StageEditorTool
|
ca0665281d152c241cc1b88f9efe314fb6594451
|
06b3e507283715868dcffb450c2ea26e66b26fa8
|
refs/heads/master
| 2020-06-03T00:32:32.534021
| 2019-07-20T23:38:43
| 2019-07-20T23:38:43
| 190,680,111
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,014
|
cpp
|
#include "MouseObject.h"
#include "../Lib/Input/Input.h"
#include "../Collision/CollisionManager.h"
#include "../Collision/CollisionData.h"
#include "../Editor/Editor.h"
#include "../Common/Common.h"
MouseObject::MouseObject(CollisionObjectParameter& data)
:CollisionObject(
data.object_type,
data.collision_type,
data.sprite_name,
data.pos.x,
data.pos.y,
data.pos.z,
data.rot,
data.scale_x,
data.scale_y
){
}
void MouseObject::Init() {
}
void MouseObject::Update() {
CollisionManager::GetInstance()->Entry(this);
auto input = Lib::Input::GetInstance();
m_collider.pos.x = m_pos.x = input->GetMovePoint().x;
m_collider.pos.y = m_pos.y = input->GetMovePoint().y;
}
void MouseObject::Reflection(CollisionObject* obj) {
}
//どうすれば一つのオブジェクトだけを操作できるか
//ポイントがオブジェクトの領域内であればすぐにm_currentに移動してしまう。
//描画順番が最後の奴が手前にくるから消えてるように見える
|
[
"matumoto.anan@gmail.com"
] |
matumoto.anan@gmail.com
|
c216cf01bef23fda7a9cdeb43148df81abb73b39
|
96392a259c510e035a25ee19f1fc66e5c2d40633
|
/inc/command/base_command.hh
|
c56a0812e1c123eba65bd60dd59a83b72f5de599
|
[] |
no_license
|
Examnes/VM
|
b8a5f1f15c0beb27cd44014689a508f4eaf8b9b1
|
66348b38bc50c07492267b50855f56cd444be74e
|
refs/heads/main
| 2023-02-18T08:49:17.509812
| 2021-01-13T06:45:49
| 2021-01-13T06:45:49
| 310,366,808
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 854
|
hh
|
#if !defined(COMMAND_HH)
#define COMMAND_HH
#include <cstdint>
#include <limits>
#include "processor_state.hh"
using result_type = uint64_t;
#define SIGN_BIT(x) (x >> (sizeof(x) * 8 - 1))
#define DEF_AS_BASE(x) typedef x base
namespace CMD
{
class command
{
protected:
operation_type operation;
public:
void init(operation_type op)
{
operation = op;
}
command() = default;
virtual void execute(processor_state& p) = 0;
virtual word get_size() = 0;
};
class common_command : public command
{
public:
word get_size()
{
return 1;
}
};
class extended_command : public command
{
public:
word get_size()
{
return 2;
}
};
} // namespace CMD
#endif // COMMAND_HH
|
[
"clikateidanbo@gmail.com"
] |
clikateidanbo@gmail.com
|
4ab1ddff68c5b385788a9208b71a02872964bc20
|
fb227e3635b5c06e49bad48928f7b6d3254c4dca
|
/codeforces/beta61div2/b.cpp
|
866de68c31d8ed2d5420a847e1109b5ce4fc3a90
|
[] |
no_license
|
BryanValeriano/marathon
|
5be2ab354e49187c865f0296f7dfb5ab3c3d6c9b
|
8dadfad7d1a6822f61ba5ed4a06e998541515634
|
refs/heads/master
| 2022-09-11T00:06:14.982588
| 2022-09-03T17:01:30
| 2022-09-03T17:01:30
| 141,581,750
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 788
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define eb emplace_back
typedef long long ll;
typedef pair<int,int> ii;
typedef vector< pair<int,int> > vii;
const int INF = 0x3f3f3f3f;
const int T = 1e3 + 10;
int v[T];
int vis[T];
int vez;
int n;
int dfs(int u) {
vis[u] = vez;
int x = 1;
if(u-1 >= 0 and v[u-1] <= v[u] and vis[u-1] != vez) x += dfs(u-1);
if(u+1 < n and v[u+1] <= v[u] and vis[u+1] != vez) x += dfs(u+1);
return x;
}
int main() {
ios::sync_with_stdio(false);
cin >> n;
for(int i = 0; i < n; i++) cin >> v[i];
int ans = 0;
for(int i = 0; i < n; i++) {
vez++;
ans = max(ans, dfs(i));
}
cout << ans << endl;
return 0;
}
|
[
"bryan_311@hotmail.com"
] |
bryan_311@hotmail.com
|
6c22212ef1ce9a55328120b2ed619a96988d24cf
|
322a95d7a95c8a126e707286458056555f19ef52
|
/include/util/ext/AnimatedSprite.hpp
|
b731e2c1eed8de91c19ca783134983b8abe26353
|
[] |
no_license
|
aadarshasubedi/perseverance
|
70b1b467659bfe99c1941a5d6263d484d7dc1f30
|
b6229ed3d873be29d39859bd5dfa550167b6c507
|
refs/heads/master
| 2020-12-28T19:23:37.840848
| 2015-02-09T02:43:19
| 2015-02-09T02:43:19
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,399
|
hpp
|
//
// Copyright (C) 2014 Maximilian Wagenbach (aka. Foaly) (foaly.f@web.de)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef ANIMATEDSPRITE_INCLUDE
#define ANIMATEDSPRITE_INCLUDE
#include <SFML/Graphics/RenderTarget.hpp>
#include <SFML/System/Time.hpp>
#include <SFML/Graphics/Drawable.hpp>
#include <SFML/Graphics/Transformable.hpp>
#include <SFML/System/Vector2.hpp>
#include "Animation.hpp"
class AnimatedSprite : public sf::Drawable, public sf::Transformable
{
public:
explicit AnimatedSprite(sf::Time frameTime = sf::seconds(0.2f), bool paused = false, bool looped = true);
void update(sf::Time deltaTime);
void setAnimation(const Animation& animation);
void setFrameTime(sf::Time time);
void play();
void play(const Animation& animation);
void pause();
void stop();
void setLooped(bool looped);
void setColor(const sf::Color& color);
const Animation* getAnimation() const;
sf::FloatRect getLocalBounds() const;
sf::FloatRect getGlobalBounds() const;
bool isLooped() const;
bool isPlaying() const;
sf::Time getFrameTime() const;
void setFrame(std::size_t newFrame, bool resetTime = true);
private:
const Animation* m_animation;
sf::Time m_frameTime;
sf::Time m_currentTime;
std::size_t m_currentFrame;
bool m_isPaused;
bool m_isLooped;
const sf::Texture* m_texture;
sf::Vertex m_vertices[4];
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
};
#endif // ANIMATEDSPRITE_INCLUDE
|
[
"ryan@errantgames.com"
] |
ryan@errantgames.com
|
0c1154162ac3debc3aa6b48b77ecf02ae4bd34cf
|
9870e11c26c15aec3cc13bc910e711367749a7ff
|
/AOJ/a_0015.cpp
|
4cc10503b916910fd0aced30ecf7b4ed506f6a98
|
[] |
no_license
|
liuq901/code
|
56eddb81972d00f2b733121505555b7c7cbc2544
|
fcbfba70338d3d10bad2a4c08f59d501761c205a
|
refs/heads/master
| 2021-01-15T23:50:10.570996
| 2016-01-16T16:14:18
| 2016-01-16T16:14:18
| 12,918,517
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,003
|
cpp
|
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
class bignum
{
int a[10000];
public:
bignum()
{
memset(a,0,sizeof(a));
}
int &operator [](int x)
{
return(a[x]);
}
};
bignum operator +(bignum a,bignum b)
{
bignum c;
c[0]=max(a[0],b[0]);
int x=0;
for (int i=1;i<=c[0];i++)
{
c[i]=a[i]+b[i]+x;
x=c[i]/10;
c[i]%=10;
}
if (x)
c[++c[0]]=x;
return(c);
}
istream &operator >>(istream &cin,bignum &a)
{
string s;
cin>>s;
a[0]=s.size();
for (int i=1;i<=a[0];i++)
a[i]=s[a[0]-i]-'0';
return(cin);
}
ostream &operator <<(ostream &cout,bignum a)
{
if (a[0]>80)
cout<<"overflow";
else
for (int i=a[0];i;i--)
cout<<a[i];
return(cout);
}
int main()
{
int T;
scanf("%d",&T);
while (T--)
{
bignum a,b;
cin>>a>>b;
cout<<a+b<<endl;
}
system("pause");
return(0);
}
|
[
"liuq901@163.com"
] |
liuq901@163.com
|
75a54404a2c25ecdf78fb03937449d095a3f1d01
|
7fcdc07ba30153d7fde77c912dfb7dcfdecb729d
|
/include/lldb/Core/StreamFile.h
|
c83f3c2f01c821bb518b2db73316024a7deabca3
|
[
"NCSA"
] |
permissive
|
ice799/lldb
|
d48a4ae43f9f13a73b3c3fc25dae77fc729072fb
|
35c0893e220e53588afe2b63ea8dba0fb9770de1
|
refs/heads/master
| 2016-09-06T01:40:49.068253
| 2010-07-17T00:56:13
| 2010-07-17T00:56:13
| 779,965
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,887
|
h
|
//===-- StreamFile.h --------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_StreamFile_h_
#define liblldb_StreamFile_h_
// C Includes
// C++ Includes
#include <string>
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Stream.h"
namespace lldb_private {
class StreamFile : public Stream
{
public:
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
StreamFile ();
StreamFile (uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order, FILE *f);
StreamFile (FILE *f);
StreamFile (uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order, const char *path, const char *permissions = "w");
StreamFile (const char *path, const char *permissions = "w");
virtual
~StreamFile();
void
Close ();
bool
Open (const char *path, const char *permissions = "w");
virtual void
Flush ();
virtual int
Write (const void *s, size_t length);
FILE *
GetFileHandle ();
void
SetFileHandle (FILE *file, bool close_file);
const char *
GetFilePathname ();
protected:
//------------------------------------------------------------------
// Classes that inherit from StreamFile can see and modify these
//------------------------------------------------------------------
FILE* m_file; ///< File handle to dump to.
bool m_close_file;
std::string m_path_name;
};
} // namespace lldb_private
#endif // liblldb_StreamFile_h_
|
[
"lattner@91177308-0d34-0410-b5e6-96231b3b80d8"
] |
lattner@91177308-0d34-0410-b5e6-96231b3b80d8
|
674886863dce51003a4402f05fbbe39eda87cdfc
|
f5538033be7cccfcbd541cca1d889eb1c5a35e96
|
/FYP/Intermediate/Build/Win64/UE4Editor/Inc/FYP/FYP_Car_Wheel_Front.generated.h
|
1739df9cc009ee3fa84549d7a5a79cc580130686
|
[] |
no_license
|
davidtaylor6130/Final-Year-Project
|
b1634d79d0d358c870d0d5d35fd813e7e9b184e1
|
3c8eb251e23968dff59acef5317f3914bd03e95d
|
refs/heads/main
| 2023-07-14T17:05:49.203337
| 2021-08-19T19:31:51
| 2021-08-19T19:31:51
| 300,294,593
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,654
|
h
|
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
/*===========================================================================
Generated code exported from UnrealHeaderTool.
DO NOT modify this manually! Edit the corresponding .h files instead!
===========================================================================*/
#include "UObject/ObjectMacros.h"
#include "UObject/ScriptMacros.h"
PRAGMA_DISABLE_DEPRECATION_WARNINGS
#ifdef FYP_FYP_Car_Wheel_Front_generated_h
#error "FYP_Car_Wheel_Front.generated.h already included, missing '#pragma once' in FYP_Car_Wheel_Front.h"
#endif
#define FYP_FYP_Car_Wheel_Front_generated_h
#define FYP_Source_FYP_FYP_Car_Wheel_Front_h_12_RPC_WRAPPERS
#define FYP_Source_FYP_FYP_Car_Wheel_Front_h_12_RPC_WRAPPERS_NO_PURE_DECLS
#define FYP_Source_FYP_FYP_Car_Wheel_Front_h_12_INCLASS_NO_PURE_DECLS \
private: \
static void StaticRegisterNativesUFYPWheelFront(); \
friend struct Z_Construct_UClass_UFYPWheelFront_Statics; \
public: \
DECLARE_CLASS(UFYPWheelFront, UVehicleWheel, COMPILED_IN_FLAGS(0), CASTCLASS_None, TEXT("/Script/FYP"), NO_API) \
DECLARE_SERIALIZER(UFYPWheelFront)
#define FYP_Source_FYP_FYP_Car_Wheel_Front_h_12_INCLASS \
private: \
static void StaticRegisterNativesUFYPWheelFront(); \
friend struct Z_Construct_UClass_UFYPWheelFront_Statics; \
public: \
DECLARE_CLASS(UFYPWheelFront, UVehicleWheel, COMPILED_IN_FLAGS(0), CASTCLASS_None, TEXT("/Script/FYP"), NO_API) \
DECLARE_SERIALIZER(UFYPWheelFront)
#define FYP_Source_FYP_FYP_Car_Wheel_Front_h_12_STANDARD_CONSTRUCTORS \
/** Standard constructor, called after all reflected properties have been initialized */ \
NO_API UFYPWheelFront(const FObjectInitializer& ObjectInitializer); \
DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL(UFYPWheelFront) \
DECLARE_VTABLE_PTR_HELPER_CTOR(NO_API, UFYPWheelFront); \
DEFINE_VTABLE_PTR_HELPER_CTOR_CALLER(UFYPWheelFront); \
private: \
/** Private move- and copy-constructors, should never be used */ \
NO_API UFYPWheelFront(UFYPWheelFront&&); \
NO_API UFYPWheelFront(const UFYPWheelFront&); \
public:
#define FYP_Source_FYP_FYP_Car_Wheel_Front_h_12_ENHANCED_CONSTRUCTORS \
private: \
/** Private move- and copy-constructors, should never be used */ \
NO_API UFYPWheelFront(UFYPWheelFront&&); \
NO_API UFYPWheelFront(const UFYPWheelFront&); \
public: \
DECLARE_VTABLE_PTR_HELPER_CTOR(NO_API, UFYPWheelFront); \
DEFINE_VTABLE_PTR_HELPER_CTOR_CALLER(UFYPWheelFront); \
DEFINE_DEFAULT_CONSTRUCTOR_CALL(UFYPWheelFront)
#define FYP_Source_FYP_FYP_Car_Wheel_Front_h_12_PRIVATE_PROPERTY_OFFSET
#define FYP_Source_FYP_FYP_Car_Wheel_Front_h_9_PROLOG
#define FYP_Source_FYP_FYP_Car_Wheel_Front_h_12_GENERATED_BODY_LEGACY \
PRAGMA_DISABLE_DEPRECATION_WARNINGS \
public: \
FYP_Source_FYP_FYP_Car_Wheel_Front_h_12_PRIVATE_PROPERTY_OFFSET \
FYP_Source_FYP_FYP_Car_Wheel_Front_h_12_RPC_WRAPPERS \
FYP_Source_FYP_FYP_Car_Wheel_Front_h_12_INCLASS \
FYP_Source_FYP_FYP_Car_Wheel_Front_h_12_STANDARD_CONSTRUCTORS \
public: \
PRAGMA_ENABLE_DEPRECATION_WARNINGS
#define FYP_Source_FYP_FYP_Car_Wheel_Front_h_12_GENERATED_BODY \
PRAGMA_DISABLE_DEPRECATION_WARNINGS \
public: \
FYP_Source_FYP_FYP_Car_Wheel_Front_h_12_PRIVATE_PROPERTY_OFFSET \
FYP_Source_FYP_FYP_Car_Wheel_Front_h_12_RPC_WRAPPERS_NO_PURE_DECLS \
FYP_Source_FYP_FYP_Car_Wheel_Front_h_12_INCLASS_NO_PURE_DECLS \
FYP_Source_FYP_FYP_Car_Wheel_Front_h_12_ENHANCED_CONSTRUCTORS \
private: \
PRAGMA_ENABLE_DEPRECATION_WARNINGS
template<> FYP_API UClass* StaticClass<class UFYPWheelFront>();
#undef CURRENT_FILE_ID
#define CURRENT_FILE_ID FYP_Source_FYP_FYP_Car_Wheel_Front_h
PRAGMA_ENABLE_DEPRECATION_WARNINGS
|
[
"43450525+davidtaylor6130@users.noreply.github.com"
] |
43450525+davidtaylor6130@users.noreply.github.com
|
3a35077e9ae2191010aaea0bb511cf5b10af1ab0
|
dfb4cb8d916b62d7272ca353302d1ad95e4d7244
|
/src/timedata.cpp
|
318297ea9536eca169903bba1343d0df38228e67
|
[
"MIT"
] |
permissive
|
mirzaei-ce/core-shahbit
|
d166ab47067bf66c3015c3da49ff31cd29f843db
|
57ad738667b3d458c92d94aee713c184d911c537
|
refs/heads/master
| 2021-07-21T11:09:22.493418
| 2017-10-25T13:50:55
| 2017-10-25T13:50:55
| 108,276,937
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,702
|
cpp
|
// Copyright (c) 2014-2015 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "timedata.h"
#include "netbase.h"
#include "sync.h"
#include "ui_interface.h"
#include "util.h"
#include "utilstrencodings.h"
#include <boost/foreach.hpp>
using namespace std;
static CCriticalSection cs_nTimeOffset;
static int64_t nTimeOffset = 0;
/**
* "Never go to sea with two chronometers; take one or three."
* Our three time sources are:
* - System clock
* - Median of other nodes clocks
* - The user (asking the user to fix the system clock if the first two disagree)
*/
int64_t GetTimeOffset()
{
LOCK(cs_nTimeOffset);
return nTimeOffset;
}
int64_t GetAdjustedTime()
{
return GetTime() + GetTimeOffset();
}
static int64_t abs64(int64_t n)
{
return (n >= 0 ? n : -n);
}
#define SHAHBIT_TIMEDATA_MAX_SAMPLES 200
void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
{
LOCK(cs_nTimeOffset);
// Ignore duplicates
static set<CNetAddr> setKnown;
if (setKnown.size() == SHAHBIT_TIMEDATA_MAX_SAMPLES)
return;
if (!setKnown.insert(ip).second)
return;
// Add data
static CMedianFilter<int64_t> vTimeOffsets(SHAHBIT_TIMEDATA_MAX_SAMPLES, 0);
vTimeOffsets.input(nOffsetSample);
LogPrint("net","added time data, samples %d, offset %+d (%+d minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60);
// There is a known issue here (see issue #4521):
//
// - The structure vTimeOffsets contains up to 200 elements, after which
// any new element added to it will not increase its size, replacing the
// oldest element.
//
// - The condition to update nTimeOffset includes checking whether the
// number of elements in vTimeOffsets is odd, which will never happen after
// there are 200 elements.
//
// But in this case the 'bug' is protective against some attacks, and may
// actually explain why we've never seen attacks which manipulate the
// clock offset.
//
// So we should hold off on fixing this and clean it up as part of
// a timing cleanup that strengthens it in a number of other ways.
//
if (vTimeOffsets.size() >= 5 && vTimeOffsets.size() % 2 == 1)
{
int64_t nMedian = vTimeOffsets.median();
std::vector<int64_t> vSorted = vTimeOffsets.sorted();
// Only let other nodes change our time by so much
if (abs64(nMedian) < 70 * 60)
{
nTimeOffset = nMedian;
}
else
{
nTimeOffset = 0;
static bool fDone;
if (!fDone)
{
// If nobody has a time different than ours but within 5 minutes of ours, give a warning
bool fMatch = false;
BOOST_FOREACH(int64_t nOffset, vSorted)
if (nOffset != 0 && abs64(nOffset) < 5 * 60)
fMatch = true;
if (!fMatch)
{
fDone = true;
string strMessage = _("Please check that your computer's date and time are correct! If your clock is wrong Shahbit Core will not work properly.");
strMiscWarning = strMessage;
uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_WARNING);
}
}
}
BOOST_FOREACH(int64_t n, vSorted)
LogPrint("net", "%+d ", n);
LogPrint("net", "| ");
LogPrint("net", "nTimeOffset = %+d (%+d minutes)\n", nTimeOffset, nTimeOffset/60);
}
}
|
[
"mirzaei@ce.sharif.edu"
] |
mirzaei@ce.sharif.edu
|
26af125afda538ef1f475846a6a14fbc19eff1e0
|
353c9dff982a492fa1aae7912fae51bfcc03c81c
|
/MPC.cpp
|
8d2c207dbcaa64567fbffede1af1c76a31683fc8
|
[] |
no_license
|
Kazuryu0907/src
|
5f3fec93580b19fea592c3af99990f1f33707bf8
|
daf7203e434aca36aa525d121e784f03fd4c2e67
|
refs/heads/master
| 2022-11-27T17:39:03.587307
| 2020-08-03T14:22:48
| 2020-08-03T14:22:48
| 281,157,239
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,649
|
cpp
|
#include "MPC.h"
#include <iostream>
#define FOR(i,n) for(int (i) = 0;(i)<(n);(i)++)
#define DTR(n) ((n)*0.0174533)
MPC::MPC(double dt,double maxu,double L){
_dt = dt;
_MPCL = L;
_maxu = maxu;
set_defaults();
setup_indexing();
load_default_data();
settings.verbose = 0;
}
void MPC::shiftArray(){
FOR(i,15)FOR(k,3)params.xr[i][k] = params.xr[i+1][k];
}
void MPC::solv(double *xr,double *cx){
FOR(i,3)params.xr[15][i] = xr[i];
FOR(i,3)params.xzero[i] = cx[i];
solve();
FOR(i,16){
FOR(k,3){
//printf("%f:",vars.u[i][k]);
}
//printf("\n");
}
FOR(i,3)outu[i] = vars.u[0][i];
double outx[3];
FOR(i,3)outx[i] = vars.x[0][i];
Eigen::Map<Eigen::Vector3d> uvec(&outu[0]);
//std::cout << uvec << std::endl;
x0 = x0 + _dt*B*uvec;
FOR(i,3)params.xzero[i] = x0.data()[i];
//std::cout << x0 << std::endl;
printf("%f:%f:%f---------",params.xzero[0],params.xzero[1],params.xzero[2]);
printf("%f:%f:%f\n",vars.u[0][0],vars.u[0][1],vars.u[0][2]);
shiftArray();
}
void MPC::updateAngle(double theta){
B << cos(theta),cos(theta+DTR(120)),cos(theta+DTR(240)),
sin(theta),sin(theta+DTR(120)),sin(theta+DTR(240)),
1/_MPCL,1/_MPCL,1/_MPCL;
}
void MPC::load_default_data(){
/* Make this a diagonal PSD matrix, even though it's not diagonal. */
FOR(i,3)x0(i) = 0;
params.a[0] = 1000;
params.b[0] = 1000;
params.dt[0] = _dt;
params.maxthetaerror[0] = 1.0;
MatrixXd A1(3,3);
A1 << 1,0,0,
0,1,0,
0,0,0;
params.A1 = A1.data();
/* Make this a diagonal PSD matrix, even though it's not diagonal. */
MatrixXd C1(3,3);
C1 << 0,0,0,
0,0,0,
0,0,1;
//params.C1 = C1.data();
//FOR(i,16)FOR(k,3)params.xr[i][k] = i*10+k;
params.A[0] = 1;
params.A[1] = 1;
params.A[2] = 1;
/* Make this a diagonal PSD matrix, even though it's not diagonal. */
B << 1,-0.5,-0.5,
0,sqrt(3)/2,-sqrt(3)/2,
1/_MPCL,1/_MPCL,1/_MPCL;
params.B = B.data();
Vector3d Vmaxu(_maxu,_maxu,_maxu);
//printf("%f\n",Vmaxu(0));
FOR(i,3)params.maxu[i] = Vmaxu.data()[i];
Vector3d xzero(0,0,0);
FOR(i,3)params.xzero[i] = xzero.data()[i];
Vector3d Theta1(0,0,1);
FOR(i,3)params.Theta1[i] = Theta1.data()[i];
}
void MPC::setxr(double xr[16][3]){
FOR(i,16)FOR(k,3)params.xr[i][k] = xr[i][k];
}
void MPC::print(){
printf("%f:%f:%f------",vars.x[0][0],vars.x[0][1],vars.x[0][2]);
printf("%f:%f:%f------",vars.u[0][0],vars.u[0][1],vars.u[0][2]);
printf("%f:%f:%f\n",params.xr[0][0],params.xr[0][1],params.xr[0][2]);
}
|
[
"41988990+Kazuryu0907@users.noreply.github.com"
] |
41988990+Kazuryu0907@users.noreply.github.com
|
ceca6ccd72f74bd6db7d0d09a87cb404a2581b98
|
2fde7d8e325536d231c0de7f8fd6ee2b17c05bc5
|
/797.all-paths-from-source-to-target.cpp
|
db978c8245805b9f52b926d22f08cbbbd4eaa68d
|
[] |
no_license
|
Sahanduiuc/leetcode-solutions
|
41326a43f5993dbc04f603cac1befb36849e8816
|
fecb9e13d81eafd284be7e9a8b89824cec85e0d6
|
refs/heads/master
| 2020-09-20T11:48:48.851581
| 2018-04-17T13:15:30
| 2018-04-17T13:15:30
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 451
|
cpp
|
class Solution {
public:
vector<vector<int>> ans;
vector<int> path;
void go(vector<vector<int>>& graph, int now) {
path.push_back(now);
if (now == (int)graph.size() - 1) {
ans.push_back(path);
path.pop_back();
return;
}
for (auto& child : graph[now]) go(graph, child);
path.pop_back();
}
vector<vector<int>> allPathsSourceTarget(vector<vector<int>>& graph) {
go(graph, 0);
return ans;
}
};
|
[
"b03901133@ntu.edu.tw"
] |
b03901133@ntu.edu.tw
|
253fce05f8ee1ccbb94e4edc14f7786ef9b9ff9d
|
323f282dc86794da456edd66badefdc8f0f4b604
|
/code/bess/core/modules/update.cc
|
2a2b51773bd1d228039649975ccee50c109b7d6b
|
[
"BSD-3-Clause"
] |
permissive
|
bestephe/loom
|
4c9ce219cfb1e018e920a34c3a72c24d31f91ed7
|
9ad9062c4d313ff611d48a1e104fedbf06bc6d61
|
refs/heads/master
| 2020-04-20T22:07:47.523484
| 2019-02-04T20:09:31
| 2019-02-04T20:09:31
| 169,129,128
| 26
| 4
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,829
|
cc
|
// Copyright (c) 2014-2016, The Regents of the University of California.
// Copyright (c) 2016-2017, Nefeli Networks, Inc.
// All rights reserved.
//
// 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 names of the copyright holders nor the names of their
// 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 HOLDER 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 "update.h"
#include "../utils/endian.h"
const Commands Update::cmds = {
{"add", "UpdateArg", MODULE_CMD_FUNC(&Update::CommandAdd),
Command::THREAD_UNSAFE},
{"clear", "EmptyArg", MODULE_CMD_FUNC(&Update::CommandClear),
Command::THREAD_UNSAFE},
};
CommandResponse Update::Init(const bess::pb::UpdateArg &arg) {
return CommandAdd(arg);
}
void Update::ProcessBatch(bess::PacketBatch *batch) {
int cnt = batch->cnt();
for (size_t i = 0; i < num_fields_; i++) {
const auto field = &fields_[i];
be64_t mask = field->mask;
be64_t value = field->value;
int16_t offset = field->offset; // could be < 0
for (int j = 0; j < cnt; j++) {
bess::Packet *snb = batch->pkts()[j];
char *head = snb->head_data<char *>();
be64_t *p = reinterpret_cast<be64_t *>(head + offset);
*p = (*p & mask) | value;
}
}
RunNextModule(batch);
}
CommandResponse Update::CommandAdd(const bess::pb::UpdateArg &arg) {
size_t curr = num_fields_;
if (curr + arg.fields_size() > kMaxFields) {
return CommandFailure(EINVAL, "max %zu variables can be specified",
kMaxFields);
}
for (int i = 0; i < arg.fields_size(); i++) {
const auto &field = arg.fields(i);
size_t size = field.size();
if (size < 1 || size > 8) {
return CommandFailure(EINVAL, "'size' must be 1-8");
}
if (field.offset() + size > SNBUF_DATA) {
return CommandFailure(EINVAL, "too large 'offset'");
}
be64_t value(field.value() << ((8 - size) * 8));
be64_t mask((1ull << ((8 - size) * 8)) - 1);
if ((value & mask).value() != 0) {
LOG(INFO) << value << ' ' << mask;
return CommandFailure(
EINVAL, "'value' field has not a correct %zu-byte value", size);
}
fields_[curr + i].offset = field.offset();
fields_[curr + i].mask = mask;
fields_[curr + i].value = value;
}
num_fields_ = curr + arg.fields_size();
return CommandSuccess();
}
CommandResponse Update::CommandClear(const bess::pb::EmptyArg &) {
num_fields_ = 0;
return CommandSuccess();
}
ADD_MODULE(Update, "update", "updates packet data with specified values")
|
[
"brentstephens@cs.wisc.edu"
] |
brentstephens@cs.wisc.edu
|
a7f27eb28bd746c5167b18de898f8020d43fddc4
|
e1f8e7caf5454bd6c1a559b0ef01fc6ab945eec4
|
/code/2019_05_07_noexcept/integer_value_03.cpp
|
ebe5e3a5b94b4916414e30904d55b34659de0e4b
|
[] |
no_license
|
siri3us/siri3us.github.io
|
da4a2bac657aa672b5173c937a613e01e7a37b79
|
b74eaea9405a9de84b3792c2f44ec91477dc2b7d
|
refs/heads/master
| 2021-07-16T15:42:14.547975
| 2020-05-18T03:07:42
| 2020-05-18T03:07:42
| 156,371,328
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,031
|
cpp
|
#include <iostream>
class IntegerValue {
public:
explicit IntegerValue(int value = 0) noexcept : value_(value) {
}
int GetValue() const noexcept {
return value_;
}
private:
int value_;
};
IntegerValue operator+(const IntegerValue& lhs, const IntegerValue& rhs) noexcept {
return IntegerValue{lhs.GetValue() + rhs.GetValue()};
}
[[maybe_unused]] static void PrintNoexcept() {
IntegerValue var;
std::cout << std::boolalpha;
std::cout << "noexcept(IntegerValue::IntegerValue()) = " << noexcept(IntegerValue{}) << std::endl;
std::cout << "noexcept(IntegerValue::GetValue()) = " << noexcept(var.GetValue()) << std::endl;
std::cout << "noexcept(operator+) = " << noexcept(var + var) << std::endl;
std::cout << "noexcept(IntegerValue::~IntegerValue()) = " << noexcept(var.~IntegerValue()) << std::endl;
}
int main(int argc, char *argv[]) {
int result = 0;
IntegerValue var1{5};
IntegerValue var2{100};
result = (var1.GetValue() + var2.GetValue() > 0) ? 0 : -1;
return result;
}
|
[
"siri3us@yandex-team.ru"
] |
siri3us@yandex-team.ru
|
d0a212fe651ef17d4997d76836a06583fdfdbba6
|
3ca2641938508b0ef59bba9a7378df0b5b5b6e93
|
/jni/redcircles.cpp
|
099a4b242c3529eb7ceac6c643a0aba4c11c5ab1
|
[] |
no_license
|
thomasriga/android-robot
|
6a557f0619308a440b56f6f46b5b1a6190c437a0
|
0e23cf5cb916a1a15f87e511e72ad46c19d19068
|
refs/heads/master
| 2023-04-07T01:39:45.342455
| 2023-03-17T16:32:55
| 2023-03-17T16:32:55
| 3,247,312
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,171
|
cpp
|
#include <jni.h>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <cv.h>
#include <cvaux.h>
using namespace std;
using namespace cv;
extern "C" {
JNIEXPORT void JNICALL Java_com_thomasriga_carbotvision_NativeCVisionView_redcircles(JNIEnv* env, jobject thiz, jint width, jint height, jbyteArray yuv, jintArray bgra, jintArray cmds)
{
jbyte* _yuv = env->GetByteArrayElements(yuv, 0);
jint* _bgra = env->GetIntArrayElements(bgra, 0);
jint* _cmds = env->GetIntArrayElements(cmds, 0);
Mat myuv(height + height/2, width, CV_8UC1, (unsigned char *)_yuv);
Mat mbgra(height, width, CV_8UC4, (unsigned char *)_bgra);
Mat mgray(height, width, CV_8UC1, (unsigned char *)_yuv);
jbyte DIRECTION_HINT = 0x2, LEFT = 0x1, STRAIGHT = 0x2, RIGHT = 0x3, FORWARD = 0xff, STOP = 0x2, BACKWARD = 0x3;
int x;
cvtColor(myuv, mbgra, CV_YUV420sp2BGR, 4);
IplImage stub = mbgra;
IplImage gstub = mgray;
IplImage* hsv_frame = cvCreateImage(cvSize(width,height), IPL_DEPTH_8U, 3);
IplImage* bgr_frame = cvCreateImage(cvSize(width,height), IPL_DEPTH_8U, 3);
IplImage* thresholded = cvCreateImage(cvSize(width,height), IPL_DEPTH_8U, 1);
IplImage* thresholded2 = cvCreateImage(cvSize(width,height), IPL_DEPTH_8U, 1);
// red
/*
CvScalar hsv_min = cvScalar(0, 30, 60, 0); // H, S, V
CvScalar hsv_max = cvScalar(15, 180, 180, 0); // H, S, V
CvScalar hsv_min2 = cvScalar(160, 30, 60, 0); // H, S, V
CvScalar hsv_max2 = cvScalar(180, 180, 180, 0); // H, S, V
cvCvtColor(&stub, hsv_frame, CV_BGR2HSV);
cvInRangeS(hsv_frame, hsv_min, hsv_max, thresholded);
cvInRangeS(hsv_frame, hsv_min2, hsv_max2, thresholded2);
cvOr(thresholded, thresholded2, thresholded);
*/
cvSmooth(&gstub, thresholded, CV_GAUSSIAN, 9, 9);
//cvCanny(thresholded, thresholded2, 1.0, 1.0, 3);
CvMemStorage* storage = cvCreateMemStorage(0);
Mat mFinal = thresholded;
cvtColor(mFinal, mbgra, CV_GRAY2BGR, 4);
stub = mbgra;
CvSeq* circles = cvHoughCircles(thresholded, storage, CV_HOUGH_GRADIENT, 2, thresholded->height/4, 200, 100);
if(circles->total > 0)
{
float* p = (float*)cvGetSeqElem( circles, 0);
//cvCircle( &stub, cvPoint(cvRound(p[0]),cvRound(p[1])), cvRound(p[2]), CV_RGB(255,255,255), 6);
for(x = 0; x < 3; x++)
{
_cmds[x] = p[x];
}
/*
if(p[0] < (int) ((double) width * 0.33))
{
_cmds[0] = DIRECTION_HINT;
_cmds[1] = RIGHT;
_cmds[2] = FORWARD;
}
else if(p[0] < (int) ((double) width * 0.66))
{
_cmds[0] = DIRECTION_HINT;
_cmds[1] = STRAIGHT;
_cmds[2] = FORWARD;
}
else
{
_cmds[0] = DIRECTION_HINT;
_cmds[1] = LEFT;
_cmds[2] = FORWARD;
}
*/
}
else
{
_cmds[0] = 0;
_cmds[1] = 0;
_cmds[2] = 0;
}
cvReleaseMemStorage(&storage);
cvReleaseImage(&hsv_frame);
cvReleaseImage(&bgr_frame);
cvReleaseImage(&thresholded);
cvReleaseImage(&thresholded2);
env->ReleaseIntArrayElements(bgra, _bgra, 0);
env->ReleaseIntArrayElements(cmds, _cmds, 0);
env->ReleaseByteArrayElements(yuv, _yuv, 0);
}
}
|
[
"thomasriga@gmail.com"
] |
thomasriga@gmail.com
|
828662ae2a0cb5d2a06ae3dcd6525a37cab746d1
|
02de1b72027e27c18fbdf8185ecd0bf9f5b2a230
|
/cpp/2016/2016-08-26-template/library.cpp
|
e0278b61143490fd60c5432c7d73ef03b49becd6
|
[] |
no_license
|
1995hnagamin/language
|
6eb869a83435bd398363639ac19a3094a8d37fd3
|
1c3d72d93b3b6521fe09bc4d927aa3eb8db2bb54
|
refs/heads/master
| 2023-04-15T01:25:42.838495
| 2023-04-04T07:20:20
| 2023-04-04T07:20:20
| 97,799,867
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 75
|
cpp
|
#include "library.hpp"
Point3D<int> origin() {
return Point3D<int>();
}
|
[
"hnagamin@trans-nt.com"
] |
hnagamin@trans-nt.com
|
cb783a51c41ad1658b78f402e90e0025b052d6be
|
45795f5735cfff4c83a83aa726b7483eb5a7e8c0
|
/smixx_v47r1/x86_64/src/translator/smpcondtyp3.hxx
|
baff6cf03963640aeb5b362dc1722a4436fa14d9
|
[] |
no_license
|
wmoore28/clas12-epics-third-party-libs
|
260286981c57167f1852cff13b975e6c9ba5a907
|
b8701fee2638b5a0b6dcd7da5b5fd7aa3413b2ce
|
refs/heads/master
| 2020-03-16T22:48:44.195456
| 2018-05-11T14:56:13
| 2018-05-11T14:56:13
| 133,053,317
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,083
|
hxx
|
// smpcond3.hxx: interface for the SmpCondTyp3 class.
//
// B. Franek
// August 2009
// Format : ( 'object-set-name' empty )
// or ( 'pbject-set-name' not_empty )
//
// Copyright Information:
// Copyright (C) 1999-2009 CCLRC. All Rights Reserved.
//////////////////////////////////////////////////////////////////////
#ifndef SMPCONDTYP3_HH
#define SMPCONDTYP3_HH
#include "smixx_common.hxx"
#include "name.hxx"
#include "namevector.hxx"
class SMLlineVector;
#include "smpcond.hxx"
class SmpCondTyp3 : public SmpCond
{
public:
SmpCondTyp3(const int idNum);
virtual ~SmpCondTyp3();
int initialise( SMLlineVector* pSMLcode,
const int ist, const int jst,
int& inext, int& jnext);
void negate();
int examine();
void out(const Name) const;
void outFull(const Name) const;
Name outString();
void outSobj(ofstream& sobj) const;
protected :
enum {_type = 3 };
int _empty; // 1 if empty, 0 otherwise
Name _objectSetName;
};
#endif
|
[
"wmoore@jlab.org"
] |
wmoore@jlab.org
|
38d7de3e756beae8e8d3b3963205656db52435e1
|
241d39cbf90ca70a3ff301c4a396e6bf1897910c
|
/ComCal_v0.1/Add.h
|
c2719a26ef4efaa163513ba9a3df25e08651c4de
|
[] |
no_license
|
cs2103jan2015-t13-1c/ComCal_v0.1
|
592c580d189df5f2cf07b91281982a484dad988b
|
e6bcf1362662fb8f75f860615c7f4388f7eb7b6e
|
refs/heads/master
| 2021-01-20T11:29:37.732021
| 2015-03-09T14:31:05
| 2015-03-09T14:31:05
| 31,873,943
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,936
|
h
|
#pragma once
/**********************************************************************************************************
Name: Add
Type: Class
Purpose: Child class of Command parent class.
Responsible for executing create/add task into tasks database text file, when its executeInput API
is called by Logic class.
Its private attributes holds its parameter keywords and specified attributes of the task to be
created/added.
Private methods are functions used to support implementation of its API, for increased abstraction.
**********************************************************************************************************/
#include "Command.h"
class Add : public Command {
private:
/****************************************************************************************************
Name: _attributeKeywords
Type: Vector of strings attribute
Purpose: Holds recognised attribute keywords
****************************************************************************************************/
std::vector<std::string> _attributeKeywords;
/****************************************************************************************************
Name: _naturalKeywords
Type: Method
Purpose: Holds recognised natural keywords.
****************************************************************************************************/
std::vector<std::string> _naturalKeywords;
std::string _description;
time_t _startDateTime;
time_t _endDateTime;
std::string _location;
/****************************************************************************************************
Name: process
Type: Method
Purpose: Processes input string to obtain specified task attributes and assigns them to the respective private
attributes.
****************************************************************************************************/
void process(std::string);
/****************************************************************************************************
Name: processAttributesStyle
Type: Method
Purpose: Processes input string based on attribute keywords and assigns them to the respective private attributes.
Returns bool value of whether input string has been processed - i.e. true if attribute keyword(s) is(are) found,
false if no attribute keyword(s) is(are) found.
****************************************************************************************************/
bool processAttributesStyle(std::string);
/****************************************************************************************************
Name: processNaturalStyle
Type: Method
Purpose: Process input string based on natural keywords and assigns them to the respective private attributes.
Called in process method if processAttributesStyle method returns false, i.e. input string is not attributes
keyword based.
****************************************************************************************************/
void processNaturalStyle(std::string);
/****************************************************************************************************
Name: prepareFeedback
Type: Method
Purpose: Prepares feedback with input added task to reflect successful addition of task and its task
attributes.
****************************************************************************************************/
std::string prepareFeedback(Task);
/****************************************************************************************************
Name: prepareUndoFeedback
Type: Method
Purpose: Prepares undo feedback with deleted task to reflect successful deletion of task for undo of this
instance of add.
****************************************************************************************************/
std::string prepareUndoFeedback(Task);
public:
Add(Manipulator*, Manipulator*);
~Add(void);
/****************************************************************************************************
Name:executeInput
Type: Method
Purpose: Executes input received - adds task with specified attributes in input string into todo task database,
and returns feedback string.
****************************************************************************************************/
std::string executeInput(std::string);
/****************************************************************************************************
Name: undo
Type: Method
Purpose: Executes undo of this instance of add, and returns feedback string.
****************************************************************************************************/
std::string undo(void);
/****************************************************************************************************
Name: redo
Type: Method
Purpose: Executes redo of this instance of add, and returns feedback string.
****************************************************************************************************/
std::string redo(void);
};
|
[
"aljunied.hamzah@gmail.com"
] |
aljunied.hamzah@gmail.com
|
792e316aace20955e4fc9d72415fde2d57553534
|
a55a200174c1770bb0e24ab54d499451d728d37b
|
/I2C_Sub/I2C_Sub.ino
|
83ab1b0b78e68486282b070c1b7116cdf5796b91
|
[] |
no_license
|
saka-guchi/I2C_Between_Arduino_and_ESP32
|
ceca1be9e9833f83765b0e6470ffefd94f8d17ce
|
5ddae076236c557b7669e94aa9043d1b943c3238
|
refs/heads/master
| 2022-12-06T20:09:48.817796
| 2020-08-21T14:04:02
| 2020-08-21T14:04:02
| 287,503,592
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,864
|
ino
|
// <https://www.arduino.cc/en/Tutorial/MasterWriter>
// <https://www.arduino.cc/en/Tutorial/MasterReader>
// by Nicholas Zambetti <http://www.zambetti.com>
// Demonstrates use of the Wire library
// Sends data as an I2C/TWI sub device
// Created 29 March 2006
// This example code is in the public domain.
// #define MICON_ESP32 // undefined if Arduino
#ifdef MICON_ESP32
# error "I2C Sub functionality is not implemented in ESP32 Arduino Core"
# error "If you want to implement, see https://www.arduino.cc/reference/en/libraries/esp32-i2c-slave/"
#endif
#define ADDRESS 0x8
#include <Wire.h>
void setup() {
Wire.begin(ADDRESS); // join i2c bus with address #8
Wire.onReceive(receiveEvent); // register event
Wire.onRequest(requestEvent); // register event
Serial.begin( 115200 ); // start serial for output
while(!Serial); // Leonardo: wait for serial monitor
Serial.println("\nI2C Sub");
}
void loop(void) {
delay(100);
}
// function that executes whenever data is received from main
// this function is registered as an event, see setup()
void receiveEvent(int howMany) {
if( howMany == 0 ) {
return;
}
Serial.print("receiveEvent: ");
while( 1 < Wire.available() ) { // loop through all but the last
char c = Wire.read(); // receive byte as a character
Serial.print(c); // print the character
}
int x = Wire.read(); // receive byte as an integer
Serial.println(x); // print the integer
}
// function that executes whenever data is requested by main
// this function is registered as an event, see setup()
void requestEvent(void) {
Serial.println("requestEvent: ");
Wire.write("hello\n"); // respond with message of 6 bytes
// as expected by main
}
|
[
"45175773+saka-guchi@users.noreply.github.com"
] |
45175773+saka-guchi@users.noreply.github.com
|
d2591ef4ec2af2b99729b80b1e37940f3616cd8c
|
e2ffd59df1e2bb33e74c42b7e263cfa247dcb8d3
|
/Project3/tree.cpp
|
792f271c2b85a736689825d53805984e0f66e74b
|
[] |
no_license
|
ykmoon04/DataStructure
|
dfa29612dc42afc6a6702871efc16721e945e969
|
3b6a4a64d19000e3ec71d15906d7d8a855ba9794
|
refs/heads/main
| 2023-06-14T09:48:12.729549
| 2021-07-02T03:20:12
| 2021-07-02T03:20:12
| 382,212,113
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,586
|
cpp
|
#include <iostream>
#include <string>
#include <queue>
#include "tree.h"
using namespace std;
TreeNode::TreeNode(string name) {
this->name = name;
}
string TreeNode::getName() {
return name;
}
HierarchyTree::HierarchyTree() {
root = NULL;
cnt = 0;
}
HierarchyTree::~HierarchyTree() {
clear();
}
void HierarchyTree::hire(string boss, string sub) {
if (cnt >= 1000) {
cout << "Cannot hire more than 1000 people" << endl;
return;
}
TreeNode* employee = new TreeNode(sub);
if (isEmpty()) {
root = employee;
}
else {
TreeNode* super = retrieve(root, boss);
if (super!=NULL) {
super->children.push_back(employee);
cnt++;
}
else {
cout << "employee <" << boss << "> not exist" << endl;
}
}
}
TreeNode* HierarchyTree::retrieve(TreeNode* curr,string target) {
if (curr->getName() == target) {
return curr;
}
int num = curr->children.size();
for (int i = 0; i < num; i++) {
TreeNode* found = retrieve(curr->children.at(i), target);
if (found != NULL) return found;
}
return NULL;
}
void HierarchyTree::fire(string name) {
if (isEmpty()) return;
TreeNode* target = retrieve(root, name);
if (target==NULL) {
cout << "employee <" << name << "> not exist" << endl;
return;
}
TreeNode* super = superior(name);
if (target->children.size() == 0) { // the victim had no subordinates
if (super == NULL) { // fire CEO
root = NULL;
}
else {
for (int i = 0; i < super->children.size(); i++) {
if (super->children[i]->getName() == name) {
super->children.erase(super->children.begin() + i);
}
}
}
}
else { // the victim had subordinates
promoted(target);
if (super == NULL) { // fire CEO
root = target->children[0];
return;
}
for (int i = 0; i < target->children.size(); i++) {
super->children.push_back(target->children[i]);
}
for (int i = 0; i < super->children.size(); i++) {
if (super->children[i]->getName() == name) {
super->children.erase(super->children.begin() + i);
}
}
}
delete target;
}
// find superior
TreeNode* HierarchyTree::superior(string name) {
if (root->getName() == name) return NULL;
queue<TreeNode*> q;
q.push(root);
while (!q.empty()) {
TreeNode* element = q.front();
q.pop();
for (int i = 0; i < element->children.size(); i++) {
if (element->children[i]->getName() == name) return element;
else q.push(element->children[i]);
}
}
}
void HierarchyTree::promoted(TreeNode* target) {
if (target->children.size()!=0)
{
promoted(target->children[0]);
}
TreeNode* super = superior(target->getName());
if (super == NULL) {
return;
}
else {
while (super->children.size() != 1) {
target->children.push_back(super->children[1]);
super->children.erase(super->children.begin() + 1);
}
}
}
void HierarchyTree::print() {
if (isEmpty()) {
cout << "No one hired" << endl;
return;
}
for (int i = 0; i < 60; i++) {
cout << "-";
}
cout << endl;
printSub(root, 0);
for (int i = 0; i < 60; i++) {
cout << "-";
}
cout << endl;
}
void HierarchyTree::printSub(TreeNode* curr, int level) {
for (int i = 0; i < level; i++) {
cout << "+";
}
cout << curr->getName() << endl;
for (int i = 0; i < curr->children.size(); i++) {
printSub(curr->children[i], level+1);
}
}
bool HierarchyTree::isEmpty() {
return root == NULL;
}
void HierarchyTree::clear() {
queue<TreeNode*> q;
q.push(root);
while (!q.empty()) {
TreeNode* element = q.front();
q.pop();
for (int i = 0; i < element->children.size(); i++) {
q.push(element->children[i]);
}
delete element;
}
}
|
[
"moonsc014@gmail.com"
] |
moonsc014@gmail.com
|
a416b48732b21b609198ba38baeded74a75407d0
|
939e6f79ca9b9411fcab2dbc2b31f73e42d3fa00
|
/lscm2/include/math/math_functions.h
|
7bd6e304c42a9b1fea63b3aa177ccd8057be220a
|
[] |
no_license
|
kingofthebongo2008/examples
|
f5f8d4149b83b454d788b53ac2ac440d77af9230
|
17d421d0f7fe9f20b32f3a9510c46eddc86353af
|
refs/heads/master
| 2023-06-10T05:07:55.712393
| 2020-07-21T12:23:34
| 2020-07-21T12:23:34
| 7,283,947
| 3
| 0
| null | 2023-05-31T20:09:46
| 2012-12-22T08:30:16
|
C++
|
UTF-8
|
C++
| false
| false
| 4,374
|
h
|
#ifndef __MATH_FUNCTIONS_H__
#define __MATH_FUNCTIONS_H__
#include <tuple>
#include <math/math_vector.h>
namespace math
{
namespace details1
{
inline float4 int_part(float4 v)
{
static __declspec( align(16) ) const uint32_t sign_mask[4] = { 0x80000000, 0x80000000, 0x80000000, 0x80000000 };
float4 mask = load4( reinterpret_cast<const float*> (&sign_mask[0]) );
float4 sign = and( v, mask);
float4 abs = and_not(mask, v);
//this number is 2<<23 as a floating point number.
//23 is the bits in the mantissa
float4 two_shift_23 = splat( 8388608.0f );
float4 result = add(abs, two_shift_23); //eliminate the mantissa in v
result = sub(result, two_shift_23); //reconstruct the number
//1.6 returns 2, instead of 1
float4 le = compare_le(abs, result);
float4 result_1 = sub (result, one() );
float4 s = select(result, result_1 , le);
//mirror the result for negatives
return or( s, sign);
}
inline float4 frac_part(float4 v)
{
return sub(v, int_part(v) );
}
}
namespace details2
{
inline float4 int_part(float4 v)
{
// truncate value
__m128i trunc = _mm_cvttps_epi32( v );
__m128 mask = _mm_castsi128_ps( _mm_cmpeq_epi32( trunc, _mm_set1_epi32( 0x80000000u ) ) );
// convert back to float and mask out invalid values
__m128 x = _mm_cvtepi32_ps( trunc );
x = _mm_andnot_ps( mask, x );
return _mm_add_ps( x, _mm_and_ps( mask, v ) );
}
inline float4 frac_part(float4 v)
{
return sub(v, int_part(v) );
}
}
namespace details
{
inline float4 int_part(float4 v)
{
return details2::int_part(v);
}
inline float4 frac_part(float4 v)
{
return details2::frac_part(v);
}
}
inline float4 truncate(float4 value)
{
return details::int_part(value);
}
inline float4 floor(float4 value)
{
float4 int_part = details::int_part( value );
float4 frac_part = sub( value, int_part );
float4 int_part_minus_one = sub( int_part, one() );
float4 mask = compare_ge( frac_part, zero() );
float4 result = select( int_part_minus_one, int_part, mask );
return result;
}
inline float4 ceiling(float4 value)
{
float4 int_part = details::int_part( value );
float4 frac_part = sub( value, int_part );
float4 int_part_plus_one = add( int_part, one() );
float4 mask = compare_ge( frac_part, zero() );
float4 result = select( int_part, int_part_plus_one, mask );
return result;
}
inline float4 round(float4 value)
{
float4 one_half = splat(0.5f);
float4 minus_one_half = splat(-0.5f);
float4 mask = compare_lt( value, zero() );
float4 int_part_1 = details::int_part( add ( value, one_half) );
float4 int_part_2 = details::int_part( add ( value, minus_one_half) );
return select ( int_part_1, int_part_2, mask );
}
namespace details
{
inline float4 negative_multiply_subtract(float4 v_1, float4 v_2, float4 v_3)
{
float4 v = mul(v_1, v_2);
return sub(v_3, v);
}
inline float4 mod_angles(float4 value)
{
float4 v;
float4 result;
float4 reciprocal_two_pi = {0.159154943f, 0.159154943f, 0.159154943f, 0.159154943f};
float4 two_pi = {6.283185307f, 6.283185307f, 6.283185307f, 6.283185307f};
// Modulo the range of the given angles such that -XM_PI <= Angles < XM_PI
v = mul(value, reciprocal_two_pi);
v = round(v);
result = details::negative_multiply_subtract( two_pi, v, value);
return result;
}
}
//does not perform parameter check. expects input parameters in -pi<=value<pi
float4 sin_1(float4 value);
float4 cos_1(float4 value);
inline std::tuple<float4, float4> sin_cos(float4 value)
{
float4 v = details::mod_angles( value );
float4 v_1 = sin_1(v);
float4 v_2 = cos_1(v);
return std::make_tuple( v_1, v_2 );
}
inline std::tuple<float4, float4> sin_cos_1(float4 value)
{
float4 v_1 = sin_1(value);
float4 v_2 = cos_1(value);
return std::make_tuple( v_1, v_2 );
}
inline float4 sin(float4 value)
{
float4 v = details::mod_angles(value);
return sin_1(v);
}
inline float4 cos(float4 value)
{
float4 v = details::mod_angles(value);
return cos_1(v);
}
//compile time log2
template<uint32_t x> struct log2_c
{
static const uint32_t value = 1 + log2_c< x / 2>::value;
};
template<> struct log2_c<1>
{
static const uint32_t value = 0;
};
template<> struct log2_c<0>
{
};
}
#endif
|
[
"stefan.dyulgerov@gmail.com"
] |
stefan.dyulgerov@gmail.com
|
b6e40a9d15dc2ccfee5742c4505dd735c458bea5
|
2abed514f6558dcacc51ac1eff7317e815fe07ad
|
/Plugins/VRExpansionPlugin/VRExpansionPlugin/Intermediate/Build/Win64/UE4Editor/Inc/VRExpansionPlugin/VRGlobalSettings.generated.h
|
5112ccd9173be7f2bf52e361b12e689f6989bf10
|
[
"MIT"
] |
permissive
|
GoVRCenter/ManicMowersVR
|
7de6c87d75a8b4173745b0f6c1921a257befddf0
|
048d7643e4bf9e9e5c544d45b866c0162af8c555
|
refs/heads/master
| 2021-10-11T13:43:21.601465
| 2018-11-06T22:45:01
| 2018-11-06T22:45:01
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 14,123
|
h
|
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.
/*===========================================================================
Generated code exported from UnrealHeaderTool.
DO NOT modify this manually! Edit the corresponding .h files instead!
===========================================================================*/
#include "UObject/ObjectMacros.h"
#include "UObject/ScriptMacros.h"
PRAGMA_DISABLE_DEPRECATION_WARNINGS
struct FBPVRControllerProfile;
struct FTransform;
#ifdef VREXPANSIONPLUGIN_VRGlobalSettings_generated_h
#error "VRGlobalSettings.generated.h already included, missing '#pragma once' in VRGlobalSettings.h"
#endif
#define VREXPANSIONPLUGIN_VRGlobalSettings_generated_h
#define ManicMowersVR_Plugins_VRExpansionPlugin_VRExpansionPlugin_Source_VRExpansionPlugin_Public_VRGlobalSettings_h_40_GENERATED_BODY \
friend struct Z_Construct_UScriptStruct_FBPVRControllerProfile_Statics; \
static class UScriptStruct* StaticStruct();
#define ManicMowersVR_Plugins_VRExpansionPlugin_VRExpansionPlugin_Source_VRExpansionPlugin_Public_VRGlobalSettings_h_29_GENERATED_BODY \
friend struct Z_Construct_UScriptStruct_FActionMappingDetails_Statics; \
VREXPANSIONPLUGIN_API static class UScriptStruct* StaticStruct();
#define ManicMowersVR_Plugins_VRExpansionPlugin_VRExpansionPlugin_Source_VRExpansionPlugin_Public_VRGlobalSettings_h_17_GENERATED_BODY \
friend struct Z_Construct_UScriptStruct_FAxisMappingDetails_Statics; \
VREXPANSIONPLUGIN_API static class UScriptStruct* StaticStruct();
#define ManicMowersVR_Plugins_VRExpansionPlugin_VRExpansionPlugin_Source_VRExpansionPlugin_Public_VRGlobalSettings_h_105_RPC_WRAPPERS \
\
DECLARE_FUNCTION(execLoadControllerProfile) \
{ \
P_GET_STRUCT_REF(FBPVRControllerProfile,Z_Param_Out_ControllerProfile); \
P_GET_UBOOL(Z_Param_bSetAsCurrentProfile); \
P_FINISH; \
P_NATIVE_BEGIN; \
*(bool*)Z_Param__Result=UVRGlobalSettings::LoadControllerProfile(Z_Param_Out_ControllerProfile,Z_Param_bSetAsCurrentProfile); \
P_NATIVE_END; \
} \
\
DECLARE_FUNCTION(execLoadControllerProfileByName) \
{ \
P_GET_PROPERTY(UNameProperty,Z_Param_ControllerProfileName); \
P_GET_UBOOL(Z_Param_bSetAsCurrentProfile); \
P_FINISH; \
P_NATIVE_BEGIN; \
*(bool*)Z_Param__Result=UVRGlobalSettings::LoadControllerProfileByName(Z_Param_ControllerProfileName,Z_Param_bSetAsCurrentProfile); \
P_NATIVE_END; \
} \
\
DECLARE_FUNCTION(execGetControllerProfile) \
{ \
P_GET_PROPERTY(UNameProperty,Z_Param_ControllerProfileName); \
P_GET_STRUCT_REF(FBPVRControllerProfile,Z_Param_Out_OutProfile); \
P_FINISH; \
P_NATIVE_BEGIN; \
*(bool*)Z_Param__Result=UVRGlobalSettings::GetControllerProfile(Z_Param_ControllerProfileName,Z_Param_Out_OutProfile); \
P_NATIVE_END; \
} \
\
DECLARE_FUNCTION(execGetCurrentProfile) \
{ \
P_GET_UBOOL_REF(Z_Param_Out_bHadLoadedProfile); \
P_FINISH; \
P_NATIVE_BEGIN; \
*(FBPVRControllerProfile*)Z_Param__Result=UVRGlobalSettings::GetCurrentProfile(Z_Param_Out_bHadLoadedProfile); \
P_NATIVE_END; \
} \
\
DECLARE_FUNCTION(execGetCurrentProfileName) \
{ \
P_GET_UBOOL_REF(Z_Param_Out_bHadLoadedProfile); \
P_FINISH; \
P_NATIVE_BEGIN; \
*(FName*)Z_Param__Result=UVRGlobalSettings::GetCurrentProfileName(Z_Param_Out_bHadLoadedProfile); \
P_NATIVE_END; \
} \
\
DECLARE_FUNCTION(execSaveControllerProfiles) \
{ \
P_FINISH; \
P_NATIVE_BEGIN; \
UVRGlobalSettings::SaveControllerProfiles(); \
P_NATIVE_END; \
} \
\
DECLARE_FUNCTION(execDeleteControllerProfile) \
{ \
P_GET_PROPERTY(UNameProperty,Z_Param_ControllerProfileName); \
P_GET_UBOOL(Z_Param_bSaveOutToConfig); \
P_FINISH; \
P_NATIVE_BEGIN; \
UVRGlobalSettings::DeleteControllerProfile(Z_Param_ControllerProfileName,Z_Param_bSaveOutToConfig); \
P_NATIVE_END; \
} \
\
DECLARE_FUNCTION(execAddControllerProfile) \
{ \
P_GET_STRUCT_REF(FBPVRControllerProfile,Z_Param_Out_NewProfile); \
P_GET_UBOOL(Z_Param_bSaveOutToConfig); \
P_FINISH; \
P_NATIVE_BEGIN; \
UVRGlobalSettings::AddControllerProfile(Z_Param_Out_NewProfile,Z_Param_bSaveOutToConfig); \
P_NATIVE_END; \
} \
\
DECLARE_FUNCTION(execOverwriteControllerProfile) \
{ \
P_GET_STRUCT_REF(FBPVRControllerProfile,Z_Param_Out_OverwritingProfile); \
P_GET_UBOOL(Z_Param_bSaveOutToConfig); \
P_FINISH; \
P_NATIVE_BEGIN; \
UVRGlobalSettings::OverwriteControllerProfile(Z_Param_Out_OverwritingProfile,Z_Param_bSaveOutToConfig); \
P_NATIVE_END; \
} \
\
DECLARE_FUNCTION(execGetControllerProfiles) \
{ \
P_FINISH; \
P_NATIVE_BEGIN; \
*(TArray<FBPVRControllerProfile>*)Z_Param__Result=UVRGlobalSettings::GetControllerProfiles(); \
P_NATIVE_END; \
} \
\
DECLARE_FUNCTION(execAdjustTransformByGivenControllerProfile) \
{ \
P_GET_STRUCT_REF(FBPVRControllerProfile,Z_Param_Out_ControllerProfile); \
P_GET_STRUCT_REF(FTransform,Z_Param_Out_SocketTransform); \
P_GET_UBOOL(Z_Param_bIsRightHand); \
P_FINISH; \
P_NATIVE_BEGIN; \
*(FTransform*)Z_Param__Result=UVRGlobalSettings::AdjustTransformByGivenControllerProfile(Z_Param_Out_ControllerProfile,Z_Param_Out_SocketTransform,Z_Param_bIsRightHand); \
P_NATIVE_END; \
} \
\
DECLARE_FUNCTION(execAdjustTransformByControllerProfile) \
{ \
P_GET_PROPERTY(UNameProperty,Z_Param_OptionalControllerProfileName); \
P_GET_STRUCT_REF(FTransform,Z_Param_Out_SocketTransform); \
P_GET_UBOOL(Z_Param_bIsRightHand); \
P_FINISH; \
P_NATIVE_BEGIN; \
*(FTransform*)Z_Param__Result=UVRGlobalSettings::AdjustTransformByControllerProfile(Z_Param_OptionalControllerProfileName,Z_Param_Out_SocketTransform,Z_Param_bIsRightHand); \
P_NATIVE_END; \
}
#define ManicMowersVR_Plugins_VRExpansionPlugin_VRExpansionPlugin_Source_VRExpansionPlugin_Public_VRGlobalSettings_h_105_RPC_WRAPPERS_NO_PURE_DECLS \
\
DECLARE_FUNCTION(execLoadControllerProfile) \
{ \
P_GET_STRUCT_REF(FBPVRControllerProfile,Z_Param_Out_ControllerProfile); \
P_GET_UBOOL(Z_Param_bSetAsCurrentProfile); \
P_FINISH; \
P_NATIVE_BEGIN; \
*(bool*)Z_Param__Result=UVRGlobalSettings::LoadControllerProfile(Z_Param_Out_ControllerProfile,Z_Param_bSetAsCurrentProfile); \
P_NATIVE_END; \
} \
\
DECLARE_FUNCTION(execLoadControllerProfileByName) \
{ \
P_GET_PROPERTY(UNameProperty,Z_Param_ControllerProfileName); \
P_GET_UBOOL(Z_Param_bSetAsCurrentProfile); \
P_FINISH; \
P_NATIVE_BEGIN; \
*(bool*)Z_Param__Result=UVRGlobalSettings::LoadControllerProfileByName(Z_Param_ControllerProfileName,Z_Param_bSetAsCurrentProfile); \
P_NATIVE_END; \
} \
\
DECLARE_FUNCTION(execGetControllerProfile) \
{ \
P_GET_PROPERTY(UNameProperty,Z_Param_ControllerProfileName); \
P_GET_STRUCT_REF(FBPVRControllerProfile,Z_Param_Out_OutProfile); \
P_FINISH; \
P_NATIVE_BEGIN; \
*(bool*)Z_Param__Result=UVRGlobalSettings::GetControllerProfile(Z_Param_ControllerProfileName,Z_Param_Out_OutProfile); \
P_NATIVE_END; \
} \
\
DECLARE_FUNCTION(execGetCurrentProfile) \
{ \
P_GET_UBOOL_REF(Z_Param_Out_bHadLoadedProfile); \
P_FINISH; \
P_NATIVE_BEGIN; \
*(FBPVRControllerProfile*)Z_Param__Result=UVRGlobalSettings::GetCurrentProfile(Z_Param_Out_bHadLoadedProfile); \
P_NATIVE_END; \
} \
\
DECLARE_FUNCTION(execGetCurrentProfileName) \
{ \
P_GET_UBOOL_REF(Z_Param_Out_bHadLoadedProfile); \
P_FINISH; \
P_NATIVE_BEGIN; \
*(FName*)Z_Param__Result=UVRGlobalSettings::GetCurrentProfileName(Z_Param_Out_bHadLoadedProfile); \
P_NATIVE_END; \
} \
\
DECLARE_FUNCTION(execSaveControllerProfiles) \
{ \
P_FINISH; \
P_NATIVE_BEGIN; \
UVRGlobalSettings::SaveControllerProfiles(); \
P_NATIVE_END; \
} \
\
DECLARE_FUNCTION(execDeleteControllerProfile) \
{ \
P_GET_PROPERTY(UNameProperty,Z_Param_ControllerProfileName); \
P_GET_UBOOL(Z_Param_bSaveOutToConfig); \
P_FINISH; \
P_NATIVE_BEGIN; \
UVRGlobalSettings::DeleteControllerProfile(Z_Param_ControllerProfileName,Z_Param_bSaveOutToConfig); \
P_NATIVE_END; \
} \
\
DECLARE_FUNCTION(execAddControllerProfile) \
{ \
P_GET_STRUCT_REF(FBPVRControllerProfile,Z_Param_Out_NewProfile); \
P_GET_UBOOL(Z_Param_bSaveOutToConfig); \
P_FINISH; \
P_NATIVE_BEGIN; \
UVRGlobalSettings::AddControllerProfile(Z_Param_Out_NewProfile,Z_Param_bSaveOutToConfig); \
P_NATIVE_END; \
} \
\
DECLARE_FUNCTION(execOverwriteControllerProfile) \
{ \
P_GET_STRUCT_REF(FBPVRControllerProfile,Z_Param_Out_OverwritingProfile); \
P_GET_UBOOL(Z_Param_bSaveOutToConfig); \
P_FINISH; \
P_NATIVE_BEGIN; \
UVRGlobalSettings::OverwriteControllerProfile(Z_Param_Out_OverwritingProfile,Z_Param_bSaveOutToConfig); \
P_NATIVE_END; \
} \
\
DECLARE_FUNCTION(execGetControllerProfiles) \
{ \
P_FINISH; \
P_NATIVE_BEGIN; \
*(TArray<FBPVRControllerProfile>*)Z_Param__Result=UVRGlobalSettings::GetControllerProfiles(); \
P_NATIVE_END; \
} \
\
DECLARE_FUNCTION(execAdjustTransformByGivenControllerProfile) \
{ \
P_GET_STRUCT_REF(FBPVRControllerProfile,Z_Param_Out_ControllerProfile); \
P_GET_STRUCT_REF(FTransform,Z_Param_Out_SocketTransform); \
P_GET_UBOOL(Z_Param_bIsRightHand); \
P_FINISH; \
P_NATIVE_BEGIN; \
*(FTransform*)Z_Param__Result=UVRGlobalSettings::AdjustTransformByGivenControllerProfile(Z_Param_Out_ControllerProfile,Z_Param_Out_SocketTransform,Z_Param_bIsRightHand); \
P_NATIVE_END; \
} \
\
DECLARE_FUNCTION(execAdjustTransformByControllerProfile) \
{ \
P_GET_PROPERTY(UNameProperty,Z_Param_OptionalControllerProfileName); \
P_GET_STRUCT_REF(FTransform,Z_Param_Out_SocketTransform); \
P_GET_UBOOL(Z_Param_bIsRightHand); \
P_FINISH; \
P_NATIVE_BEGIN; \
*(FTransform*)Z_Param__Result=UVRGlobalSettings::AdjustTransformByControllerProfile(Z_Param_OptionalControllerProfileName,Z_Param_Out_SocketTransform,Z_Param_bIsRightHand); \
P_NATIVE_END; \
}
#define ManicMowersVR_Plugins_VRExpansionPlugin_VRExpansionPlugin_Source_VRExpansionPlugin_Public_VRGlobalSettings_h_105_INCLASS_NO_PURE_DECLS \
private: \
static void StaticRegisterNativesUVRGlobalSettings(); \
friend struct Z_Construct_UClass_UVRGlobalSettings_Statics; \
public: \
DECLARE_CLASS(UVRGlobalSettings, UObject, COMPILED_IN_FLAGS(0 | CLASS_DefaultConfig | CLASS_Config), CASTCLASS_None, TEXT("/Script/VRExpansionPlugin"), NO_API) \
DECLARE_SERIALIZER(UVRGlobalSettings) \
static const TCHAR* StaticConfigName() {return TEXT("Engine");} \
#define ManicMowersVR_Plugins_VRExpansionPlugin_VRExpansionPlugin_Source_VRExpansionPlugin_Public_VRGlobalSettings_h_105_INCLASS \
private: \
static void StaticRegisterNativesUVRGlobalSettings(); \
friend struct Z_Construct_UClass_UVRGlobalSettings_Statics; \
public: \
DECLARE_CLASS(UVRGlobalSettings, UObject, COMPILED_IN_FLAGS(0 | CLASS_DefaultConfig | CLASS_Config), CASTCLASS_None, TEXT("/Script/VRExpansionPlugin"), NO_API) \
DECLARE_SERIALIZER(UVRGlobalSettings) \
static const TCHAR* StaticConfigName() {return TEXT("Engine");} \
#define ManicMowersVR_Plugins_VRExpansionPlugin_VRExpansionPlugin_Source_VRExpansionPlugin_Public_VRGlobalSettings_h_105_STANDARD_CONSTRUCTORS \
/** Standard constructor, called after all reflected properties have been initialized */ \
NO_API UVRGlobalSettings(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get()); \
DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL(UVRGlobalSettings) \
DECLARE_VTABLE_PTR_HELPER_CTOR(NO_API, UVRGlobalSettings); \
DEFINE_VTABLE_PTR_HELPER_CTOR_CALLER(UVRGlobalSettings); \
private: \
/** Private move- and copy-constructors, should never be used */ \
NO_API UVRGlobalSettings(UVRGlobalSettings&&); \
NO_API UVRGlobalSettings(const UVRGlobalSettings&); \
public:
#define ManicMowersVR_Plugins_VRExpansionPlugin_VRExpansionPlugin_Source_VRExpansionPlugin_Public_VRGlobalSettings_h_105_ENHANCED_CONSTRUCTORS \
private: \
/** Private move- and copy-constructors, should never be used */ \
NO_API UVRGlobalSettings(UVRGlobalSettings&&); \
NO_API UVRGlobalSettings(const UVRGlobalSettings&); \
public: \
DECLARE_VTABLE_PTR_HELPER_CTOR(NO_API, UVRGlobalSettings); \
DEFINE_VTABLE_PTR_HELPER_CTOR_CALLER(UVRGlobalSettings); \
DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL(UVRGlobalSettings)
#define ManicMowersVR_Plugins_VRExpansionPlugin_VRExpansionPlugin_Source_VRExpansionPlugin_Public_VRGlobalSettings_h_105_PRIVATE_PROPERTY_OFFSET
#define ManicMowersVR_Plugins_VRExpansionPlugin_VRExpansionPlugin_Source_VRExpansionPlugin_Public_VRGlobalSettings_h_102_PROLOG
#define ManicMowersVR_Plugins_VRExpansionPlugin_VRExpansionPlugin_Source_VRExpansionPlugin_Public_VRGlobalSettings_h_105_GENERATED_BODY_LEGACY \
PRAGMA_DISABLE_DEPRECATION_WARNINGS \
public: \
ManicMowersVR_Plugins_VRExpansionPlugin_VRExpansionPlugin_Source_VRExpansionPlugin_Public_VRGlobalSettings_h_105_PRIVATE_PROPERTY_OFFSET \
ManicMowersVR_Plugins_VRExpansionPlugin_VRExpansionPlugin_Source_VRExpansionPlugin_Public_VRGlobalSettings_h_105_RPC_WRAPPERS \
ManicMowersVR_Plugins_VRExpansionPlugin_VRExpansionPlugin_Source_VRExpansionPlugin_Public_VRGlobalSettings_h_105_INCLASS \
ManicMowersVR_Plugins_VRExpansionPlugin_VRExpansionPlugin_Source_VRExpansionPlugin_Public_VRGlobalSettings_h_105_STANDARD_CONSTRUCTORS \
public: \
PRAGMA_ENABLE_DEPRECATION_WARNINGS
#define ManicMowersVR_Plugins_VRExpansionPlugin_VRExpansionPlugin_Source_VRExpansionPlugin_Public_VRGlobalSettings_h_105_GENERATED_BODY \
PRAGMA_DISABLE_DEPRECATION_WARNINGS \
public: \
ManicMowersVR_Plugins_VRExpansionPlugin_VRExpansionPlugin_Source_VRExpansionPlugin_Public_VRGlobalSettings_h_105_PRIVATE_PROPERTY_OFFSET \
ManicMowersVR_Plugins_VRExpansionPlugin_VRExpansionPlugin_Source_VRExpansionPlugin_Public_VRGlobalSettings_h_105_RPC_WRAPPERS_NO_PURE_DECLS \
ManicMowersVR_Plugins_VRExpansionPlugin_VRExpansionPlugin_Source_VRExpansionPlugin_Public_VRGlobalSettings_h_105_INCLASS_NO_PURE_DECLS \
ManicMowersVR_Plugins_VRExpansionPlugin_VRExpansionPlugin_Source_VRExpansionPlugin_Public_VRGlobalSettings_h_105_ENHANCED_CONSTRUCTORS \
private: \
PRAGMA_ENABLE_DEPRECATION_WARNINGS
#undef CURRENT_FILE_ID
#define CURRENT_FILE_ID ManicMowersVR_Plugins_VRExpansionPlugin_VRExpansionPlugin_Source_VRExpansionPlugin_Public_VRGlobalSettings_h
PRAGMA_ENABLE_DEPRECATION_WARNINGS
|
[
"Hamltoe@gmail.com"
] |
Hamltoe@gmail.com
|
95add1d11568fd7c23ce9313fc99393813f131ee
|
5690958c4d974acecada4de2daf38a4c425f7a58
|
/src/main.cpp
|
f778ce7a440f6e12c19cefc8742cdd0c7abdd9b2
|
[] |
no_license
|
greatwallisme/ctp_hft
|
00f18b73bfbf78e9b7d079c52b7707a7cea87a0b
|
e37e54ef73e8e45cd68ef9e333c2c9be33b9f68f
|
refs/heads/master
| 2020-04-15T21:55:42.357372
| 2017-08-04T09:40:00
| 2017-08-04T09:40:00
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 597
|
cpp
|
/******************************************************************************
Copyright (c) 2016. All Rights Reserved.
FileName: main.cpp
Version: 1.0
Date: 2017.4.25
History:
shengkaishan 2017.4.25 1.0 Create
******************************************************************************/
#include "future_platform.h"
#include <QtWidgets/QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTextCodec::setCodecForLocale(QTextCodec::codecForName("GBK"));
future::future_platform w;
w.start_server();
w.show();
return a.exec();
}
|
[
"kaishansheng@163.com"
] |
kaishansheng@163.com
|
48d7e90711c85e7ea440ebf8a4c4813740d50031
|
119828e4a5a7bd3cec7360d47765e68a780fe34d
|
/Framework/Core/D3D11/Pipeline.cpp
|
4cd5f07b1355cc0ff800e470fe4454e3de2b4a8e
|
[] |
no_license
|
JoSungHun/TerrianEditor
|
4b5b11cf0d672b114e0ab7d7940f674e232beae2
|
fb8c57dfe270df7e52dfd04e9e81c7b00b29f458
|
refs/heads/master
| 2020-06-05T03:53:00.212549
| 2019-06-17T08:33:19
| 2019-06-17T08:33:19
| 192,304,158
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,509
|
cpp
|
#include "Framework.h"
#include "Pipeline.h"
Pipeline::Pipeline(Context * context)
: context(context)
, vertexBuffer(nullptr)
, instanceBuffer(nullptr)
, indexBuffer(nullptr)
, inputLayout(nullptr)
, vertexShader(nullptr)
, hullShader(nullptr)
, domainShader(nullptr)
, pixelShader(nullptr)
, rsState(nullptr)
{
graphics = context->GetSubsystem<Graphics>();
rsState = new RasterizerState(context);
}
Pipeline::~Pipeline()
{
SAFE_DELETE(vertexShader);
SAFE_DELETE(hullShader);
SAFE_DELETE(domainShader);
SAFE_DELETE(pixelShader);
//SAFE_DELETE(geometryShader);
for (auto cBuffer : vsConstantBuffers)
{
SAFE_DELETE(cBuffer);
}
vsConstantBuffers.shrink_to_fit();
for (auto cBuffer : hsConstantBuffers)
{
SAFE_DELETE(cBuffer);
}
hsConstantBuffers.shrink_to_fit();
for (auto cBuffer : dsConstantBuffers)
{
SAFE_DELETE(cBuffer);
}
dsConstantBuffers.shrink_to_fit();
for (auto cBuffer : psConstantBuffers)
{
SAFE_DELETE(cBuffer);
}
psConstantBuffers.shrink_to_fit();
}
void Pipeline::SetInputLayout(D3D11_INPUT_ELEMENT_DESC* descs, const uint& count)
{
if (inputLayout)
SAFE_DELETE(inputLayout);
inputLayout = new InputLayout(context);
inputLayout->Create(descs, count, vertexShader->GetBlob());
}
void Pipeline::SetShader(const ShaderType & type, const std::string & shaderFileName)
{
switch (type)
{
case ShaderType::VS:
if (vertexShader)
SAFE_DELETE(vertexShader);
vertexShader = new VertexShader(context);
vertexShader->Create(shaderFileName);
inputLayout = new InputLayout(context);
inputLayout->Create(vertexShader->GetBlob());
break;
case ShaderType::HS:
if (hullShader)
SAFE_DELETE(hullShader);
hullShader = new HullShader(context);
hullShader->Create(shaderFileName);
break;
case ShaderType::DS:
if (domainShader)
SAFE_DELETE(domainShader);
domainShader = new DomainShader(context);
domainShader->Create(shaderFileName);
break;
case ShaderType::GS:
//shader = new GeometryShader(context);
break;
case ShaderType::PS:
if (pixelShader)
SAFE_DELETE(pixelShader);
pixelShader = new PixelShader(context);
pixelShader->Create(shaderFileName);
break;
default:
return;
break;
}
}
void Pipeline::SetSRVSlot(const ShaderType & type, const uint & numSRVSlot)
{
if (numSRVSlot == 0)
return;
switch (type)
{
case ShaderType::VS:
vsShaderResourceViews.resize(numSRVSlot);
break;
case ShaderType::HS:
hsShaderResourceViews.resize(numSRVSlot);
break;
case ShaderType::DS:
dsShaderResourceViews.resize(numSRVSlot);
break;
case ShaderType::GS:
//gsShaderResourceViews.resize(numSRVSlot);
break;
case ShaderType::PS:
psShaderResourceViews.resize(numSRVSlot);
break;
default:
break;
}
}
void Pipeline::SetSRVSlot(const uint & vsSlot, const uint & psSlot, const uint & hsSlot, const uint & dsSlot, const uint & gsSlot)
{
SetSRVSlot(ShaderType::VS, vsSlot);
SetSRVSlot(ShaderType::PS, psSlot);
SetSRVSlot(ShaderType::HS, hsSlot);
SetSRVSlot(ShaderType::DS, dsSlot);
SetSRVSlot(ShaderType::GS, gsSlot);
}
void Pipeline::SetShaderResourceView(const ShaderType & type, const uint & slotNum, ID3D11ShaderResourceView * srv)
{
switch (type)
{
case ShaderType::VS:
vsShaderResourceViews[slotNum] = srv;
break;
case ShaderType::HS:
hsShaderResourceViews[slotNum] = srv;
break;
case ShaderType::DS:
dsShaderResourceViews[slotNum] = srv;
break;
case ShaderType::GS:
//gsShaderResoruceViews[slotNum] = srv;
break;
case ShaderType::PS:
psShaderResourceViews[slotNum] = srv;
break;
default:
break;
}
}
void Pipeline::SetShaderResourceView(const ShaderType & type, const uint & slotNum, Texture * texture)
{
switch (type)
{
case ShaderType::VS:
vsShaderResourceViews[slotNum] = texture->GetSRV();
break;
case ShaderType::HS:
hsShaderResourceViews[slotNum] = texture->GetSRV();
break;
case ShaderType::DS:
dsShaderResourceViews[slotNum] = texture->GetSRV();
break;
case ShaderType::GS:
//gsShaderResoruceViews[slotNum] = texture->GetSRV();
break;
case ShaderType::PS:
psShaderResourceViews[slotNum] = texture->GetSRV();
break;
default:
break;
}
}
void Pipeline::SetShaderResourceView(const ShaderType & type, const uint & slotNum, const std::string & fileName)
{
//TODO : Create ResourceManager and get srv from fileName
}
void Pipeline::SetRSCullMode(const D3D11_CULL_MODE & cullmode)
{
rsState->CullMode(cullmode);
}
void Pipeline::SetRSFillMode(const D3D11_FILL_MODE & fillMode)
{
rsState->FillMode(fillMode);
}
void Pipeline::Bind()
{
if (instanceBuffer)
{
ID3D11Buffer* arrBuffer[2] = { vertexBuffer->GetBuffer(), instanceBuffer->GetBuffer() };
uint arrStride[2] = { vertexBuffer->GetStride(),instanceBuffer->GetStride() };
uint arrOffset[2] = { vertexBuffer->GetOffset(),instanceBuffer->GetOffset() };
graphics->GetDeviceContext()->IASetVertexBuffers(0, 2, arrBuffer, arrStride, arrOffset);
}
else
{
vertexBuffer->BindPipeline();
}
indexBuffer->BindPipeline();
inputLayout->BindPipeline();
graphics->GetDeviceContext()->IASetPrimitiveTopology(topology);
for (uint i = 0; i < vsConstantBuffers.size(); ++i)
vsConstantBuffers[i]->buffer->BindPipeline(ShaderType::VS, i);
for (uint i = 0; i < vsShaderResourceViews.size(); ++i)
graphics->GetDeviceContext()->VSSetShaderResources(i, 1, &vsShaderResourceViews[i]);
for (uint i = 0; i < hsConstantBuffers.size(); ++i)
hsConstantBuffers[i]->buffer->BindPipeline(ShaderType::HS, i);
for (uint i = 0; i < hsShaderResourceViews.size(); ++i)
graphics->GetDeviceContext()->HSSetShaderResources(i, 1, &hsShaderResourceViews[i]);
for (uint i = 0; i < dsConstantBuffers.size(); ++i)
dsConstantBuffers[i]->buffer->BindPipeline(ShaderType::DS, i);
for (uint i = 0; i < dsShaderResourceViews.size(); ++i)
graphics->GetDeviceContext()->DSSetShaderResources(i, 1, &dsShaderResourceViews[i]);
for (uint i = 0; i < psConstantBuffers.size(); ++i)
psConstantBuffers[i]->buffer->BindPipeline(ShaderType::PS, i);
for (uint i = 0; i < psShaderResourceViews.size(); ++i)
graphics->GetDeviceContext()->PSSetShaderResources(i, 1, &psShaderResourceViews[i]);
if(vertexShader)
vertexShader->BindPipeline();
if(hullShader)
hullShader->BindPipeline();
if(domainShader)
domainShader->BindPipeline();
if(pixelShader)
pixelShader->BindPipeline();
if(rsState)
rsState->BindPipeline();
}
void Pipeline::UnBind()
{
if (rsState)
rsState->UnbindPipeline();
if(domainShader || hullShader)
graphics->TurnBackOffShaders();
}
|
[
"41054697+JoSungHun@users.noreply.github.com"
] |
41054697+JoSungHun@users.noreply.github.com
|
a2ddcdd59aea562ea0a1597cc2c8d89792af6dd2
|
d0c44dd3da2ef8c0ff835982a437946cbf4d2940
|
/cmake-build-debug/programs_tiling/function14388/function14388_schedule_26/function14388_schedule_26.cpp
|
230a8256495d389733d6649b98192ac008f7c35f
|
[] |
no_license
|
IsraMekki/tiramisu_code_generator
|
8b3f1d63cff62ba9f5242c019058d5a3119184a3
|
5a259d8e244af452e5301126683fa4320c2047a3
|
refs/heads/master
| 2020-04-29T17:27:57.987172
| 2019-04-23T16:50:32
| 2019-04-23T16:50:32
| 176,297,755
| 1
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,520
|
cpp
|
#include <tiramisu/tiramisu.h>
using namespace tiramisu;
int main(int argc, char **argv){
tiramisu::init("function14388_schedule_26");
constant c0("c0", 256), c1("c1", 512), c2("c2", 512);
var i0("i0", 0, c0), i1("i1", 0, c1), i2("i2", 0, c2), i01("i01"), i02("i02"), i03("i03"), i04("i04"), i05("i05"), i06("i06");
input input00("input00", {i0, i1}, p_int32);
input input01("input01", {i0, i1}, p_int32);
input input02("input02", {i0, i1}, p_int32);
input input03("input03", {i1, i2}, p_int32);
input input04("input04", {i0}, p_int32);
computation comp0("comp0", {i0, i1, i2}, input00(i0, i1) * input01(i0, i1) * input02(i0, i1) + input03(i1, i2) - input04(i0));
comp0.tile(i0, i1, i2, 32, 128, 128, i01, i02, i03, i04, i05, i06);
comp0.parallelize(i01);
buffer buf00("buf00", {256, 512}, p_int32, a_input);
buffer buf01("buf01", {256, 512}, p_int32, a_input);
buffer buf02("buf02", {256, 512}, p_int32, a_input);
buffer buf03("buf03", {512, 512}, p_int32, a_input);
buffer buf04("buf04", {256}, p_int32, a_input);
buffer buf0("buf0", {256, 512, 512}, p_int32, a_output);
input00.store_in(&buf00);
input01.store_in(&buf01);
input02.store_in(&buf02);
input03.store_in(&buf03);
input04.store_in(&buf04);
comp0.store_in(&buf0);
tiramisu::codegen({&buf00, &buf01, &buf02, &buf03, &buf04, &buf0}, "../data/programs/function14388/function14388_schedule_26/function14388_schedule_26.o");
return 0;
}
|
[
"ei_mekki@esi.dz"
] |
ei_mekki@esi.dz
|
e8bf6859f3c556f1f119f76df598514eb64cdd7f
|
490ee4233db2f8833633722041667b8d496d1aea
|
/CodeBinder.Java/JNI/Resources/JNIBoxes.h
|
be5129aad1670d3bf7be29e71fe7de71267792f2
|
[
"MIT"
] |
permissive
|
ceztko/CodeBinder
|
eb474fcac6d94954fd39cf2e68b87a217d41c0ff
|
8a86f9740cd199545005023221e026ab2b9af9af
|
refs/heads/master
| 2023-08-03T11:36:53.987661
| 2023-08-02T16:10:13
| 2023-08-02T16:10:13
| 154,561,427
| 1
| 0
|
MIT
| 2023-08-11T08:24:13
| 2018-10-24T19:58:43
|
C#
|
UTF-8
|
C++
| false
| false
| 2,534
|
h
|
/* This file was generated. DO NOT EDIT! */
#pragma once
#include "JNITypesPrivate.h"
#include <CBBaseTypes.h>
// Wraps java numerical box type
template <typename TJBox, typename TNative = typename TJBox::ValueType>
class BJ2NImpl
{
public:
BJ2NImpl(JNIEnv* env, typename TJBox::BoxPtr box)
{
m_env = env;
m_box = box;
m_value = (TNative)box->GetValue(env);
}
~BJ2NImpl()
{
m_box->SetValue(m_env, (typename TJBox::ValueType)m_value);
}
public:
inline operator TNative* () { return &m_value; }
public:
TNative m_value;
JNIEnv* m_env;
typename TJBox::BoxPtr m_box;
};
// Wraps java string box type
class SBJ2N
{
public:
SBJ2N(JNIEnv* env, jStringBox box);
~SBJ2N();
public:
inline operator cbstring* () { return &m_value; }
private:
JNIEnv* m_env;
jStringBox m_box;
jstring m_jstring;
const char* m_chars;
jboolean m_isCopy;
cbstring m_value;
};
BJ2NImpl<_jBooleanBox> BJ2N(JNIEnv* env, jBooleanBox box);
BJ2NImpl<_jByteBox> BJ2N(JNIEnv* env, jByteBox box);
BJ2NImpl<_jShortBox> BJ2N(JNIEnv* env, jShortBox box);
BJ2NImpl<_jIntegerBox> BJ2N(JNIEnv* env, jIntegerBox box);
BJ2NImpl<_jLongBox> BJ2N(JNIEnv* env, jLongBox box);
BJ2NImpl<_jFloatBox> BJ2N(JNIEnv* env, jFloatBox box);
BJ2NImpl<_jDoubleBox> BJ2N(JNIEnv* env, jDoubleBox box);
SBJ2N BJ2N(JNIEnv* env, jStringBox box);
template <typename TNative>
BJ2NImpl<_jBooleanBox, TNative> BJ2N(JNIEnv* env, jBooleanBox box)
{
return BJ2NImpl<_jBooleanBox, TNative>(env, box);
}
template <typename TNative>
BJ2NImpl<_jByteBox, TNative> BJ2N(JNIEnv* env, jByteBox box)
{
return BJ2NImpl<_jByteBox, TNative>(env, box);
}
template <typename TNative>
BJ2NImpl<_jShortBox, TNative> BJ2N(JNIEnv* env, jShortBox box)
{
return BJ2NImpl<_jShortBox, TNative>(env, box);
}
template <typename TNative>
BJ2NImpl<_jIntegerBox, TNative> BJ2N(JNIEnv* env, jIntegerBox box)
{
return BJ2NImpl<_jIntegerBox, TNative>(env, box);
}
template <typename TNative>
BJ2NImpl<_jLongBox, TNative> BJ2N(JNIEnv* env, jLongBox box)
{
return BJ2NImpl<_jLongBox, TNative>(env, box);
}
template <typename TNative>
BJ2NImpl<_jFloatBox, TNative> BJ2N(JNIEnv* env, jFloatBox box)
{
return BJ2NImpl<_jFloatBox, TNative>(env, box);
}
template <typename TNative>
BJ2NImpl<_jDoubleBox, TNative> BJ2N(JNIEnv* env, jDoubleBox box)
{
return BJ2NImpl<_jDoubleBox, TNative>(env, box);
}
|
[
"ceztko@gmail.com"
] |
ceztko@gmail.com
|
7343f4a3d7fceaecb8181a7d74276c03e6cb1cfa
|
cefd6c17774b5c94240d57adccef57d9bba4a2e9
|
/WebKit/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.cpp
|
254a83d87845e7464da3299583e9da41df9ffd5d
|
[
"BSL-1.0"
] |
permissive
|
adzhou/oragle
|
9c054c25b24ff0a65cb9639bafd02aac2bcdce8b
|
5442d418b87d0da161429ffa5cb83777e9b38e4d
|
refs/heads/master
| 2022-11-01T05:04:59.368831
| 2014-03-12T15:50:08
| 2014-03-12T15:50:08
| 17,238,063
| 0
| 1
|
BSL-1.0
| 2022-10-18T04:23:53
| 2014-02-27T05:39:44
|
C++
|
UTF-8
|
C++
| false
| false
| 20,891
|
cpp
|
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
* Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "config.h"
#if USE(COORDINATED_GRAPHICS)
#include "CoordinatedDrawingArea.h"
#include "DrawingAreaProxyMessages.h"
#include "LayerTreeContext.h"
#include "ShareableBitmap.h"
#include "UpdateInfo.h"
#include "WebPage.h"
#include "WebPageCreationParameters.h"
#include "WebProcess.h"
#include <WebCore/GraphicsContext.h>
#include <WebCore/Page.h>
#include <WebCore/Settings.h>
using namespace WebCore;
namespace WebKit {
CoordinatedDrawingArea::~CoordinatedDrawingArea()
{
if (m_layerTreeHost)
m_layerTreeHost->invalidate();
}
CoordinatedDrawingArea::CoordinatedDrawingArea(WebPage* webPage, const WebPageCreationParameters& parameters)
: DrawingArea(DrawingAreaTypeCoordinated, webPage)
, m_backingStoreStateID(0)
, m_isPaintingEnabled(true)
, m_inUpdateBackingStoreState(false)
, m_shouldSendDidUpdateBackingStoreState(false)
, m_isWaitingForDidUpdate(false)
, m_compositingAccordingToProxyMessages(false)
, m_layerTreeStateIsFrozen(false)
, m_wantsToExitAcceleratedCompositingMode(false)
, m_isPaintingSuspended(!(parameters.viewState & ViewState::IsVisible))
, m_displayTimer(RunLoop::main(), this, &CoordinatedDrawingArea::displayTimerFired)
, m_exitCompositingTimer(RunLoop::main(), this, &CoordinatedDrawingArea::exitAcceleratedCompositingMode)
{
// Always use compositing in CoordinatedGraphics
enterAcceleratedCompositingMode(0);
}
void CoordinatedDrawingArea::setNeedsDisplay()
{
if (!m_isPaintingEnabled)
return;
if (m_layerTreeHost) {
ASSERT(m_dirtyRegion.isEmpty());
m_layerTreeHost->setNonCompositedContentsNeedDisplay();
return;
}
setNeedsDisplayInRect(m_webPage->bounds());
}
void CoordinatedDrawingArea::setNeedsDisplayInRect(const IntRect& rect)
{
if (!m_isPaintingEnabled)
return;
if (m_layerTreeHost) {
ASSERT(m_dirtyRegion.isEmpty());
m_layerTreeHost->setNonCompositedContentsNeedDisplayInRect(rect);
return;
}
IntRect dirtyRect = rect;
dirtyRect.intersect(m_webPage->bounds());
if (dirtyRect.isEmpty())
return;
m_dirtyRegion.unite(dirtyRect);
scheduleDisplay();
}
void CoordinatedDrawingArea::scroll(const IntRect& scrollRect, const IntSize& scrollDelta)
{
if (!m_isPaintingEnabled)
return;
if (m_layerTreeHost) {
ASSERT(m_scrollRect.isEmpty());
ASSERT(m_scrollOffset.isEmpty());
ASSERT(m_dirtyRegion.isEmpty());
m_layerTreeHost->scrollNonCompositedContents(scrollRect);
return;
}
if (scrollRect.isEmpty())
return;
if (!m_scrollRect.isEmpty() && scrollRect != m_scrollRect) {
unsigned scrollArea = scrollRect.width() * scrollRect.height();
unsigned currentScrollArea = m_scrollRect.width() * m_scrollRect.height();
if (currentScrollArea >= scrollArea) {
// The rect being scrolled is at least as large as the rect we'd like to scroll.
// Go ahead and just invalidate the scroll rect.
setNeedsDisplayInRect(scrollRect);
return;
}
// Just repaint the entire current scroll rect, we'll scroll the new rect instead.
setNeedsDisplayInRect(m_scrollRect);
m_scrollRect = IntRect();
m_scrollOffset = IntSize();
}
// Get the part of the dirty region that is in the scroll rect.
Region dirtyRegionInScrollRect = intersect(scrollRect, m_dirtyRegion);
if (!dirtyRegionInScrollRect.isEmpty()) {
// There are parts of the dirty region that are inside the scroll rect.
// We need to subtract them from the region, move them and re-add them.
m_dirtyRegion.subtract(scrollRect);
// Move the dirty parts.
Region movedDirtyRegionInScrollRect = intersect(translate(dirtyRegionInScrollRect, scrollDelta), scrollRect);
// And add them back.
m_dirtyRegion.unite(movedDirtyRegionInScrollRect);
}
// Compute the scroll repaint region.
Region scrollRepaintRegion = subtract(scrollRect, translate(scrollRect, scrollDelta));
m_dirtyRegion.unite(scrollRepaintRegion);
scheduleDisplay();
m_scrollRect = scrollRect;
m_scrollOffset += scrollDelta;
}
void CoordinatedDrawingArea::pageBackgroundTransparencyChanged()
{
if (m_layerTreeHost)
m_layerTreeHost->pageBackgroundTransparencyChanged();
}
void CoordinatedDrawingArea::setLayerTreeStateIsFrozen(bool isFrozen)
{
if (m_layerTreeStateIsFrozen == isFrozen)
return;
m_layerTreeStateIsFrozen = isFrozen;
if (m_layerTreeHost)
m_layerTreeHost->setLayerFlushSchedulingEnabled(!isFrozen);
if (isFrozen)
m_exitCompositingTimer.stop();
else if (m_wantsToExitAcceleratedCompositingMode)
exitAcceleratedCompositingModeSoon();
}
void CoordinatedDrawingArea::forceRepaint()
{
setNeedsDisplay();
m_webPage->layoutIfNeeded();
if (m_layerTreeHost) {
// FIXME: We need to do the same work as the layerHostDidFlushLayers function here,
// but clearly it doesn't make sense to call the function with that name.
// Consider refactoring and renaming it.
if (m_compositingAccordingToProxyMessages)
m_layerTreeHost->forceRepaint();
else {
// Call setShouldNotifyAfterNextScheduledLayerFlush(false) here to
// prevent layerHostDidFlushLayers() from being called a second time.
m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(false);
layerHostDidFlushLayers();
}
return;
}
m_isWaitingForDidUpdate = false;
display();
}
bool CoordinatedDrawingArea::forceRepaintAsync(uint64_t callbackID)
{
return m_layerTreeHost && m_layerTreeHost->forceRepaintAsync(callbackID);
}
void CoordinatedDrawingArea::didInstallPageOverlay(PageOverlay* pageOverlay)
{
if (m_layerTreeHost)
m_layerTreeHost->didInstallPageOverlay(pageOverlay);
}
void CoordinatedDrawingArea::didUninstallPageOverlay(PageOverlay* pageOverlay)
{
if (m_layerTreeHost)
m_layerTreeHost->didUninstallPageOverlay(pageOverlay);
setNeedsDisplay();
}
void CoordinatedDrawingArea::setPageOverlayNeedsDisplay(PageOverlay* pageOverlay, const IntRect& rect)
{
if (m_layerTreeHost) {
m_layerTreeHost->setPageOverlayNeedsDisplay(pageOverlay, rect);
return;
}
setNeedsDisplayInRect(rect);
}
void CoordinatedDrawingArea::setPageOverlayOpacity(PageOverlay* pageOverlay, float value)
{
if (m_layerTreeHost)
m_layerTreeHost->setPageOverlayOpacity(pageOverlay, value);
}
void CoordinatedDrawingArea::setPaintingEnabled(bool paintingEnabled)
{
m_isPaintingEnabled = paintingEnabled;
}
void CoordinatedDrawingArea::updatePreferences(const WebPreferencesStore& store)
{
m_webPage->corePage()->settings().setForceCompositingMode(store.getBoolValueForKey(WebPreferencesKey::forceCompositingModeKey()) && LayerTreeHost::supportsAcceleratedCompositing());
}
void CoordinatedDrawingArea::layerHostDidFlushLayers()
{
ASSERT(m_layerTreeHost);
m_layerTreeHost->forceRepaint();
if (m_shouldSendDidUpdateBackingStoreState && !exitAcceleratedCompositingModePending()) {
sendDidUpdateBackingStoreState();
return;
}
if (!m_layerTreeHost)
return;
ASSERT(!m_compositingAccordingToProxyMessages);
if (!exitAcceleratedCompositingModePending()) {
m_webPage->send(Messages::DrawingAreaProxy::EnterAcceleratedCompositingMode(m_backingStoreStateID, m_layerTreeHost->layerTreeContext()));
m_compositingAccordingToProxyMessages = true;
}
}
GraphicsLayerFactory* CoordinatedDrawingArea::graphicsLayerFactory()
{
if (m_layerTreeHost)
return m_layerTreeHost->graphicsLayerFactory();
return 0;
}
void CoordinatedDrawingArea::setRootCompositingLayer(GraphicsLayer* graphicsLayer)
{
// FIXME: Instead of using nested if statements, we should keep a compositing state
// enum in the CoordinatedDrawingArea object and have a changeAcceleratedCompositingState function
// that takes the new state.
if (graphicsLayer) {
if (!m_layerTreeHost) {
// We're actually entering accelerated compositing mode.
enterAcceleratedCompositingMode(graphicsLayer);
} else {
// We're already in accelerated compositing mode, but the root compositing layer changed.
m_exitCompositingTimer.stop();
m_wantsToExitAcceleratedCompositingMode = false;
// If we haven't sent the EnterAcceleratedCompositingMode message, make sure that the
// layer tree host calls us back after the next layer flush so we can send it then.
if (!m_compositingAccordingToProxyMessages)
m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(true);
m_layerTreeHost->setRootCompositingLayer(graphicsLayer);
}
} else {
if (m_layerTreeHost)
m_layerTreeHost->setRootCompositingLayer(0);
}
}
void CoordinatedDrawingArea::scheduleCompositingLayerFlush()
{
if (!m_layerTreeHost)
return;
m_layerTreeHost->scheduleLayerFlush();
}
void CoordinatedDrawingArea::updateBackingStoreState(uint64_t stateID, bool respondImmediately, float deviceScaleFactor, const WebCore::IntSize& size, const WebCore::IntSize& scrollOffset)
{
ASSERT(!m_inUpdateBackingStoreState);
m_inUpdateBackingStoreState = true;
ASSERT_ARG(stateID, stateID >= m_backingStoreStateID);
if (stateID != m_backingStoreStateID) {
m_backingStoreStateID = stateID;
m_shouldSendDidUpdateBackingStoreState = true;
m_webPage->setDeviceScaleFactor(deviceScaleFactor);
m_webPage->setSize(size);
m_webPage->layoutIfNeeded();
m_webPage->scrollMainFrameIfNotAtMaxScrollPosition(scrollOffset);
if (m_layerTreeHost) {
// Coordinated Graphics sets the size of the root layer to contents size.
if (!m_webPage->useFixedLayout())
m_layerTreeHost->sizeDidChange(m_webPage->size());
} else
m_dirtyRegion = m_webPage->bounds();
} else {
ASSERT(size == m_webPage->size());
if (!m_shouldSendDidUpdateBackingStoreState) {
// We've already sent a DidUpdateBackingStoreState message for this state. We have nothing more to do.
m_inUpdateBackingStoreState = false;
return;
}
}
// The UI process has updated to a new backing store state. Any Update messages we sent before
// this point will be ignored. We wait to set this to false until after updating the page's
// size so that any displays triggered by the relayout will be ignored. If we're supposed to
// respond to the UpdateBackingStoreState message immediately, we'll do a display anyway in
// sendDidUpdateBackingStoreState; otherwise we shouldn't do one right now.
m_isWaitingForDidUpdate = false;
if (respondImmediately) {
// Make sure to resume painting if we're supposed to respond immediately, otherwise we'll just
// send back an empty UpdateInfo struct.
if (m_isPaintingSuspended)
resumePainting();
sendDidUpdateBackingStoreState();
}
m_inUpdateBackingStoreState = false;
}
void CoordinatedDrawingArea::sendDidUpdateBackingStoreState()
{
ASSERT(!m_isWaitingForDidUpdate);
ASSERT(m_shouldSendDidUpdateBackingStoreState);
m_shouldSendDidUpdateBackingStoreState = false;
UpdateInfo updateInfo;
if (!m_isPaintingSuspended && !m_layerTreeHost)
display(updateInfo);
LayerTreeContext layerTreeContext;
if (m_isPaintingSuspended || m_layerTreeHost) {
updateInfo.viewSize = m_webPage->size();
updateInfo.deviceScaleFactor = m_webPage->corePage()->deviceScaleFactor();
if (m_layerTreeHost) {
layerTreeContext = m_layerTreeHost->layerTreeContext();
// We don't want the layer tree host to notify after the next scheduled
// layer flush because that might end up sending an EnterAcceleratedCompositingMode
// message back to the UI process, but the updated layer tree context
// will be sent back in the DidUpdateBackingStoreState message.
m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(false);
m_layerTreeHost->forceRepaint();
}
}
m_webPage->send(Messages::DrawingAreaProxy::DidUpdateBackingStoreState(m_backingStoreStateID, updateInfo, layerTreeContext));
m_compositingAccordingToProxyMessages = !layerTreeContext.isEmpty();
}
void CoordinatedDrawingArea::didUpdate()
{
// We might get didUpdate messages from the UI process even after we've
// entered accelerated compositing mode. Ignore them.
if (m_layerTreeHost)
return;
m_isWaitingForDidUpdate = false;
// Display if needed. We call displayTimerFired here since it will throttle updates to 60fps.
displayTimerFired();
}
void CoordinatedDrawingArea::suspendPainting()
{
ASSERT(!m_isPaintingSuspended);
if (m_layerTreeHost)
m_layerTreeHost->pauseRendering();
m_isPaintingSuspended = true;
m_displayTimer.stop();
m_webPage->corePage()->suspendScriptedAnimations();
}
void CoordinatedDrawingArea::resumePainting()
{
if (!m_isPaintingSuspended) {
// FIXME: We can get a call to resumePainting when painting is not suspended.
// This happens when sending a synchronous message to create a new page. See <rdar://problem/8976531>.
return;
}
if (m_layerTreeHost)
m_layerTreeHost->resumeRendering();
m_isPaintingSuspended = false;
// FIXME: We shouldn't always repaint everything here.
setNeedsDisplay();
m_webPage->corePage()->resumeScriptedAnimations();
}
void CoordinatedDrawingArea::enterAcceleratedCompositingMode(GraphicsLayer* graphicsLayer)
{
m_exitCompositingTimer.stop();
m_wantsToExitAcceleratedCompositingMode = false;
ASSERT(!m_layerTreeHost);
m_layerTreeHost = LayerTreeHost::create(m_webPage);
if (!m_inUpdateBackingStoreState)
m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(true);
m_layerTreeHost->setRootCompositingLayer(graphicsLayer);
// Non-composited content will now be handled exclusively by the layer tree host.
m_dirtyRegion = Region();
m_scrollRect = IntRect();
m_scrollOffset = IntSize();
m_displayTimer.stop();
m_isWaitingForDidUpdate = false;
}
void CoordinatedDrawingArea::exitAcceleratedCompositingModeSoon()
{
if (m_layerTreeStateIsFrozen) {
m_wantsToExitAcceleratedCompositingMode = true;
return;
}
if (exitAcceleratedCompositingModePending())
return;
m_exitCompositingTimer.startOneShot(0);
}
void CoordinatedDrawingArea::scheduleDisplay()
{
ASSERT(!m_layerTreeHost);
if (m_isWaitingForDidUpdate)
return;
if (m_isPaintingSuspended)
return;
if (m_dirtyRegion.isEmpty())
return;
if (m_displayTimer.isActive())
return;
m_displayTimer.startOneShot(0);
}
void CoordinatedDrawingArea::displayTimerFired()
{
display();
}
void CoordinatedDrawingArea::display()
{
ASSERT(!m_layerTreeHost);
ASSERT(!m_isWaitingForDidUpdate);
ASSERT(!m_inUpdateBackingStoreState);
if (m_isPaintingSuspended)
return;
if (m_dirtyRegion.isEmpty())
return;
if (m_shouldSendDidUpdateBackingStoreState) {
sendDidUpdateBackingStoreState();
return;
}
UpdateInfo updateInfo;
display(updateInfo);
if (m_layerTreeHost) {
// The call to update caused layout which turned on accelerated compositing.
// Don't send an Update message in this case.
return;
}
m_webPage->send(Messages::DrawingAreaProxy::Update(m_backingStoreStateID, updateInfo));
m_isWaitingForDidUpdate = true;
}
static bool shouldPaintBoundsRect(const IntRect& bounds, const Vector<IntRect>& rects)
{
const size_t rectThreshold = 10;
const double wastedSpaceThreshold = 0.75;
if (rects.size() <= 1 || rects.size() > rectThreshold)
return true;
// Attempt to guess whether or not we should use the region bounds rect or the individual rects.
// We do this by computing the percentage of "wasted space" in the bounds. If that wasted space
// is too large, then we will do individual rect painting instead.
unsigned boundsArea = bounds.width() * bounds.height();
unsigned rectsArea = 0;
for (size_t i = 0; i < rects.size(); ++i)
rectsArea += rects[i].width() * rects[i].height();
double wastedSpace = 1 - (static_cast<double>(rectsArea) / boundsArea);
return wastedSpace <= wastedSpaceThreshold;
}
void CoordinatedDrawingArea::display(UpdateInfo& updateInfo)
{
ASSERT(!m_isPaintingSuspended);
ASSERT(!m_layerTreeHost);
ASSERT(!m_webPage->size().isEmpty());
m_webPage->layoutIfNeeded();
// The layout may have put the page into accelerated compositing mode. If the LayerTreeHost is
// in charge of displaying, we have nothing more to do.
if (m_layerTreeHost)
return;
updateInfo.viewSize = m_webPage->size();
updateInfo.deviceScaleFactor = m_webPage->corePage()->deviceScaleFactor();
IntRect bounds = m_dirtyRegion.bounds();
ASSERT(m_webPage->bounds().contains(bounds));
IntSize bitmapSize = bounds.size();
float deviceScaleFactor = m_webPage->corePage()->deviceScaleFactor();
bitmapSize.scale(deviceScaleFactor);
RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(bitmapSize, ShareableBitmap::SupportsAlpha);
if (!bitmap)
return;
if (!bitmap->createHandle(updateInfo.bitmapHandle))
return;
Vector<IntRect> rects = m_dirtyRegion.rects();
if (shouldPaintBoundsRect(bounds, rects)) {
rects.clear();
rects.append(bounds);
}
updateInfo.scrollRect = m_scrollRect;
updateInfo.scrollOffset = m_scrollOffset;
m_dirtyRegion = Region();
m_scrollRect = IntRect();
m_scrollOffset = IntSize();
auto graphicsContext = bitmap->createGraphicsContext();
graphicsContext->applyDeviceScaleFactor(deviceScaleFactor);
updateInfo.updateRectBounds = bounds;
graphicsContext->translate(-bounds.x(), -bounds.y());
for (size_t i = 0; i < rects.size(); ++i) {
m_webPage->drawRect(*graphicsContext, rects[i]);
if (m_webPage->hasPageOverlay()) {
PageOverlayList& pageOverlays = m_webPage->pageOverlays();
PageOverlayList::iterator end = pageOverlays.end();
for (PageOverlayList::iterator it = pageOverlays.begin(); it != end; ++it)
m_webPage->drawPageOverlay(it->get(), *graphicsContext, rects[i]);
}
updateInfo.updateRects.append(rects[i]);
}
// Layout can trigger more calls to setNeedsDisplay and we don't want to process them
// until the UI process has painted the update, so we stop the timer here.
m_displayTimer.stop();
}
void CoordinatedDrawingArea::didReceiveCoordinatedLayerTreeHostMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder)
{
if (m_layerTreeHost)
m_layerTreeHost->didReceiveCoordinatedLayerTreeHostMessage(connection, decoder);
}
} // namespace WebKit
#endif // USE(COORDINATED_GRAPHICS)
|
[
"adzhou@hp.com"
] |
adzhou@hp.com
|
9bccc0f5b43ab2b27e241dbd2c83c29184f4845c
|
3f5fcc4ca381dc9fd18d63dd16cabc370773afbd
|
/src/2015/advent7/Gates.h
|
de3b89fe54881694b55c8fe6b0f279a977b1d2e6
|
[] |
no_license
|
rramdin/adventofcode
|
1cff255d0b8c6b147e9ef34f333156c42dd47556
|
11a673efab1c61da717562c20d617538038aaf67
|
refs/heads/master
| 2021-01-21T13:25:22.429125
| 2020-09-28T01:48:23
| 2020-09-28T01:48:23
| 47,476,085
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,823
|
h
|
#ifndef __GATES_H
#define __GATES_H
#include <string>
#include <map>
#include <inttypes.h>
class Gate;
class Gates
{
public:
void process(const std::string &s);
uint16_t getValue(const std::string &name) const;
void clear();
void setValue(const std::string &name, uint16_t value);
private:
std::map<std::string, Gate*> gates_;
mutable std::map<std::string, uint16_t> cache_;
};
class Gate
{
public:
virtual uint16_t getValue(const Gates*) const = 0;
};
class ReferenceGate :public Gate
{
public:
ReferenceGate(const std::string &name): name_(name) {}
virtual uint16_t getValue(const Gates*) const override;
private:
const std::string name_;
};
class AndGate :public Gate
{
public:
AndGate(const std::string &g1, const std::string &g2)
: g1_(g1), g2_(g2) {}
virtual uint16_t getValue(const Gates*) const override;
private:
const std::string g1_, g2_;
};
class OrGate :public Gate
{
public:
OrGate(const std::string &g1, const std::string &g2)
: g1_(g1), g2_(g2) {}
virtual uint16_t getValue(const Gates*) const override;
private:
const std::string g1_, g2_;
};
class LShiftGate :public Gate
{
public:
LShiftGate(const std::string &g, const size_t shift)
: g_(g), shift_(shift) {}
virtual uint16_t getValue(const Gates*) const override;
private:
const std::string g_;
const size_t shift_;
};
class RShiftGate :public Gate
{
public:
RShiftGate(const std::string &g, const size_t shift)
: g_(g), shift_(shift) {}
virtual uint16_t getValue(const Gates*) const override;
private:
const std::string g_;
const size_t shift_;
};
class NotGate :public Gate
{
public:
NotGate(const std::string &g)
: g_(g) {}
virtual uint16_t getValue(const Gates*) const override;
private:
const std::string g_;
};
#endif
|
[
"rramdin@suntradingllc.com"
] |
rramdin@suntradingllc.com
|
c2e271ded225bf81ca396ce3250f1a9beb8f2a69
|
d6ee80e8e555bcad339f636ca1164f745b3fddf1
|
/src/ResourceScheduler/match_maker.h
|
a30fcb66e5d5d7e6c4f8dd4fac049526d1af2c3c
|
[] |
no_license
|
pointnity/ifisher
|
434a03989da894948af44dc0dc0d93e9065c52f5
|
66e00a0d209b98a0e3d493035187079fb5ab6338
|
refs/heads/master
| 2020-04-14T07:48:04.738586
| 2014-06-04T12:33:38
| 2014-06-04T12:33:38
| 163,722,303
| 0
| 0
| null | 2019-01-01T08:03:39
| 2019-01-01T08:03:39
| null |
UTF-8
|
C++
| false
| false
| 749
|
h
|
/********************************
FileName: ResourceScheduler/match_maker
Author: ZhangZhang & Tangxuehai
Date: 2014-05-11
Version: 0.1
Description: match machine with job
*********************************/
#ifndef SRC_RESOURCE_SCHEDULER_MATCH_MAKER_H
#define SRC_RESOURCE_SCHEDULER_MATCH_MAKER_H
#include <vector>
#include <string>
#include "common/clynn/singleton.h"
using std::vector;
using std::string;
class MatchMaker {
public:
int Negotiation(const string& job, vector<string>& machines);
int NegotiationTask(const string& task, string& machine);
int NegotiationTaskConstraint(const string& task_ad, const vector<string>& soft_list, string& machine);
private:
};
typedef Singleton<MatchMaker> MATCH_MAKER;
#endif
|
[
"yes@yes-K40AB.(none)"
] |
yes@yes-K40AB.(none)
|
a7a55ce248480976797c4a08c31c13e3e1fdf18f
|
23ace58d05876953cb78ff44f963b8e79070889c
|
/HDU/杭电3336.cpp
|
e6acc4c34248ec1ae62f4ea5b7ba07f31ee35aef
|
[] |
no_license
|
InTheBloodHorse/ACM
|
ae9d2fccb33efee2d54b530eba0b0640aff5ae43
|
7a1a5c7d3b5e1ede7c62b484f91e89bcf012bd5d
|
refs/heads/master
| 2020-03-28T09:01:59.552044
| 2019-04-30T13:37:58
| 2019-04-30T13:37:58
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 624
|
cpp
|
#include<bits/stdc++.h>
using namespace std;
int nextval[200005];
char s[200005];
int dp[200005];
void gen_next(){
int ll = strlen(s);
nextval[0]=0;
nextval[1]=0;
int k=0;
for(int i=1;i<ll;i++){
while(k>0 && s[k]!=s[i]) k = nextval[k];
if(s[k]==s[i]) k++;
nextval[i+1]=k;
}
nextval[0]=-1;
}
int main()
{
int t;
scanf("%d",&t);
while(t--){
int ll ;
scanf("%d",&ll);
memset(nextval,0,sizeof(nextval));
memset(dp,0,sizeof(dp));
scanf("%s",s);
gen_next();
int sum=0;
for(int i=1;i<=ll;i++){
dp[i]=dp[nextval[i]] + 1;
sum = (sum + dp[i]+10007) %10007;
}
printf("%d\n",sum);
}
}
|
[
"2495088064@qq.com"
] |
2495088064@qq.com
|
5a037576b726fb9b4d3f544c69f85a9b4f74bebd
|
1eba317aec7378987541fcceaf48e3a9abb17f10
|
/ch03/mount.cpp
|
2097cb3ad49771a7ee78bfb565736fbb6f389dea
|
[] |
no_license
|
lalalaring/learning-cpp-ue4
|
11bf9a4384faa16af4c5a529261e8225b3297e04
|
b56cdcb5d75d85e9d313390a84ab481e42f2a226
|
refs/heads/master
| 2021-01-15T08:47:28.510695
| 2015-07-01T11:52:16
| 2015-07-01T11:52:16
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,081
|
cpp
|
#include <iostream>
using namespace std;
enum Mount
{
Horse=1, Mare, Mule, Sheep, Chocobo
};
int main()
{
int mount;
cout << "Choose your mount:" << endl;
cout << Horse << " Horse" << endl;
cout << Mare << " Mare" << endl;
cout << Mule << " Mule" << endl;
cout << Sheep << " Sheep" << endl;
cout << Chocobo << " Chocobo" << endl;
cout << "Enter a number from 1 to 5 to choose a mount" << endl;
cin >> mount;
switch( mount )
{
case Horse:
cout << "I'm on a horse!" << endl;
break;
case Mare:
cout << "Bad horse made you his mare!" << endl;
break;
case Mule:
cout << "Into Commodore 64 games, eh?" << endl;
break;
case Sheep:
cout << "Stay with me, safe and ignorant." << endl;
break;
case Chocobo:
cout << "Time to get a Knights of the Round summon!" << endl;
break;
default:
cout << "Invalid mount" << endl;
break;
}
return 0;
}
|
[
"sam@bitpay.com"
] |
sam@bitpay.com
|
27861611b5db231ad7041f0d9c39125649b752cc
|
40f87941b3620692ac7c4f7254ef8d1b30e88cc1
|
/BasicWindowsCpp/BEEntitySystems.cpp
|
3e689e5f4103225cb54d3906a81336dcb15efe42
|
[] |
no_license
|
Dalelit/BasicEngine
|
c3f17a29b14fd3fb911f3fe7d5b9429412d120f7
|
0d59145bb769ca8e1fc968680a29548e4f10fe39
|
refs/heads/master
| 2020-09-02T06:02:32.870630
| 2020-03-15T12:09:00
| 2020-03-15T12:09:00
| 219,148,886
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,778
|
cpp
|
#include "pch.h"
#include "BEEntitySystems.h"
using namespace DirectX;
// to do: work out if this or XMVectorGetY XMVectorSetY is better?
#define GETY(v) v.m128_f32[1]
#define SETY(v,y) v.m128_f32[1] = y
void BEEntitySystem::SetPositionInGrid(BEModel* pModel, float spacing, unsigned int widthCount, unsigned int depthCount)
{
unsigned int entityCount = pModel->GetEntityCout();
BEEntity* pEntity = pModel->GetEntityData();
assert(widthCount * depthCount == entityCount);
float z = -((float)depthCount - 1.0f) * spacing / 2.0f;
float xstart = -((float)widthCount - 1.0f) * spacing / 2.0f;
for (unsigned int d = 0; d < depthCount; d++)
{
float x = xstart;
for (unsigned int w = 0; w < widthCount; w++)
{
pEntity->SetPosition(x, 0.0f, z);
x += spacing;
pEntity++;
}
z += spacing;
}
}
void BEPhysicsSystem::BasicUpdate(BEModel* pModel, float deltaTime)
{
unsigned int entityCount = pModel->GetEntityCout();
BEEntity* pEntity = pModel->GetEntityData();
BEComponentPhysics* pPhysics = pModel->GetPhysicsData();
for (unsigned int i = 0; i < entityCount; i++)
{
pEntity->position += pPhysics->velocity * deltaTime;
pPhysics->velocity += pPhysics->acceleration * deltaTime;
pEntity->rotation += pPhysics->angularVelocity * deltaTime;
pEntity++;
pPhysics++;
}
}
void BEPhysicsSystem::BounceUpdate(BEModel* pModel, float deltaTime)
{
unsigned int entityCount = pModel->GetEntityCout();
BEEntity* pEntity = pModel->GetEntityData();
BEComponentPhysics* pPhysics = pModel->GetPhysicsData();
for (unsigned int i = 0; i < entityCount; i++)
{
if ( (GETY(pEntity->position) > 0.0f && GETY(pPhysics->acceleration) > 0.0f) ||
(GETY(pEntity->position) < 0.0f && GETY(pPhysics->acceleration) < 0.0f) )
SETY(pPhysics->acceleration, -GETY(pPhysics->acceleration)); // swap acceleration direciton
pEntity++;
pPhysics++;
}
}
void BEPhysicsSystem::BounceSetup(BEModel* pModel, float maxSpeed)
{
unsigned int entityCount = pModel->GetEntityCout();
BEComponentPhysics* pPhysics = pModel->GetPhysicsData();
for (unsigned int i = 0; i < entityCount; i++)
{
float dir = maxSpeed * (i % 2 == 1 ? 1.0f : -1.0f);
SETY(pPhysics->velocity, dir);
SETY(pPhysics->acceleration, -dir);
pPhysics++;
}
}
void BEPhysicsSystem::RandomRotationSetup(BEModel* pModel, float maxSpeed)
{
unsigned int entityCount = pModel->GetEntityCout();
BEComponentPhysics* pPhysics = pModel->GetPhysicsData();
std::random_device rd;
std::mt19937_64 gen(rd());
std::uniform_real_distribution<float> dist(-maxSpeed * XM_PI, maxSpeed * XM_PI);
for (unsigned int i = 0; i < entityCount; i++)
{
float x = dist(gen);
float y = dist(gen);
float z = dist(gen);
pPhysics->angularVelocity = XMVECTOR({ x, y, z, 1.0f });
pPhysics++;
}
}
|
[
"dale.coding@gmail.com"
] |
dale.coding@gmail.com
|
31b91bc272da315f716b09757d500564f643ad29
|
fcd1f7e0e777730168a9ec34ff15f5900814225c
|
/src/lab6/tcp.hh
|
5ed113d07af8842a9edc2a706c3d4768ba86b70d
|
[] |
no_license
|
Hagfjall/EITN30-internet-inside
|
b44fcb3438ef0d2d3a2040c17351e7a6e0b9e88e
|
5b6c93594b213edcda734e043e74877e56a11931
|
refs/heads/master
| 2021-01-17T08:36:57.917326
| 2016-07-31T06:16:25
| 2016-07-31T06:16:25
| 64,579,523
| 0
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 13,988
|
hh
|
/*!***************************************************************************
*!
*! FILE NAME : tcp.hh
*!
*! DESCRIPTION: TCP, Transport control protocol
*!
*!***************************************************************************/
#ifndef tcp_hh
#define tcp_hh
/****************** INCLUDE FILES SECTION ***********************************/
#include "inpacket.hh"
#include "ipaddr.hh"
#include "queue.hh"
#include "tcpsocket.hh"
#include "timer.hh"
/****************** CLASS DEFINITION SECTION ********************************/
/*****************************************************************************
*%
*% CLASS NAME : TCP
*%
*% BASE CLASSES : None
*%
*% CLASS TYPE : Singleton
*%
*% DESCRIPTION : Holds the TCP connections.
*%
*% SUBCLASSING : None.
*%
*%***************************************************************************/
class TCPConnection;
class TCP {
public:
static TCP &instance();
TCPConnection *getConnection(IPAddress &theSourceAddress,
uword theSourcePort,
uword theDestinationPort);
// Find a connection in the connection list
TCPConnection *createConnection(IPAddress &theSourceAddress,
uword theSourcePort,
uword theDestinationPort,
InPacket *theCreator);
// Create a new connection and insert it in the connection list
void deleteConnection(TCPConnection *);
// Removes a connection from the list and deletes it
bool acceptConnection(uword portNo);
// Is true when a connection is accepted on port portNo.
void connectionEstablished(TCPConnection *theConnection);
// Create a new TCPSocket. Register it in TCPConnection.
// Create and start a SimpleApplication.
enum {
tcpHeaderLength = 20
};
PQueue<TCPConnection *> myConnectionList;
private:
TCP();
// All the TCP connections
};
/*****************************************************************************
*%
*% CLASS NAME : retransmitTimer
*%
****************************/
class retransmitTimer : public Timed {
public:
retransmitTimer(TCPConnection *theConnection,
Duration retransmitTime);
~retransmitTimer();
void start();
// this->timeOutAfter(myRetransmitTime);
void cancel();
// this->resetTimeOut();
private:
void timeOut();
// ...->sendNext = ...->sentUnAcked; ..->sendFromQueue();
TCPConnection *myConnection;
Duration myRetransmitTime;
// one second
};
class connectionTimeoutTimer : public Timed {
public:
connectionTimeoutTimer(TCPConnection *theConnection, Duration timeoutTime);
~connectionTimeoutTimer();
void start();
void cancel();
private:
void timeOut();
TCPConnection *myConnection;
Duration myTimeoutTime;
};
/*****************************************************************************
*%
*% CLASS NAME : TCPConnection
*%
*% BASE CLASSES : None
*%
*% CLASS TYPE :
*%
*% DESCRIPTION : Holds the state of one TCP connection.
*%
*% SUBCLASSING : None.
*%
*%***************************************************************************/
class TCPState;
class TCPSender;
class TCPConnection {
public:
TCPConnection(IPAddress &theSourceAddress,
uword theSourcePort,
uword theDestinationPort,
InPacket *theCreator);
~TCPConnection();
bool tryConnection(IPAddress &theSourceAddress,
uword theSourcePort,
uword theDestinationPort);
// Returns true if this connection matches the arguments
void Synchronize(udword theSynchronizationNumber);
// Handle an incoming SYN segment
void NetClose();
// Handle an incoming FIN segment
void AppClose();
// Handle close from application
void Kill();
// Handle an incoming RST segment, can also called in other error conditions
void Receive(udword theSynchronizationNumber,
byte *theData,
udword theLength);
// Handle incoming data
void Acknowledge(udword theAcknowledgementNumber);
// Handle incoming Acknowledgement
void Send(byte *theData,
udword theLength);
// Send outgoing data
uword serverPortNumber();
// Return myPort.
void registerSocket(TCPSocket *theSocket);
// Set mySocket to theSocket.
//-------------------------------------------------------------------------
//
// Interface to TCPState
//
IPAddress hisAddress;
// Other hosts IP address
uword hisPort;
// Other hosts port
uword myPort;
// My port
udword receiveNext;
// next expected sequence number from other host
uword receiveWindow;
// Number of bytes it is posible to send without getting an ACK
udword sendNext;
// next sequence number to send
udword sentUnAcked;
// Data has been acknowledged up to this sequence number. What remains up to
// sendNext is sent but not yet acked by the other host.
byte *transmitQueue; //, a reference to the data to be sent,
udword queueLength; // the number of data to be sent, and
udword firstSeq; // the sequence number of the first byte in the queue.
udword theOffset;
// the first position in the queue relative the variable transmitQueue to send from ,
byte *theFirst;
// the first byte to send in the segment relative the variable transmitQueue,
udword theSendLength;
// the number of byte to send in a single segment.
udword sentMaxSeq;
udword myWindowSize; // contains the offered window size from each segment.
TCPSender *myTCPSender;
TCPState *myState;
TCPSocket *mySocket;
retransmitTimer *timer;
connectionTimeoutTimer *timeOutTimer;
bool RSTflag;
};
/*****************************************************************************
*%
*% CLASS NAME : TCPState
*%
*% BASE CLASSES : None
*%
*% CLASS TYPE : Pure virtual
*%
*% DESCRIPTION : Handle a state of one TCP connection.
*%
*% SUBCLASSING : yes.
*%
*%***************************************************************************/
class TCPState {
public:
virtual void Synchronize(TCPConnection *theConnection,
udword theSynchronizationNumber);
// Handle an incoming SYN segment
virtual void NetClose(TCPConnection *theConnection);
// Handle an incoming FIN segment
virtual void AppClose(TCPConnection *theConnection);
// Handle close from application
virtual void Kill(TCPConnection *theConnection);
// Handle an incoming RST segment, can also called in other error conditions
virtual void Receive(TCPConnection *theConnection,
udword theSynchronizationNumber,
byte *theData,
udword theLength);
// Handle incoming data
virtual void Acknowledge(TCPConnection *theConnection,
udword theAcknowledgementNumber);
// Handle incoming Acknowledgement
virtual void Send(TCPConnection *theConnection,
byte *theData,
udword theLength);
// Send outgoing data
};
/*****************************************************************************
*%
*% CLASS NAME : ListenState
*%
*% BASE CLASSES : None
*%
*% CLASS TYPE :
*%
*% DESCRIPTION : Handle listen state.
*%
*% SUBCLASSING : no.
*%
*%***************************************************************************/
class ListenState : public TCPState {
public:
static ListenState *instance();
void Synchronize(TCPConnection *theConnection,
udword theSynchronizationNumber);
// Handle an incoming SYN segment
protected:
ListenState() { }
};
/*****************************************************************************
*%
*% CLASS NAME : SynRecvdState
*%
*% BASE CLASSES : None
*%
*% CLASS TYPE :
*%
*% DESCRIPTION : Handle SYN received state.
*%
*% SUBCLASSING : no.
*%
*%***************************************************************************/
class SynRecvdState : public TCPState {
public:
static SynRecvdState *instance();
void Acknowledge(TCPConnection *theConnection,
udword theAcknowledgementNumber);
// Handle incoming Acknowledgement
protected:
SynRecvdState() { }
};
/*****************************************************************************
*%
*% CLASS NAME : EstablishedState
*%
*% BASE CLASSES : None
*%
*% CLASS TYPE :
*%
*% DESCRIPTION : Handle established state.
*%
*% SUBCLASSING : no.
*%
*%***************************************************************************/
class EstablishedState : public TCPState {
public:
static EstablishedState *instance();
void NetClose(TCPConnection *theConnection);
// Handle an incoming FIN segment
void Receive(TCPConnection *theConnection,
udword theSynchronizationNumber,
byte *theData,
udword theLength);
// Handle incoming data
void Acknowledge(TCPConnection *theConnection,
udword theAcknowledgementNumber);
// Handle incoming Acknowledgement
void Send(TCPConnection *theConnection,
byte *theData,
udword theLength);
// Send outgoing data
void AppClose(TCPConnection *theConnection);
protected:
EstablishedState() { }
};
/*****************************************************************************
*%
*% CLASS NAME : CloseWaitState
*%
*% BASE CLASSES : None
*%
*% CLASS TYPE :
*%
*% DESCRIPTION : Handle established state.
*%
*% SUBCLASSING : no.
*%
*%***************************************************************************/
class CloseWaitState : public TCPState {
public:
static CloseWaitState *instance();
void AppClose(TCPConnection *theConnection);
// Handle close from application
protected:
CloseWaitState() { }
};
/*****************************************************************************
*%
*% CLASS NAME : LastAckState
*%
*% BASE CLASSES : None
*%
*% CLASS TYPE :
*%
*% DESCRIPTION : Handle established state.
*%
*% SUBCLASSING : no.
*%
*%***************************************************************************/
class LastAckState : public TCPState {
public:
static LastAckState *instance();
void Acknowledge(TCPConnection *theConnection,
udword theAcknowledgementNumber);
// Handle incoming Acknowledgement
protected:
LastAckState() { }
};
class FinWait1State : public TCPState {
public:
static FinWait1State *instance();
void Acknowledge(TCPConnection *theConnection,
udword theAcknowledgementNumber);
// Handle incoming Acknowledgement
protected:
FinWait1State() { }
};
class FinWait2State : public TCPState {
public:
static FinWait2State *instance();
void NetClose(TCPConnection *theConnection);
// Handle incoming Acknowledgement
protected:
FinWait2State() { }
};
/*****************************************************************************
*%
*% CLASS NAME : TCPSender
*%
*% BASE CLASSES :
*%
*% CLASS TYPE :
*%
*% DESCRIPTION : Send a TCP segment.
*%
*% SUBCLASSING : None.
*%
*%***************************************************************************/
class TCPSender {
public:
TCPSender(TCPConnection *theConnection,
InPacket *theCreator);
~TCPSender();
void sendFlags(byte theFlags);
// Send a flag segment without data.
void sendData(byte *theData,
udword theLength);
// Send a data segment. PSH and ACK flags are set.
void sendFromQueue();
private:
TCPConnection *myConnection;
InPacket *myAnswerChain;
};
/*****************************************************************************
*%
*% CLASS NAME : TCPInPacket
*%
*% BASE CLASSES : InPacket
*%
*% CLASS TYPE :
*%
*% DESCRIPTION : Decode a TCP packet.
*%
*% SUBCLASSING : None.
*%
*%***************************************************************************/
class TCPInPacket : public InPacket {
public:
TCPInPacket(byte *theData,
udword theLength,
InPacket *theFrame,
IPAddress &theSourceAddress);
void decode();
void answer(byte *theData, udword theLength);
uword headerOffset();
InPacket *copyAnswerChain();
private:
IPAddress mySourceAddress;
uword mySourcePort;
uword myDestinationPort;
udword mySequenceNumber;
udword myAcknowledgementNumber;
};
/*****************************************************************************
*%
*% CLASS NAME : TCPHeader
*%
*% BASE CLASSES : none
*%
*% CLASS TYPE :
*%
*% DESCRIPTION : Describes the fields of a TCP packet.
*%
*% SUBCLASSING : None.
*%
*%***************************************************************************/
class TCPHeader {
public:
TCPHeader() { }
uword sourcePort;
uword destinationPort;
udword sequenceNumber;
udword acknowledgementNumber;
byte headerLength;
// 6 reserved bits omitted.
byte flags;
uword windowSize;
uword checksum;
uword urgentPointer;
};
/*****************************************************************************
*%
*% CLASS NAME : TCPPseudoHeader
*%
*% BASE CLASSES : none
*%
*% CLASS TYPE :
*%
*% DESCRIPTION : The TCP pseudo header used for checksum calculation.
*%
*% SUBCLASSING : None.
*%
*%***************************************************************************/
class TCPPseudoHeader {
public:
TCPPseudoHeader(IPAddress &theDestination, uword theLength);
uword checksum();
protected:
IPAddress sourceIPAddress;
IPAddress destinationIPAddress;
byte zero;
byte protocol;
uword tcpLength;
};
#endif
/****************** END OF FILE tcp.hh *************************************/
|
[
"fredrik@hagfjall.se"
] |
fredrik@hagfjall.se
|
aefe449e95936ee1bb7b562900f1b42ba2e4948f
|
dd9b32ddd4cd08de785f85404a21f6857c0095df
|
/fmts.hpp
|
f96d348867cf4a5dd9c23e238e5a19cc9f3c4635
|
[] |
no_license
|
Tao-kun/Expresser
|
ba6c599d16f3540ddc25ae6a5f0adf01ae8fa3dd
|
b4637bb99a6ffe23bfa433c5092873faac6a9cf9
|
refs/heads/master
| 2020-09-16T07:52:05.647617
| 2019-12-26T13:14:05
| 2019-12-26T13:14:05
| 223,703,385
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 19,213
|
hpp
|
#ifndef EXPRESSER_FMP_HPP
#define EXPRESSER_FMP_HPP
#include <string>
#include "fmt/core.h"
#include "Types.h"
#include "Error/Error.h"
#include "Lexer/Token.h"
#include "Instruction/Instruction.h"
namespace fmt {
template<>
struct formatter<expresser::ExpresserError> {
template<typename ParseContext>
constexpr auto parse(ParseContext &ctx) { return ctx.begin(); }
template<typename FormatContext>
auto format(const expresser::ExpresserError &p, FormatContext &ctx) {
return format_to(ctx.out(), "Line: {} Column: {} Error: {}",
p.GetPos().first, p.GetPos().second, p.GetCode());
}
};
template<>
struct formatter<expresser::ErrorCode> {
template<typename ParseContext>
constexpr auto parse(ParseContext &ctx) { return ctx.begin(); }
template<typename FormatContext>
auto format(const expresser::ErrorCode &p, FormatContext &ctx) {
std::string name;
switch (p) {
case expresser::ErrAssignToConstant:
name = "AssignToConstant";
break;
case expresser::ErrCallFunctionInStartSection:
name = "Not support call a function in start section";
break;
case expresser::ErrCastToVoid:
name = "CastToVoid";
break;
case expresser::ErrConstantNeedValue:
name = "ConstantNeedValue";
break;
case expresser::ErrDoubleOverflow:
name = "DoubleOverflow";
break;
case expresser::ErrDuplicateDeclaration:
name = "DuplicateDeclaration";
break;
case expresser::ErrEOF:
name = "EOF";
break;
case expresser::ErrIncompleteExpression:
name = "IncompleteExpression";
break;
case expresser::ErrIncompleteFunction:
name = "Incomplete Function";
break;
case expresser::ErrInvalidAssignment:
name = "Invalid Assignment: only need semicolon, assign symbol, comma";
break;
case expresser::ErrInvalidCast:
name = "InvalidCast: unknown cast type";
break;
case expresser::ErrInvalidCharacter:
name = "InvalidCharacter";
break;
case expresser::ErrInvalidDouble:
name = "InvalidDouble";
break;
case expresser::ErrInvalidExpression:
name = "InvalidExpression: input not match:\n"
"<primary-expression> ::=\n"
" '('<expression>')'\n"
" |<identifier>\n"
" |<integer-literal>\n"
" |<function-call>\n"
" |<char-literal>";
break;
case expresser::ErrInvalidFunctionCall:
name = "InvalidFunctionCall: EOF before a <function-call> ends\n"
"<function-call> ::=\n"
" <identifier> '(' [<expression-list>] ')'\n"
"<expression-list> ::=\n"
" <expression>{','<expression>}";
break;
case expresser::ErrInvalidFunctionReturnType:
name = "InvalidFunctionReturnType";
break;
case expresser::ErrInvalidIdentifier:
name = "InvalidIdentifier: not match <identifier> ::= <nondigit>{<nondigit>|<digit>}";
break;
case expresser::ErrInvalidInput:
name = "InvalidInput";
break;
case expresser::ErrInvalidInteger:
name = "InvalidInteger";
break;
case expresser::ErrInvalidJump:
name = "InvalidJump";
break;
case expresser::ErrInvalidLoop:
name = "InvalidLoop";
break;
case expresser::ErrInvalidNotEqual:
name = "InvalidNotEqual";
break;
case expresser::ErrInvalidParameter:
name = "InvalidParameter";
break;
case expresser::ErrInvalidPrint:
name = "InvalidPrint";
break;
case expresser::ErrInvalidScan:
name = "InvalidScan";
break;
case expresser::ErrInvalidStatement:
name = "InvalidStatement";
break;
case expresser::ErrInvalidStringLiteral:
name = "InvalidStringLiteral";
break;
case expresser::ErrInvalidVariableDeclaration:
name = "InvalidVariableDeclaration";
break;
case expresser::ErrInvalidVariableType:
name = "InvalidVariableType";
break;
case expresser::ErrIntegerOverflow:
name = "IntegerOverflow";
break;
case expresser::ErrMissingBrace:
name = "MissingBrace";
break;
case expresser::ErrMissingBracket:
name = "MissingBracket";
break;
case expresser::ErrMissingRightQuote:
name = "MissingRightQuote";
break;
case expresser::ErrNeedAssignSymbol:
name = "NeedAssignSymbol";
break;
case expresser::ErrNeedFunctionName:
name = "Need a function name in <function-call>";
break;
case expresser::ErrNeedIdentifier:
name = "NeedIdentifier";
break;
case expresser::ErrNeedRelationalOperator:
name = "NeedRelationalOperator";
break;
case expresser::ErrNeedSemicolon:
name = "NeedSemicolon";
break;
case expresser::ErrNeedSemicolonOrComma:
name = "NeedSemicolonOrComma";
break;
case expresser::ErrNeedVariableType:
name = "NeedVariableType";
break;
case expresser::ErrNeedWhileInDoWhile:
name = "NeedWhileInDoWhile";
break;
case expresser::ErrNotInitialized:
name = "NotInitialized";
break;
case expresser::ErrNotDeclared:
name = "NotDeclared";
break;
case expresser::ErrReturnInVoidFunction:
name = "ReturnInVoidFunction";
break;
case expresser::ErrStreamError:
name = "StreamError";
break;
case expresser::ErrUnknownEscapeCharacter:
name = "UnknownEscapeCharacter";
break;
case expresser::ErrUndeclaredFunction:
name = "UndeclaredFunction";
break;
case expresser::ErrUndeclaredIdentifier:
name = "UndeclaredIdentifier";
break;
default:
name = "Unhandled Error";
break;
}
return format_to(ctx.out(), name);
}
};
}
namespace fmt {
template<>
struct formatter<expresser::Token> {
template<typename ParseContext>
constexpr auto parse(ParseContext &ctx) { return ctx.begin(); }
template<typename FormatContext>
auto format(expresser::Token p, FormatContext &ctx) {
return format_to(ctx.out(), "Line: {} Column: {} Type: {} Value: {}",
p.GetStartPos().first, p.GetStartPos().second, p.GetType(), p.GetStringValue());
}
};
template<>
struct formatter<expresser::TokenType> {
template<typename ParseContext>
constexpr auto parse(ParseContext &ctx) { return ctx.begin(); }
template<typename FormatContext>
auto format(const expresser::TokenType &p, FormatContext &ctx) {
std::string name;
switch (p) {
case expresser::STRINGLITERAL:
name = "STRINGLITERAL";
break;
case expresser::IDENTIFIER:
name = "IDENTIFIER";
break;
case expresser::INTEGER:
name = "INTEGER";
break;
case expresser::CHARLITERAL:
name = "CHARLITERAL";
break;
case expresser::DOUBLE:
name = "DOUBLE";
break;
case expresser::VOID:
name = "VOID";
break;
case expresser::RESERVED:
name = "RESERVED";
break;
case expresser::PLUS:
name = "PLUS";
break;
case expresser::MINUS:
name = "MINUS";
break;
case expresser::MULTIPLE:
name = "MULTIPLE";
break;
case expresser::DIVIDE:
name = "DIVIDE";
break;
case expresser::LESS:
name = "LESS";
break;
case expresser::GREATER:
name = "GREATER";
break;
case expresser::LESSEQUAL:
name = "LESSEQUAL";
break;
case expresser::GREATEREQUAL:
name = "GREATEREQUAL";
break;
case expresser::EQUAL:
name = "EQUAL";
break;
case expresser::NOTEQUAL:
name = "NOTEQUAL";
break;
case expresser::LEFTBRACKET:
name = "LEFTBRACKET";
break;
case expresser::RIGHTBRACKET:
name = "RIGHTBRACKET";
break;
case expresser::LEFTBRACE:
name = "LEFTBRACE";
break;
case expresser::RIGHTBRACE:
name = "RIGHTBRACE";
break;
case expresser::ASSIGN:
name = "ASSIGN";
break;
case expresser::SEMICOLON:
name = "SEMICOLON";
break;
case expresser::COLON:
name = "COLON";
break;
case expresser::COMMA:
name = "COMMA";
break;
}
return format_to(ctx.out(), name);
}
};
}
namespace fmt {
template<>
struct formatter<expresser::Instruction> {
template<typename ParseContext>
constexpr auto parse(ParseContext &ctx) { return ctx.begin(); }
template<typename FormatContext>
auto format(expresser::Instruction inst, FormatContext &ctx) {
auto params = inst.GetParams();
std::string string_param;
for (;;) {
int32_t value;
if (params.first._size == 0)
break;
value = 0;
::memcpy(&value, params.first._value, params.first._size);
string_param += " ";
string_param += std::to_string(value);
if (params.second._size == 0)
break;
value = 0;
::memcpy(&value, params.second._value, params.second._size);
string_param += "," + std::to_string(value);
break;
}
return format_to(ctx.out(), "{} {}{}", std::to_string(inst.GetIndex()), inst.GetOperation(), string_param);
}
};
template<>
struct formatter<expresser::Operation> {
template<typename ParseContext>
constexpr auto parse(ParseContext &ctx) { return ctx.begin(); }
template<typename FormatContext>
auto format(const expresser::Operation &op, FormatContext &ctx) {
std::string name;
switch (op) {
case expresser::NOP:
name = "nop";
break;
case expresser::BIPUSH:
name = "bipush";
break;
case expresser::IPUSH:
name = "ipush";
break;
case expresser::POP:
name = "pop";
break;
case expresser::POP2:
name = "pop2";
break;
case expresser::POPN:
name = "popn";
break;
case expresser::DUP:
name = "dup";
break;
case expresser::DUP2:
name = "dup2";
break;
case expresser::LOADC:
name = "loadc";
break;
case expresser::LOADA:
name = "loada";
break;
case expresser::NEW:
name = "new";
break;
case expresser::SNEW:
name = "snew";
break;
case expresser::ILOAD:
name = "iload";
break;
case expresser::DLOAD:
name = "dload";
break;
case expresser::ALOAD:
name = "aload";
break;
case expresser::IALOAD:
name = "iaload";
break;
case expresser::DALOAD:
name = "daload";
break;
case expresser::AALOAD:
name = "aaload";
break;
case expresser::ISTORE:
name = "istore";
break;
case expresser::DSTORE:
name = "dstore";
break;
case expresser::ASTORE:
name = "astore";
break;
case expresser::IASTORE:
name = "iastore";
break;
case expresser::DASTORE:
name = "dastore";
break;
case expresser::AASTORE:
name = "aastore";
break;
case expresser::IADD:
name = "iadd";
break;
case expresser::DADD:
name = "dadd";
break;
case expresser::ISUB:
name = "isub";
break;
case expresser::DSUB:
name = "dsub";
break;
case expresser::IMUL:
name = "imul";
break;
case expresser::DMUL:
name = "dmul";
break;
case expresser::IDIV:
name = "idiv";
break;
case expresser::DDIV:
name = "ddiv";
break;
case expresser::INEG:
name = "ineg";
break;
case expresser::DNEG:
name = "dneg";
break;
case expresser::ICMP:
name = "icmp";
break;
case expresser::DCMP:
name = "dcmp";
break;
case expresser::I2D:
name = "i2d";
break;
case expresser::D2I:
name = "d2i";
break;
case expresser::I2C:
name = "i2c";
break;
case expresser::JMP:
name = "jmp";
break;
case expresser::JE:
name = "je";
break;
case expresser::JNE:
name = "jne";
break;
case expresser::JL:
name = "jl";
break;
case expresser::JGE:
name = "jge";
break;
case expresser::JG:
name = "jg";
break;
case expresser::JLE:
name = "jle";
break;
case expresser::CALL:
name = "call";
break;
case expresser::RET:
name = "ret";
break;
case expresser::IRET:
name = "iret";
break;
case expresser::DRET:
name = "dret";
break;
case expresser::ARET:
name = "aret";
break;
case expresser::IPRINT:
name = "iprint";
break;
case expresser::DPRINT:
name = "dprint";
break;
case expresser::CPRINT:
name = "cprint";
break;
case expresser::SPRINT:
name = "sprint";
break;
case expresser::PRINTL:
name = "printl";
break;
case expresser::ISCAN:
name = "iscan";
break;
case expresser::DSCAN:
name = "dscan";
break;
case expresser::CSCAN:
name = "cscan";
break;
}
return format_to(ctx.out(), name);
}
};
}
#endif //EXPRESSER_FMP_HPP
|
[
"Tao-kun@users.noreply.github.com"
] |
Tao-kun@users.noreply.github.com
|
9a87e08af2fc039657c74a44337186e94da45c8c
|
75452de12ec9eea346e3b9c7789ac0abf3eb1d73
|
/src/connectivity/bluetooth/core/bt-host/l2cap/low_energy_command_handler.h
|
b9f0bf98d2186c31bba9d615857bf9f0b0994acf
|
[
"BSD-3-Clause"
] |
permissive
|
oshunter/fuchsia
|
c9285cc8c14be067b80246e701434bbef4d606d1
|
2196fc8c176d01969466b97bba3f31ec55f7767b
|
refs/heads/master
| 2022-12-22T11:30:15.486382
| 2020-08-16T03:41:23
| 2020-08-16T03:41:23
| 287,920,017
| 2
| 2
|
BSD-3-Clause
| 2022-12-16T03:30:27
| 2020-08-16T10:18:30
|
C++
|
UTF-8
|
C++
| false
| false
| 3,368
|
h
|
// Copyright 2020 The Fuchsia 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 SRC_CONNECTIVITY_BLUETOOTH_CORE_BT_HOST_L2CAP_LOW_ENERGY_COMMAND_HANDLER_H_
#define SRC_CONNECTIVITY_BLUETOOTH_CORE_BT_HOST_L2CAP_LOW_ENERGY_COMMAND_HANDLER_H_
#include "src/connectivity/bluetooth/core/bt-host/common/byte_buffer.h"
#include "src/connectivity/bluetooth/core/bt-host/l2cap/command_handler.h"
#include "src/connectivity/bluetooth/core/bt-host/l2cap/l2cap.h"
namespace bt::l2cap::internal {
class LowEnergyCommandHandler final : public CommandHandler {
public:
class ConnectionParameterUpdateResponse final : public Response {
public:
using PayloadT = ConnectionParameterUpdateResponsePayload;
static constexpr const char* kName = "Connection Parameter Update Response";
using Response::Response; // Inherit ctor
bool Decode(const ByteBuffer& payload_buf);
ConnectionParameterUpdateResult result() const { return result_; }
private:
friend class LowEnergyCommandHandler;
ConnectionParameterUpdateResult result_;
};
class ConnectionParameterUpdateResponder final : public Responder {
public:
explicit ConnectionParameterUpdateResponder(SignalingChannel::Responder* sig_responder);
void Send(ConnectionParameterUpdateResult result);
};
// |sig| must be valid for the lifetime of this object.
// |command_failed_callback| is called if an outbound request timed out with
// RTX or ERTX timers after retransmission (if configured). The call may come
// after the lifetime of this object.
explicit LowEnergyCommandHandler(SignalingChannelInterface* sig,
fit::closure request_fail_callback = nullptr);
~LowEnergyCommandHandler() = default;
DISALLOW_COPY_AND_ASSIGN_ALLOW_MOVE(LowEnergyCommandHandler);
// Outbound request sending methods. Response callbacks are required to be
// non-empty. The callbacks are wrapped and moved into the SignalingChannel
// and may outlive LowEnergyCommandHandler.
using ConnectionParameterUpdateResponseCallback =
fit::function<void(const ConnectionParameterUpdateResponse& rsp)>;
bool SendConnectionParameterUpdateRequest(uint16_t interval_min, uint16_t interval_max,
uint16_t slave_latency, uint16_t timeout_multiplier,
ConnectionParameterUpdateResponseCallback cb);
// Inbound request delegate registration methods. The callbacks are wrapped
// and moved into the SignalingChannel and may outlive LowEnergyCommandHandler. It
// is expected that any request delegates registered will span the lifetime of
// its signaling channel and hence link, so no unregistration is provided.
// However each call to register will replace any currently registered request
// delegate.
using ConnectionParameterUpdateRequestCallback = fit::function<void(
uint16_t interval_min, uint16_t interval_max, uint16_t slave_latency,
uint16_t timeout_multiplier, ConnectionParameterUpdateResponder* responder)>;
void ServeConnectionParameterUpdateRequest(ConnectionParameterUpdateRequestCallback cb);
};
} // namespace bt::l2cap::internal
#endif // SRC_CONNECTIVITY_BLUETOOTH_CORE_BT_HOST_L2CAP_LOW_ENERGY_COMMAND_HANDLER_H_
|
[
"commit-bot@chromium.org"
] |
commit-bot@chromium.org
|
3995426bbebf65b05a43e6e8507a0548eeca03a0
|
90047daeb462598a924d76ddf4288e832e86417c
|
/base/profiler/native_stack_sampler_mac.cc
|
dcaaa6febcaad06b9a292d81c2c0e592fe21d591
|
[
"BSD-3-Clause"
] |
permissive
|
massbrowser/android
|
99b8c21fa4552a13c06bbedd0f9c88dd4a4ad080
|
a9c4371682c9443d6e1d66005d4db61a24a9617c
|
refs/heads/master
| 2022-11-04T21:15:50.656802
| 2017-06-08T12:31:39
| 2017-06-08T12:31:39
| 93,747,579
| 2
| 2
|
BSD-3-Clause
| 2022-10-31T10:34:25
| 2017-06-08T12:36:07
| null |
UTF-8
|
C++
| false
| false
| 17,359
|
cc
|
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/profiler/native_stack_sampler.h"
#include <dlfcn.h>
#include <libkern/OSByteOrder.h>
#include <libunwind.h>
#include <mach-o/swap.h>
#include <mach/kern_return.h>
#include <mach/mach.h>
#include <mach/thread_act.h>
#include <pthread.h>
#include <sys/resource.h>
#include <sys/syslimits.h>
#include <algorithm>
#include <map>
#include <memory>
#include "base/logging.h"
#include "base/mac/mach_logging.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
namespace base {
namespace {
// Miscellaneous --------------------------------------------------------------
size_t StackCopyBufferSize() {
static size_t stack_size = 0;
if (stack_size)
return stack_size;
// In platform_thread_mac's GetDefaultThreadStackSize(), RLIMIT_STACK is used
// for all stacks, not just the main thread's, so it is good for use here.
struct rlimit stack_rlimit;
if (getrlimit(RLIMIT_STACK, &stack_rlimit) == 0 &&
stack_rlimit.rlim_cur != RLIM_INFINITY) {
stack_size = stack_rlimit.rlim_cur;
return stack_size;
}
// If getrlimit somehow fails, return the default macOS main thread stack size
// of 8 MB (DFLSSIZ in <i386/vmparam.h>) with extra wiggle room.
return 12 * 1024 * 1024;
}
// Stack walking --------------------------------------------------------------
// Fills |state| with |target_thread|'s context.
//
// Note that this is called while a thread is suspended. Make very very sure
// that no shared resources (e.g. memory allocators) are used for the duration
// of this function.
bool GetThreadState(thread_act_t target_thread, x86_thread_state64_t* state) {
mach_msg_type_number_t count =
static_cast<mach_msg_type_number_t>(x86_THREAD_STATE64_COUNT);
return thread_get_state(target_thread, x86_THREAD_STATE64,
reinterpret_cast<thread_state_t>(state),
&count) == KERN_SUCCESS;
}
// If the value at |pointer| points to the original stack, rewrites it to point
// to the corresponding location in the copied stack.
//
// Note that this is called while a thread is suspended. Make very very sure
// that no shared resources (e.g. memory allocators) are used for the duration
// of this function.
uintptr_t RewritePointerIfInOriginalStack(
const uintptr_t* original_stack_bottom,
const uintptr_t* original_stack_top,
uintptr_t* stack_copy_bottom,
uintptr_t pointer) {
uintptr_t original_stack_bottom_int =
reinterpret_cast<uintptr_t>(original_stack_bottom);
uintptr_t original_stack_top_int =
reinterpret_cast<uintptr_t>(original_stack_top);
uintptr_t stack_copy_bottom_int =
reinterpret_cast<uintptr_t>(stack_copy_bottom);
if ((pointer < original_stack_bottom_int) ||
(pointer >= original_stack_top_int)) {
return pointer;
}
return stack_copy_bottom_int + (pointer - original_stack_bottom_int);
}
// Copies the stack to a buffer while rewriting possible pointers to locations
// within the stack to point to the corresponding locations in the copy. This is
// necessary to handle stack frames with dynamic stack allocation, where a
// pointer to the beginning of the dynamic allocation area is stored on the
// stack and/or in a non-volatile register.
//
// Eager rewriting of anything that looks like a pointer to the stack, as done
// in this function, does not adversely affect the stack unwinding. The only
// other values on the stack the unwinding depends on are return addresses,
// which should not point within the stack memory. The rewriting is guaranteed
// to catch all pointers because the stacks are guaranteed by the ABI to be
// sizeof(void*) aligned.
//
// Note that this is called while a thread is suspended. Make very very sure
// that no shared resources (e.g. memory allocators) are used for the duration
// of this function.
void CopyStackAndRewritePointers(uintptr_t* stack_copy_bottom,
const uintptr_t* original_stack_bottom,
const uintptr_t* original_stack_top,
x86_thread_state64_t* thread_state)
NO_SANITIZE("address") {
size_t count = original_stack_top - original_stack_bottom;
for (size_t pos = 0; pos < count; ++pos) {
stack_copy_bottom[pos] = RewritePointerIfInOriginalStack(
original_stack_bottom, original_stack_top, stack_copy_bottom,
original_stack_bottom[pos]);
}
uint64_t* rewrite_registers[] = {&thread_state->__rbx, &thread_state->__rbp,
&thread_state->__rsp, &thread_state->__r12,
&thread_state->__r13, &thread_state->__r14,
&thread_state->__r15};
for (auto* reg : rewrite_registers) {
*reg = RewritePointerIfInOriginalStack(
original_stack_bottom, original_stack_top, stack_copy_bottom, *reg);
}
}
// Walks the stack represented by |unwind_context|, calling back to the provided
// lambda for each frame. Returns false if an error occurred, otherwise returns
// true.
template <typename StackFrameCallback>
bool WalkStackFromContext(unw_context_t* unwind_context,
size_t* frame_count,
const StackFrameCallback& callback) {
unw_cursor_t unwind_cursor;
unw_init_local(&unwind_cursor, unwind_context);
int step_result;
unw_word_t ip;
do {
++(*frame_count);
unw_get_reg(&unwind_cursor, UNW_REG_IP, &ip);
callback(static_cast<uintptr_t>(ip));
step_result = unw_step(&unwind_cursor);
} while (step_result > 0);
if (step_result != 0)
return false;
return true;
}
const char* LibSystemKernelName() {
static char path[PATH_MAX];
static char* name = nullptr;
if (name)
return name;
Dl_info info;
dladdr(reinterpret_cast<void*>(_exit), &info);
strncpy(path, info.dli_fname, PATH_MAX);
name = path;
#if !defined(ADDRESS_SANITIZER)
DCHECK_EQ(std::string(name),
std::string("/usr/lib/system/libsystem_kernel.dylib"));
#endif
return name;
}
// Walks the stack represented by |thread_state|, calling back to the provided
// lambda for each frame.
template <typename StackFrameCallback>
void WalkStack(const x86_thread_state64_t& thread_state,
uintptr_t stack_top,
const StackFrameCallback& callback) {
size_t frame_count = 0;
// This uses libunwind to walk the stack. libunwind is designed to be used for
// a thread to walk its own stack. This creates two problems.
// Problem 1: There is no official way to create a unw_context other than to
// create it from the current state of the current thread's stack. To get
// around this, forge a context. A unw_context is just a copy of the 16 main
// registers followed by the instruction pointer, nothing more.
// Coincidentally, the first 17 items of the x86_thread_state64_t type are
// exactly those registers in exactly the same order, so just bulk copy them
// over.
unw_context_t unwind_context;
memcpy(&unwind_context, &thread_state, sizeof(uintptr_t) * 17);
bool result = WalkStackFromContext(&unwind_context, &frame_count, callback);
if (!result)
return;
if (frame_count == 1) {
// Problem 2: Because libunwind is designed to be triggered by user code on
// their own thread, if it hits a library that has no unwind info for the
// function that is being executed, it just stops. This isn't a problem in
// the normal case, but in this case, it's quite possible that the stack
// being walked is stopped in a function that bridges to the kernel and thus
// is missing the unwind info.
// For now, just unwind the single case where the thread is stopped in a
// function in libsystem_kernel.
uint64_t& rsp = unwind_context.data[7];
uint64_t& rip = unwind_context.data[16];
Dl_info info;
if (dladdr(reinterpret_cast<void*>(rip), &info) != 0 &&
strcmp(info.dli_fname, LibSystemKernelName()) == 0) {
rip = *reinterpret_cast<uint64_t*>(rsp);
rsp += 8;
WalkStackFromContext(&unwind_context, &frame_count, callback);
}
}
}
// Module identifiers ---------------------------------------------------------
// Returns the hex encoding of a 16-byte ID for the binary loaded at
// |module_addr|. Returns an empty string if the UUID cannot be found at
// |module_addr|.
std::string GetUniqueId(const void* module_addr) {
const mach_header_64* mach_header =
reinterpret_cast<const mach_header_64*>(module_addr);
DCHECK_EQ(MH_MAGIC_64, mach_header->magic);
size_t offset = sizeof(mach_header_64);
size_t offset_limit = sizeof(mach_header_64) + mach_header->sizeofcmds;
for (uint32_t i = 0; (i < mach_header->ncmds) &&
(offset + sizeof(load_command) < offset_limit);
++i) {
const load_command* current_cmd = reinterpret_cast<const load_command*>(
reinterpret_cast<const uint8_t*>(mach_header) + offset);
if (offset + current_cmd->cmdsize > offset_limit) {
// This command runs off the end of the command list. This is malformed.
return std::string();
}
if (current_cmd->cmd == LC_UUID) {
if (current_cmd->cmdsize < sizeof(uuid_command)) {
// This "UUID command" is too small. This is malformed.
return std::string();
}
const uuid_command* uuid_cmd =
reinterpret_cast<const uuid_command*>(current_cmd);
static_assert(sizeof(uuid_cmd->uuid) == sizeof(uuid_t),
"UUID field of UUID command should be 16 bytes.");
return HexEncode(&uuid_cmd->uuid, sizeof(uuid_cmd->uuid));
}
offset += current_cmd->cmdsize;
}
return std::string();
}
// Gets the index for the Module containing |instruction_pointer| in
// |modules|, adding it if it's not already present. Returns
// StackSamplingProfiler::Frame::kUnknownModuleIndex if no Module can be
// determined for |module|.
size_t GetModuleIndex(const uintptr_t instruction_pointer,
std::vector<StackSamplingProfiler::Module>* modules,
std::map<const void*, size_t>* profile_module_index) {
Dl_info inf;
if (!dladdr(reinterpret_cast<const void*>(instruction_pointer), &inf))
return StackSamplingProfiler::Frame::kUnknownModuleIndex;
auto module_index = profile_module_index->find(inf.dli_fbase);
if (module_index == profile_module_index->end()) {
StackSamplingProfiler::Module module(
reinterpret_cast<uintptr_t>(inf.dli_fbase), GetUniqueId(inf.dli_fbase),
base::FilePath(inf.dli_fname));
modules->push_back(module);
module_index =
profile_module_index
->insert(std::make_pair(inf.dli_fbase, modules->size() - 1))
.first;
}
return module_index->second;
}
// ScopedSuspendThread --------------------------------------------------------
// Suspends a thread for the lifetime of the object.
class ScopedSuspendThread {
public:
explicit ScopedSuspendThread(mach_port_t thread_port)
: thread_port_(thread_suspend(thread_port) == KERN_SUCCESS
? thread_port
: MACH_PORT_NULL) {}
~ScopedSuspendThread() {
if (!was_successful())
return;
kern_return_t kr = thread_resume(thread_port_);
MACH_CHECK(kr == KERN_SUCCESS, kr) << "thread_resume";
}
bool was_successful() const { return thread_port_ != MACH_PORT_NULL; }
private:
mach_port_t thread_port_;
DISALLOW_COPY_AND_ASSIGN(ScopedSuspendThread);
};
// NativeStackSamplerMac ------------------------------------------------------
class NativeStackSamplerMac : public NativeStackSampler {
public:
NativeStackSamplerMac(mach_port_t thread_port,
AnnotateCallback annotator,
NativeStackSamplerTestDelegate* test_delegate);
~NativeStackSamplerMac() override;
// StackSamplingProfiler::NativeStackSampler:
void ProfileRecordingStarting(
std::vector<StackSamplingProfiler::Module>* modules) override;
void RecordStackSample(StackSamplingProfiler::Sample* sample) override;
void ProfileRecordingStopped() override;
private:
// Suspends the thread with |thread_port_|, copies its stack and resumes the
// thread, then records the stack frames and associated modules into |sample|.
void SuspendThreadAndRecordStack(StackSamplingProfiler::Sample* sample);
// Weak reference: Mach port for thread being profiled.
mach_port_t thread_port_;
const AnnotateCallback annotator_;
NativeStackSamplerTestDelegate* const test_delegate_;
// The stack base address corresponding to |thread_handle_|.
const void* const thread_stack_base_address_;
// The size of the |stack_copy_buffer_|.
const size_t stack_copy_buffer_size_;
// Buffer to use for copies of the stack. We use the same buffer for all the
// samples to avoid the overhead of multiple allocations and frees.
const std::unique_ptr<unsigned char[]> stack_copy_buffer_;
// Weak. Points to the modules associated with the profile being recorded
// between ProfileRecordingStarting() and ProfileRecordingStopped().
std::vector<StackSamplingProfiler::Module>* current_modules_ = nullptr;
// Maps a module's base address to the corresponding Module's index within
// current_modules_.
std::map<const void*, size_t> profile_module_index_;
DISALLOW_COPY_AND_ASSIGN(NativeStackSamplerMac);
};
NativeStackSamplerMac::NativeStackSamplerMac(
mach_port_t thread_port,
AnnotateCallback annotator,
NativeStackSamplerTestDelegate* test_delegate)
: thread_port_(thread_port),
annotator_(annotator),
test_delegate_(test_delegate),
thread_stack_base_address_(
pthread_get_stackaddr_np(pthread_from_mach_thread_np(thread_port))),
stack_copy_buffer_size_(StackCopyBufferSize()),
stack_copy_buffer_(new unsigned char[stack_copy_buffer_size_]) {
DCHECK(annotator_);
// This class suspends threads, and those threads might be suspended in dyld.
// Therefore, for all the system functions that might be linked in dynamically
// that are used while threads are suspended, make calls to them to make sure
// that they are linked up.
x86_thread_state64_t thread_state;
GetThreadState(thread_port_, &thread_state);
}
NativeStackSamplerMac::~NativeStackSamplerMac() {}
void NativeStackSamplerMac::ProfileRecordingStarting(
std::vector<StackSamplingProfiler::Module>* modules) {
current_modules_ = modules;
profile_module_index_.clear();
}
void NativeStackSamplerMac::RecordStackSample(
StackSamplingProfiler::Sample* sample) {
DCHECK(current_modules_);
SuspendThreadAndRecordStack(sample);
}
void NativeStackSamplerMac::ProfileRecordingStopped() {
current_modules_ = nullptr;
}
void NativeStackSamplerMac::SuspendThreadAndRecordStack(
StackSamplingProfiler::Sample* sample) {
x86_thread_state64_t thread_state;
// Copy the stack.
uintptr_t new_stack_top = 0;
{
// IMPORTANT NOTE: Do not do ANYTHING in this in this scope that might
// allocate memory, including indirectly via use of DCHECK/CHECK or other
// logging statements. Otherwise this code can deadlock on heap locks in the
// default heap acquired by the target thread before it was suspended.
ScopedSuspendThread suspend_thread(thread_port_);
if (!suspend_thread.was_successful())
return;
if (!GetThreadState(thread_port_, &thread_state))
return;
uintptr_t stack_top =
reinterpret_cast<uintptr_t>(thread_stack_base_address_);
uintptr_t stack_bottom = thread_state.__rsp;
if (stack_bottom >= stack_top)
return;
uintptr_t stack_size = stack_top - stack_bottom;
if (stack_size > stack_copy_buffer_size_)
return;
(*annotator_)(sample);
CopyStackAndRewritePointers(
reinterpret_cast<uintptr_t*>(stack_copy_buffer_.get()),
reinterpret_cast<uintptr_t*>(stack_bottom),
reinterpret_cast<uintptr_t*>(stack_top), &thread_state);
new_stack_top =
reinterpret_cast<uintptr_t>(stack_copy_buffer_.get()) + stack_size;
} // ScopedSuspendThread
if (test_delegate_)
test_delegate_->OnPreStackWalk();
// Walk the stack and record it.
// Reserve enough memory for most stacks, to avoid repeated allocations.
// Approximately 99.9% of recorded stacks are 128 frames or fewer.
sample->frames.reserve(128);
auto* current_modules = current_modules_;
auto* profile_module_index = &profile_module_index_;
WalkStack(
thread_state, new_stack_top,
[sample, current_modules, profile_module_index](uintptr_t frame_ip) {
sample->frames.push_back(StackSamplingProfiler::Frame(
frame_ip,
GetModuleIndex(frame_ip, current_modules, profile_module_index)));
});
}
} // namespace
std::unique_ptr<NativeStackSampler> NativeStackSampler::Create(
PlatformThreadId thread_id,
AnnotateCallback annotator,
NativeStackSamplerTestDelegate* test_delegate) {
return base::MakeUnique<NativeStackSamplerMac>(thread_id, annotator,
test_delegate);
}
} // namespace base
|
[
"xElvis89x@gmail.com"
] |
xElvis89x@gmail.com
|
a487fcf3b2d0f9e5f28db96ab924f4b50e28fb11
|
f13d58b82ab70b42ff017432272e4e9fc3d8d99a
|
/online-judge/CodeForces/CodeForces 1117A.cpp
|
ffd13e9d057117ef476f3d2427b17474b563252f
|
[] |
no_license
|
WEGFan/Algorithm-Contest-Code
|
3586d6edba03165a9e243a10566fedcc6bcf1315
|
a5b53605c0ec7161d12d48335171763a2ddf12b0
|
refs/heads/master
| 2020-11-26T10:33:02.807386
| 2019-12-19T12:05:17
| 2019-12-19T12:05:17
| 229,043,842
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 582
|
cpp
|
#include <iostream>
#include <algorithm>
using namespace std;
int arr[100007];
int main()
{
int n;
cin >> n;
int maxlen = 0, maxn = 0;
for (int i = 0; i < n; i++)
{
cin >> arr[i];
maxn = max(maxn, arr[i]);
}
for (int i = 0; i < n; i++)
{
int j = i, len = 0;
while (j < n && arr[i] == arr[j])
{
if (arr[j] == maxn)
{
len++;
}
j++;
}
maxlen = max(len, maxlen);
i = j - 1;
}
cout << maxlen << endl;
return 0;
}
|
[
"goofans@qq.com"
] |
goofans@qq.com
|
51bd6a8b7c4d60e2b893b586c46849d3024a6e0a
|
c3f83e21b4598aa80bba3d793371f59d2f075f08
|
/DirectShowSpy/FilterGraphHelper.h
|
a4bdde5a89823e93aeac231b894f9f7284819bdf
|
[] |
no_license
|
WladimirW/alax
|
d4ff1fec7b90238cfe400c723478168fadbe0ffa
|
b1c45d51e9ff4b087e74360a21c2a4306eb884ec
|
refs/heads/master
| 2020-03-12T22:56:18.590594
| 2018-04-23T08:23:59
| 2018-04-23T08:23:59
| 130,856,226
| 1
| 0
| null | null | null | null |
MacCentralEurope
|
C++
| false
| false
| 145,139
|
h
|
////////////////////////////////////////////////////////////
// Copyright (C) Roman Ryltsov, 2008-2015
// Created by Roman Ryltsov roman@alax.info, http://alax.info
//
// This source code is published to complement DirectShowSpy developer powertoy
// and demonstrate the internal use of APIs and tricks powering the tool. It is
// allowed to freely re-use the portions of the code in other projects, commercial
// or otherwise (provided that you donít pretend that you wrote the original tool).
//
// Please keep in mind that DirectShowSpy is a developer tool, it is strongly recommended
// that it is not shipped with release grade software. It is allowed to distribute
// DirectShowSpy if only it is not registered with Windows by default and either
// used privately, or registered on specific throubleshooting request. The advice applies
// to hooking methods used by DirectShowSpy in general as well.
#pragma once
#include "rofiles.h"
#include "rodshow.h"
#include "Module_i.h"
#include "Common.h"
#include "RunPropertyBag.h"
#include "RunEvent.h"
INT_PTR DoFilterGraphListPropertySheetModal(HWND hParentWindow = GetActiveWindow(), COptions* pOptions = NULL);
HRESULT FilterGraphHelper_DoPropertyFrameModal(LONG nParentWindowHandle);
HRESULT FilterGraphHelper_DoFilterGraphListModal(LONG nParentWindowHandle);
HRESULT FilterGraphHelper_OpenGraphStudioNext(LONG nParentWindowHandle, LPCWSTR pszMonikerDisplayName, VARIANT_BOOL* pbResult);
HRESULT FilterGraphHelper_OpenGraphEdit(LONG nParentWindowHandle, LPCWSTR pszMonikerDisplayName, VARIANT_BOOL* pbResult);
VOID MediaSampleTrace_Reset(DWORD nProcessIdentifier);
CString MediaSampleTrace_Get(DWORD nProcessIdentifier);
CComPtr<IUnknown> MediaSampleTrace_Lock();
////////////////////////////////////////////////////////////
// CRunPropertyBagPropertyPage
class ATL_NO_VTABLE CRunPropertyBagPropertyPage :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CRunPropertyBagPropertyPage, &__uuidof(RunPropertyBagPropertyPage)>,
public COlePropertyPageT<CRunPropertyBagPropertyPage>,
public CDialogResize<CRunPropertyBagPropertyPage>
{
public:
enum { IDR = IDR_GENERIC_RUNPROPERTYBAG_PROPERTYPAGE };
enum { IDD = IDD_GENERIC_RUNPROPERTYBAG };
BEGIN_COM_MAP(CRunPropertyBagPropertyPage)
COM_INTERFACE_ENTRY(IPropertyPage2)
COM_INTERFACE_ENTRY(IPropertyPage)
END_COM_MAP()
BEGIN_MSG_MAP_EX(CRunPropertyBagPropertyPage)
CHAIN_MSG_MAP(COlePropertyPage)
CHAIN_MSG_MAP(CDialogResize<CRunPropertyBagPropertyPage>)
MSG_WM_INITDIALOG(OnInitDialog)
MSG_WM_DESTROY(OnDestroy)
COMMAND_ID_HANDLER_EX(IDC_GENERIC_RUNPROPERTYBAG_REFRESH, OnRefresh)
COMMAND_ID_HANDLER_EX(IDC_GENERIC_RUNPROPERTYBAG_COPY, OnCopy)
COMMAND_ID_HANDLER_EX(IDC_GENERIC_RUNPROPERTYBAG_SAVEAS, OnSaveAs)
REFLECT_NOTIFICATIONS()
END_MSG_MAP()
BEGIN_DLGRESIZE_MAP(CRunPropertyBagPropertyPage)
DLGRESIZE_CONTROL(IDC_GENERIC_RUNPROPERTYBAG_INTRODUCTION, DLSZ_SIZE_X)
DLGRESIZE_CONTROL(IDC_GENERIC_RUNPROPERTYBAG_TEXT, DLSZ_SIZE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_GENERIC_RUNPROPERTYBAG_REFRESH, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_GENERIC_RUNPROPERTYBAG_COPY, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_GENERIC_RUNPROPERTYBAG_SAVEAS, DLSZ_MOVE_Y)
END_DLGRESIZE_MAP()
private:
BOOL m_bActivating;
CRoEdit m_TextEdit;
CFont m_TextFont;
CButton m_CopyButton;
CButton m_SaveAsButton;
CRoMapT<INT_PTR, BOOL> m_ChangeMap;
public:
// CRunPropertyBagPropertyPage
static CString GetObjectFriendlyName()
{
return _StringHelper::GetLine(IDR, 2);
}
static HRESULT WINAPI UpdateRegistry(BOOL bRegister)
{
_Z2(atlTraceRegistrar, 2, _T("bRegister %d\n"), bRegister);
return DefaultUpdateRegistry(bRegister);
}
CRunPropertyBagPropertyPage()
{
_Z4_THIS();
}
~CRunPropertyBagPropertyPage()
{
_Z4_THIS();
}
VOID UpdateControls()
{
const INT nLextLength = m_TextEdit.GetWindowTextLength();
m_CopyButton.EnableWindow(nLextLength > 0);
m_SaveAsButton.EnableWindow(nLextLength > 0);
}
VOID UpdateText()
{
CString sText;
_A(GetObjectCount() == 1);
m_TextEdit.SetValue(CRunPropertyBagHelper::GetPropertyBagText(GetObject(0)));
}
// Window Message Handler
LRESULT OnInitDialog(HWND, LPARAM)
{
m_bActivating = TRUE;
_ATLTRY
{
CWaitCursor WaitCursor;
m_TextEdit = GetDlgItem(IDC_GENERIC_RUNPROPERTYBAG_TEXT);
CLogFont TextFont;
CFontHandle(AtlGetDefaultGuiFont()).GetLogFont(TextFont);
_tcsncpy_s(TextFont.lfFaceName, _T("Courier New"), _TRUNCATE);
TextFont.SetHeight(8);
m_TextFont = TextFont.CreateFontIndirect();
m_TextEdit.SetFont(m_TextFont);
//m_RefreshButton = GetDlgItem(IDC_GENERIC_RUNEVENT_REFRESH);
m_CopyButton = GetDlgItem(IDC_GENERIC_RUNPROPERTYBAG_COPY);
m_SaveAsButton = GetDlgItem(IDC_GENERIC_RUNPROPERTYBAG_SAVEAS);
DlgResize_Init(FALSE);
_A(GetObjectCount() >= 1);
//const CComQIPtr<IRunPropertyBagAware> pRunPropertyBagAware = GetObject(0);
//__D(pRunPropertyBagAware, E_NOINTERFACE);
UpdateText();
UpdateControls();
m_ChangeMap.RemoveAll();
m_bActivating = FALSE;
}
_ATLCATCH(Exception)
{
AtlExceptionMessageBox(m_hWnd, Exception);
for(CWindow Window = GetWindow(GW_CHILD); Window.IsWindow(); Window = Window.GetWindow(GW_HWNDNEXT))
Window.EnableWindow(FALSE);
}
return TRUE;
}
LRESULT OnDestroy()
{
return 0;
}
LRESULT OnRefresh(UINT, INT, HWND)
{
CWaitCursor WaitCursor;
UpdateText();
UpdateControls();
return 0;
}
LRESULT OnCopy(UINT, INT, HWND)
{
SetClipboardText(m_hWnd, m_TextEdit.GetValue());
MessageBeep(MB_OK);
return 0;
}
LRESULT OnSaveAs(UINT, INT, HWND)
{
static const COMDLG_FILTERSPEC g_pFilter[] =
{
{ _T("Text Files"), _T("*.txt") },
{ _T("BZip2 Compressed Text Files"), _T("*.txt.bz2") },
{ _T("All Files"), _T("*.*") },
};
CPath sPath = _CommonDialogHelper::QuerySavePath(m_hWnd, g_pFilter, _T("txt"));
if(!_tcslen(sPath))
return 0;
CAtlFile File;
__C(File.Create(sPath, GENERIC_WRITE, FILE_SHARE_READ, CREATE_ALWAYS));
_ATLTRY
{
CStringA sText = Utf8StringFromString(CStringW(m_TextEdit.GetValue()));
static const BYTE g_pnByteOrderMark[] = { 0xEF, 0xBB, 0xBF, 0x00 };
sText.Insert(0, (LPCSTR) g_pnByteOrderMark);
if(_tcsicmp(GetPathExtension(sPath), _T(".bz2")) == 0)
{
CLocalObjectPtr<CBzip2Item> pItem;
pItem->SetRawData((const BYTE*) (LPCSTR) sText, sText.GetLength());
CHeapPtr<BYTE> pnData;
SIZE_T nDataSize = 0;
pItem->GetData(pnData, nDataSize);
__C(File.Write(pnData, (DWORD) nDataSize));
} else
__C(File.Write(sText, (DWORD) sText.GetLength()));
}
_ATLCATCHALL()
{
File.Close();
_W(DeleteFile(sPath));
_ATLRETHROW;
}
MessageBeep(MB_OK);
return 0;
}
// COlePropertyPageT, IRoPropertyPageT, IPropertyPage2, IPropertyPage
STDMETHOD(Apply)()
{
_Z4(atlTraceCOM, 4, _T("...\n"));
_ATLTRY
{
//if(!m_ChangeMap.IsEmpty())
{
//CWaitCursor WaitCursor;
//m_ChangeMap.RemoveAll();
SetDirty(FALSE);
}
}
_ATLCATCH(Exception)
{
_C(Exception);
}
return S_OK;
}
};
OBJECT_ENTRY_AUTO(__uuidof(RunPropertyBagPropertyPage), CRunPropertyBagPropertyPage)
////////////////////////////////////////////////////////////
// CRunEventPropertyPage
class ATL_NO_VTABLE CRunEventPropertyPage :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CRunEventPropertyPage, &__uuidof(RunEventPropertyPage)>,
public COlePropertyPageT<CRunEventPropertyPage>,
public CDialogResize<CRunEventPropertyPage>
{
public:
enum { IDR = IDR_GENERIC_RUNEVENT_PROPERTYPAGE };
enum { IDD = IDD_GENERIC_RUNEVENT };
BEGIN_COM_MAP(CRunEventPropertyPage)
COM_INTERFACE_ENTRY(IPropertyPage2)
COM_INTERFACE_ENTRY(IPropertyPage)
END_COM_MAP()
BEGIN_MSG_MAP_EX(CRunEventPropertyPage)
CHAIN_MSG_MAP(COlePropertyPage)
CHAIN_MSG_MAP(CDialogResize<CRunEventPropertyPage>)
MSG_WM_INITDIALOG(OnInitDialog)
MSG_WM_DESTROY(OnDestroy)
COMMAND_HANDLER_EX(IDC_GENERIC_RUNEVENT_CAPTURE, BN_CLICKED, OnCaptureButtonClicked)
COMMAND_ID_HANDLER_EX(IDC_GENERIC_RUNEVENT_REFRESH, OnRefresh)
COMMAND_ID_HANDLER_EX(IDC_GENERIC_RUNEVENT_COPY, OnCopy)
COMMAND_ID_HANDLER_EX(IDC_GENERIC_RUNEVENT_SAVEAS, OnSaveAs)
REFLECT_NOTIFICATIONS()
END_MSG_MAP()
BEGIN_DLGRESIZE_MAP(CRunEventPropertyPage)
DLGRESIZE_CONTROL(IDC_GENERIC_RUNEVENT_CAPTURE, DLSZ_SIZE_X)
DLGRESIZE_CONTROL(IDC_GENERIC_RUNEVENT_TEXT, DLSZ_SIZE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_GENERIC_RUNEVENT_REFRESH, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_GENERIC_RUNEVENT_COPY, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_GENERIC_RUNEVENT_SAVEAS, DLSZ_MOVE_Y)
END_DLGRESIZE_MAP()
public:
private:
BOOL m_bActivating;
CButton m_CaptureButton;
CRoEdit m_TextEdit;
CButton m_RefreshButton;
CButton m_CopyButton;
CButton m_SaveAsButton;
CRoMapT<INT_PTR, BOOL> m_ChangeMap;
public:
// CRunEventPropertyPage
static CString GetObjectFriendlyName()
{
return _StringHelper::GetLine(IDR, 2);
}
static HRESULT WINAPI UpdateRegistry(BOOL bRegister)
{
_Z2(atlTraceRegistrar, 2, _T("bRegister %d\n"), bRegister);
return DefaultUpdateRegistry(bRegister);
}
CRunEventPropertyPage()
{
_Z4_THIS();
}
~CRunEventPropertyPage()
{
_Z4_THIS();
}
VOID UpdateControls()
{
const BOOL bCapture = m_CaptureButton.GetCheck();
//m_TextEdit.EnableWindow(bCapture);
m_RefreshButton.EnableWindow(bCapture);
const INT nLextLength = m_TextEdit.GetWindowTextLength();
m_CopyButton.EnableWindow(nLextLength > 0);
m_SaveAsButton.EnableWindow(nLextLength > 0);
}
VOID Refresh()
{
const CComQIPtr<IRunEventAware> pRunEventAware = GetObject(0);
if(!pRunEventAware)
return;
CComVariantArray vValue;
__C(pRunEventAware->get_Value(&vValue));
CString sText;
_ATLTRY
{
if(vValue.vt > VT_NULL)
{
CRoArrayT<CComVariantArray> Array;
vValue.ToElementArray(Array);
for(SIZE_T nIndex = 0; nIndex < Array.GetCount(); nIndex++)
{
CRunEventHelper::CEvents::CItem Item;
if(!Item.SetAsVariant(Array[nIndex]))
continue;
sText.AppendFormat(_T("%d") _T("\t") _T("%hs"), (LONG) (Item.m_nTime / 10000i64), Item.m_pszText);
sText.Append(_T("\r\n"));
}
}
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
m_TextEdit.SetValue(sText);
}
// Window Message Handler
LRESULT OnInitDialog(HWND, LPARAM)
{
m_bActivating = TRUE;
_ATLTRY
{
m_CaptureButton = GetDlgItem(IDC_GENERIC_RUNEVENT_CAPTURE);
m_TextEdit = GetDlgItem(IDC_GENERIC_RUNEVENT_TEXT);
m_RefreshButton = GetDlgItem(IDC_GENERIC_RUNEVENT_REFRESH);
m_CopyButton = GetDlgItem(IDC_GENERIC_RUNEVENT_COPY);
m_SaveAsButton = GetDlgItem(IDC_GENERIC_RUNEVENT_SAVEAS);
DlgResize_Init(FALSE);
//m_OutputSampleTimeEdit = GetDlgItem(IDC_SUSPENSIONFILTER_SAMPLE_OUTPUTTIME);
_A(GetObjectCount() >= 1);
const CComQIPtr<IRunEventAware> pRunEventAware = GetObject(0);
__D(pRunEventAware, E_NOINTERFACE);
VARIANT_BOOL bCapture = ATL_VARIANT_FALSE;
__C(pRunEventAware->get_Capture(&bCapture));
m_CaptureButton.SetCheck(bCapture != ATL_VARIANT_FALSE);
if(bCapture != ATL_VARIANT_FALSE)
Refresh();
UpdateControls();
m_ChangeMap.RemoveAll();
m_bActivating = FALSE;
}
_ATLCATCH(Exception)
{
AtlExceptionMessageBox(m_hWnd, Exception);
for(CWindow Window = GetWindow(GW_CHILD); Window.IsWindow(); Window = Window.GetWindow(GW_HWNDNEXT))
Window.EnableWindow(FALSE);
}
return TRUE;
}
LRESULT OnDestroy()
{
return 0;
}
LRESULT OnCaptureButtonClicked(UINT, INT, HWND)
{
CWaitCursor WaitCursor;
const CComQIPtr<IRunEventAware> pRunEventAware = GetObject(0);
if(pRunEventAware)
_ATLTRY
{
const BOOL bCapture = m_CaptureButton.GetCheck();
__C(pRunEventAware->put_Capture(bCapture ? ATL_VARIANT_TRUE : ATL_VARIANT_FALSE));
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
UpdateControls();
return 0;
}
LRESULT OnRefresh(UINT, INT, HWND)
{
CWaitCursor WaitCursor;
Refresh();
UpdateControls();
return 0;
}
LRESULT OnCopy(UINT, INT, HWND)
{
SetClipboardText(m_hWnd, m_TextEdit.GetValue());
MessageBeep(MB_OK);
return 0;
}
LRESULT OnSaveAs(UINT, INT, HWND)
{
static const COMDLG_FILTERSPEC g_pFilter[] =
{
{ _T("Text Files"), _T("*.txt") },
{ _T("BZip2 Compressed Text Files"), _T("*.txt.bz2") },
{ _T("All Files"), _T("*.*") },
};
CPath sPath = _CommonDialogHelper::QuerySavePath(m_hWnd, g_pFilter, _T("txt"));
if(!_tcslen(sPath))
return 0;
CAtlFile File;
__C(File.Create(sPath, GENERIC_WRITE, FILE_SHARE_READ, CREATE_ALWAYS));
_ATLTRY
{
CStringA sText = Utf8StringFromString(CStringW(m_TextEdit.GetValue()));
static const BYTE g_pnByteOrderMark[] = { 0xEF, 0xBB, 0xBF, 0x00 };
sText.Insert(0, (LPCSTR) g_pnByteOrderMark);
if(_tcsicmp(GetPathExtension(sPath), _T(".bz2")) == 0)
{
CLocalObjectPtr<CBzip2Item> pItem;
pItem->SetRawData((const BYTE*) (LPCSTR) sText, sText.GetLength());
CHeapPtr<BYTE> pnData;
SIZE_T nDataSize = 0;
pItem->GetData(pnData, nDataSize);
__C(File.Write(pnData, (DWORD) nDataSize));
} else
__C(File.Write(sText, (DWORD) sText.GetLength()));
}
_ATLCATCHALL()
{
File.Close();
_W(DeleteFile(sPath));
_ATLRETHROW;
}
MessageBeep(MB_OK);
return 0;
}
// COlePropertyPageT, IRoPropertyPageT, IPropertyPage2, IPropertyPage
STDMETHOD(Apply)()
{
_Z4(atlTraceCOM, 4, _T("...\n"));
_ATLTRY
{
//if(!m_ChangeMap.IsEmpty())
{
//CWaitCursor WaitCursor;
//m_ChangeMap.RemoveAll();
SetDirty(FALSE);
}
}
_ATLCATCH(Exception)
{
_C(Exception);
}
return S_OK;
}
};
OBJECT_ENTRY_AUTO(__uuidof(RunEventPropertyPage), CRunEventPropertyPage)
////////////////////////////////////////////////////////////
// CFilterGraphHelper
class ATL_NO_VTABLE CFilterGraphHelper :
public CComObjectRootEx<CComMultiThreadModelNoCS>,
public CComCoClass<CFilterGraphHelper, &__uuidof(FilterGraphHelper)>,
public IProvideClassInfo2Impl<&__uuidof(FilterGraphHelper), &IID_NULL>,
public IDispatchImpl<IFilterGraphHelper>,
public CModuleVersionInformationT<CFilterGraphHelper>
{
public:
enum { IDR = IDR_FILTERGRAPHHELPER };
//DECLARE_REGISTRY_RESOURCEID(IDR)
BEGIN_COM_MAP(CFilterGraphHelper)
COM_INTERFACE_ENTRY(IProvideClassInfo2)
COM_INTERFACE_ENTRY(IProvideClassInfo)
COM_INTERFACE_ENTRY(IFilterGraphHelper)
COM_INTERFACE_ENTRY_IID(__uuidof(IDispatch), IFilterGraphHelper)
COM_INTERFACE_ENTRY(IModuleVersionInformation)
END_COM_MAP()
public:
////////////////////////////////////////////////////////
// CProcessData
class CProcessData
{
public:
CStringW m_sDisplayName;
DWORD m_nIdentifier;
CPath m_sImagePath;
public:
// CProcessData
CProcessData() :
m_nIdentifier(0)
{
}
};
////////////////////////////////////////////////////////
// CPropertyFrameDialog
class CPropertyFrameDialog :
public CDialogImpl<CPropertyFrameDialog>,
public CDialogResize<CPropertyFrameDialog>,
public CDialogWithAcceleratorsT<CPropertyFrameDialog>
{
public:
enum { IDD = IDD_FILTERGRAPHHELPER_PROPERTYFRAME };
BEGIN_MSG_MAP_EX(CPropertyFrameDialog)
//CHAIN_MSG_MAP(CDialogImpl<CPropertyFrameDialog>)
CHAIN_MSG_MAP(CDialogResize<CPropertyFrameDialog>)
MSG_WM_INITDIALOG(OnInitDialog)
MSG_WM_DESTROY(OnDestroy)
MSG_TVN_GETINFOTIP(IDC_FILTERGRAPHHELPER_PROPERTYFRAME_TREE, OnTreeViewGetInfoTip)
MSG_TVN_SELCHANGED(IDC_FILTERGRAPHHELPER_PROPERTYFRAME_TREE, OnTreeViewSelChanged)
MSG_TVN_ITEMEXPANDING(IDC_FILTERGRAPHHELPER_PROPERTYFRAME_TREE, OnTreeViewItemExplanding)
MSG_TVN_DBLCLK(IDC_FILTERGRAPHHELPER_PROPERTYFRAME_TREE, OnTreeViewDblClk)
NOTIFY_HANDLER_EX(IDC_FILTERGRAPHHELPER_PROPERTYFRAME_REFRESH, CRoHyperStatic::NC_ANCHORCLICKED, OnRefreshAnchorClicked)
NOTIFY_HANDLER_EX(IDC_FILTERGRAPHHELPER_PROPERTYFRAME_COPY, CRoHyperStatic::NC_ANCHORCLICKED, OnCopyAnchorClicked)
NOTIFY_HANDLER_EX(IDC_FILTERGRAPHHELPER_PROPERTYFRAME_SAVEAS, CRoHyperStatic::NC_ANCHORCLICKED, OnSaveAsAnchorClicked)
MSG_WM_SYSCOMMAND(OnSysCommand)
COMMAND_ID_HANDLER_EX(IDOK, OnOk)
COMMAND_ID_HANDLER_EX(IDCANCEL, OnCancel)
COMMAND_ID_HANDLER_EX(IDC_FILTERGRAPHHELPER_PROPERTYFRAME_APPLY, OnApply)
COMMAND_ID_HANDLER_EX(IDC_FILTERGRAPHHELPER_PROPERTYFRAME_TREE_WALKUP, OnTreeWalkUp)
COMMAND_ID_HANDLER_EX(IDC_FILTERGRAPHHELPER_ACTION_OPENGSN, OnActionCommand)
COMMAND_ID_HANDLER_EX(IDC_FILTERGRAPHHELPER_ACTION_OPENGE, OnActionCommand)
COMMAND_ID_HANDLER_EX(IDC_FILTERGRAPHHELPER_ACTION_OPENLIST, OnActionCommand)
REFLECT_NOTIFICATIONS()
END_MSG_MAP()
BEGIN_DLGRESIZE_MAP(CPropertyFrameDialog)
DLGRESIZE_CONTROL(IDC_FILTERGRAPHHELPER_PROPERTYFRAME_TREE, DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_FILTERGRAPHHELPER_PROPERTYFRAME_TEXT, DLSZ_SIZE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_FILTERGRAPHHELPER_PROPERTYFRAME_REFRESH, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_FILTERGRAPHHELPER_PROPERTYFRAME_COPY, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_FILTERGRAPHHELPER_PROPERTYFRAME_SAVEAS, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDOK, DLSZ_MOVE_X | DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDCANCEL, DLSZ_MOVE_X | DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_FILTERGRAPHHELPER_PROPERTYFRAME_APPLY, DLSZ_MOVE_X | DLSZ_MOVE_Y)
END_DLGRESIZE_MAP()
public:
////////////////////////////////////////////////////
// CPropertyPageSite
class ATL_NO_VTABLE CPropertyPageSite :
public CComObjectRootEx<CComSingleThreadModel>,
public IPropertyPageSite
{
friend class CPropertyFrameDialog;
public:
BEGIN_COM_MAP(CPropertyPageSite)
COM_INTERFACE_ENTRY(IPropertyPageSite)
END_COM_MAP()
private:
CPropertyFrameDialog* m_pOwner;
CComPtr<IUnknown> m_pUnknown;
CComPtr<IPropertyPage> m_pPropertyPage;
CString m_sTitle;
DWORD m_nStatus;
public:
// CPropertyPageSite
CPropertyPageSite() :
m_pOwner(NULL)
{
}
VOID Initialize(CPropertyFrameDialog* pOwner, IUnknown* pUnknown, IPropertyPage* pPropertyPage)
{
_A(pOwner && pUnknown && pPropertyPage);
_A(!m_pOwner);
m_pOwner = pOwner;
m_pUnknown = pUnknown;
m_pPropertyPage = pPropertyPage;
__C(pPropertyPage->SetObjects(1, &m_pUnknown.p));
PROPPAGEINFO Information;
ZeroMemory(&Information, sizeof Information);
Information.cb = sizeof Information;
__C(pPropertyPage->GetPageInfo(&Information));
CStringW sTitle = Information.pszTitle;
CoTaskMemFree(Information.pszTitle);
CoTaskMemFree(Information.pszDocString);
CoTaskMemFree(Information.pszHelpFile);
m_sTitle = CString(sTitle);
m_nStatus = 0;
__C(pPropertyPage->SetPageSite(this));
}
VOID Terminate()
{
if(m_pPropertyPage)
{
_V(m_pPropertyPage->SetPageSite(NULL));
m_pPropertyPage.Release();
}
m_pUnknown.Release();
m_pOwner = NULL;
}
BOOL IsDirty()
{
return m_nStatus & PROPPAGESTATUS_DIRTY;
}
// IPropertyPageSite
STDMETHOD(OnStatusChange)(DWORD nFlags)
{
_Z4(atlTraceCOM, 4, _T("nFlags 0x%x\n"), nFlags);
m_nStatus = nFlags;
m_pOwner->HandleStatusChange(this);
return S_OK;
}
STDMETHOD(GetLocaleID)(LCID* pLocaleIdentifier)
{
_Z4(atlTraceCOM, 4, _T("...\n"));
pLocaleIdentifier;
return E_NOTIMPL;
}
STDMETHOD(GetPageContainer)(IUnknown** ppUnknown)
{
_Z4(atlTraceCOM, 4, _T("...\n"));
ppUnknown;
return E_NOTIMPL;
}
STDMETHOD(TranslateAccelerator)(MSG* pMessage)
{
_Z4(atlTraceCOM, 4, _T("...\n"));
pMessage;
return E_NOTIMPL;
}
};
////////////////////////////////////////////////////
// CMemoryAllocatorDialog
class CMemoryAllocatorDialog :
public CDialogImpl<CMemoryAllocatorDialog>,
public CDialogResize<CMemoryAllocatorDialog>
{
public:
enum { IDD = IDD_FILTERGRAPHHELPER_MEMORYALLOCATOR };
BEGIN_MSG_MAP_EX(CMemoryAllocatorDialog)
//CHAIN_MSG_MAP(CDialogImpl<CMemoryAllocatorDialog>)
CHAIN_MSG_MAP(CDialogResize<CMemoryAllocatorDialog>)
MSG_WM_INITDIALOG(OnInitDialog)
MSG_LVN_GETDISPINFO(IDC_FILTERGRAPHHELPER_MEMORYALLOCATOR_LIST, OnListViewGetDispInfo)
MSG_LVN_GETINFOTIP(IDC_FILTERGRAPHHELPER_MEMORYALLOCATOR_LIST, OnListViewGetInfoTip)
COMMAND_ID_HANDLER_EX(IDC_FILTERGRAPHHELPER_MEMORYALLOCATOR_REFRESH, OnRefresh)
REFLECT_NOTIFICATIONS()
END_MSG_MAP()
BEGIN_DLGRESIZE_MAP(CMemoryAllocatorDialog)
DLGRESIZE_CONTROL(IDC_FILTERGRAPHHELPER_MEMORYALLOCATOR_LIST, DLSZ_SIZE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_FILTERGRAPHHELPER_MEMORYALLOCATOR_REFRESH, DLSZ_MOVE_Y)
END_DLGRESIZE_MAP()
public:
////////////////////////////////////////////////
// CMemoryAllocatorData
class CMemoryAllocatorData
{
public:
LONG_PTR m_nIdentifier;
CString m_sNames;
HRESULT m_nMemAllocatorResult;
LONG m_nBufferCount;
LONG m_nBufferSize;
LONG m_nBufferAlign;
LONG m_nBufferPrefix;
HRESULT m_nMemAllocatorCallbackTempResult;
LONG m_nFreeBufferCount;
public:
// CMemoryAllocatorData
VOID Initialize(CRoArrayT<CComVariantArray>& Array)
{
SIZE_T nIndex = 0;
__D(nIndex + 2 + 1 + 1 <= Array.GetCount(), E_UNNAMED);
m_nIdentifier = Array[nIndex++].GetAsType(VT_I4).lVal;
m_sNames = Array[nIndex++].GetAsType(VT_BSTR).bstrVal;
m_nMemAllocatorResult = Array[nIndex++].GetAsType(VT_I4).lVal;
if(SUCCEEDED(m_nMemAllocatorResult))
{
__D(nIndex + 4 <= Array.GetCount(), E_UNNAMED);
m_nBufferCount = Array[nIndex++].GetAsType(VT_I4).lVal;
m_nBufferSize = Array[nIndex++].GetAsType(VT_I4).lVal;
m_nBufferAlign = Array[nIndex++].GetAsType(VT_I4).lVal;
m_nBufferPrefix = Array[nIndex++].GetAsType(VT_I4).lVal;
}
m_nMemAllocatorCallbackTempResult = Array[nIndex++].GetAsType(VT_I4).lVal;
if(SUCCEEDED(m_nMemAllocatorCallbackTempResult))
{
__D(nIndex + 1 <= Array.GetCount(), E_UNNAMED);
m_nFreeBufferCount = Array[nIndex++].GetAsType(VT_I4).lVal;
}
}
};
private:
CPropertyFrameDialog* m_pOwner;
BOOL m_bActivating;
CStatic m_TitleStatic;
CFont m_TitleFont;
CRoListViewT<CMemoryAllocatorData, CRoListControlDataTraitsT> m_ListView;
CButton m_RefreshButton;
CRoMapT<INT_PTR, BOOL> m_ChangeMap;
public:
// CMemoryAllocatorDialog
VOID UpdateListView()
{
CWindowRedraw ListViewRedraw(m_ListView);
CRoArrayT<INT> ValidItemArray;
_ATLTRY
{
const CComQIPtr<IFilterGraphMemoryAllocatorData> pFilterGraphMemoryAllocatorData = m_pOwner->m_Owner.m_pFilterGraph;
if(pFilterGraphMemoryAllocatorData)
{
CComVariantArray vValue;
__C(pFilterGraphMemoryAllocatorData->get_Value(&vValue));
if(vValue.vt > VT_NULL)
{
CRoArrayT<CComVariantArray> ItemArray;
vValue.ToElementArray(ItemArray);
for(auto&& vItemValue: ItemArray)
{
CRoArrayT<CComVariantArray> ItemItemArray;
vItemValue.ToElementArray(ItemItemArray);
// SUGG: Reuse existing list view items instead of full list replacement
CMemoryAllocatorData Data;
Data.Initialize(ItemItemArray);
const INT nItem = m_ListView.InsertItem(m_ListView.GetItemCount(), Data);
ValidItemArray.Add(nItem);
}
}
}
}
_ATLCATCHALL()
{
m_ListView.DeleteAllItems();
ValidItemArray.RemoveAll();
_ATLRETHROW;
}
for(INT nItem = m_ListView.GetItemCount() - 1; nItem >= 0; nItem--)
if(!ValidItemArray.FindFirst(nItem))
m_ListView.DeleteItem(nItem);
}
// Window Message Handler
LRESULT OnInitDialog(HWND, LPARAM lParam)
{
m_pOwner = (CPropertyFrameDialog*) lParam;
m_bActivating = TRUE;
_ATLTRY
{
CWaitCursor WaitCursor;
m_TitleStatic = GetDlgItem(IDC_FILTERGRAPHHELPER_MEMORYALLOCATOR_TITLE);
CreateTitleFont(m_TitleFont, m_TitleStatic);
m_ListView.Initialize(GetDlgItem(IDC_FILTERGRAPHHELPER_MEMORYALLOCATOR_LIST));
m_RefreshButton = GetDlgItem(IDC_FILTERGRAPHHELPER_MEMORYALLOCATOR_REFRESH);
DlgResize_Init(FALSE, FALSE);
_ATLTRY
{
UpdateListView();
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
m_bActivating = FALSE;
}
_ATLCATCH(Exception)
{
for(CWindow Window = GetWindow(GW_CHILD); Window; Window = Window.GetWindow(GW_HWNDNEXT))
Window.EnableWindow(FALSE);
AtlExceptionMessageBox(m_hWnd, Exception);
}
return TRUE;
}
LRESULT OnListViewGetDispInfo(NMLVDISPINFO* pHeader)
{
const CMemoryAllocatorData& Data = m_ListView.DataFromParameter(pHeader->item.lParam);
if(pHeader->item.mask & LVIF_TEXT)
{
CString& sTextBuffer = m_ListView.GetTextBufferString(TRUE);
switch(pHeader->item.iSubItem)
{
case 1: // Buffer Count
if(SUCCEEDED(Data.m_nMemAllocatorResult))
sTextBuffer = _StringHelper::FormatNumber(Data.m_nBufferCount);
break;
case 2: // Free Buffer Count
if(SUCCEEDED(Data.m_nMemAllocatorCallbackTempResult))
sTextBuffer = _StringHelper::FormatNumber(Data.m_nFreeBufferCount);
break;
case 3: // Buffer Size
if(SUCCEEDED(Data.m_nMemAllocatorResult))
sTextBuffer = _StringHelper::FormatNumber(Data.m_nBufferSize);
break;
default: // Name
sTextBuffer = Data.m_sNames;
}
pHeader->item.pszText = m_ListView.GetTextBuffer();
}
return 0;
}
LRESULT OnListViewGetInfoTip(NMLVGETINFOTIP* pHeader)
{
const CMemoryAllocatorData& Data = m_ListView.GetItemData(pHeader->iItem);
CString& sTextBuffer = m_ListView.GetTextBufferString(TRUE);
//sTextBuffer.AppendFormat(_T("Identifier: 0x%08X") _T("\r\n"), Data.m_nIdentifier);
if(SUCCEEDED(Data.m_nMemAllocatorResult))
{
sTextBuffer.AppendFormat(_T("Buffer Count: %s") _T("\r\n"), _StringHelper::FormatNumber(Data.m_nBufferCount));
sTextBuffer.AppendFormat(_T("Buffer Size: %s (%s total)") _T("\r\n"), _StringHelper::FormatNumber(Data.m_nBufferSize), _StringHelper::FormatNumber(Data.m_nBufferCount * Data.m_nBufferSize));
if(Data.m_nBufferAlign > 1)
sTextBuffer.AppendFormat(_T("Buffer Alignment: %s") _T("\r\n"), _StringHelper::FormatNumber(Data.m_nBufferAlign));
if(Data.m_nBufferPrefix > 0)
sTextBuffer.AppendFormat(_T("Buffer Prefix: %s") _T("\r\n"), _StringHelper::FormatNumber(Data.m_nBufferPrefix));
} else
sTextBuffer.AppendFormat(_T("IMemAllocator: %s") _T("\r\n"), Ds::FormatResult(Data.m_nMemAllocatorResult, _T("Error 0x%08X")));
if(SUCCEEDED(Data.m_nMemAllocatorCallbackTempResult))
{
sTextBuffer.AppendFormat(_T("Free Buffer Count: %s") _T("\r\n"), _StringHelper::FormatNumber(Data.m_nFreeBufferCount));
} else
sTextBuffer.AppendFormat(_T("IMemAllocatorCallbackTemp: %s") _T("\r\n"), Ds::FormatResult(Data.m_nMemAllocatorCallbackTempResult, _T("Error 0x%08X")));
CString sNames = Data.m_sNames;
sNames.Replace(_T(", "), _T("|"));
CRoArrayT<CString> Array;
_StringHelper::Split(sNames, _T('|'), Array);
if(!Array.IsEmpty())
{
sTextBuffer.Append(_T("\r\n") _T("Pin Connections:") _T("\r\n"));
for(auto&& sName: Array)
{
sTextBuffer.AppendFormat(_T(" ") _T("%s") _T("\r\n"), sName);
}
}
sTextBuffer.TrimRight(_T("\t\n\r ."));
#pragma region Clipboard Copy
if(GetKeyState(VK_CONTROL) < 0 && GetKeyState(VK_SHIFT) < 0)
_ATLTRY
{
SetClipboardText(m_hWnd, sTextBuffer);
MessageBeep(MB_OK);
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
MessageBeep(MB_ICONERROR);
}
#pragma endregion
_tcsncpy_s(pHeader->pszText, pHeader->cchTextMax, m_ListView.GetTextBuffer(), _TRUNCATE);
return 0;
}
LRESULT OnRefresh(UINT, INT, HWND)
{
UpdateListView();
return 0;
}
};
////////////////////////////////////////////////////
// CActionDialog
class CActionDialog :
public CDialogImpl<CActionDialog>,
public CDialogResize<CActionDialog>
{
public:
enum { IDD = IDD_FILTERGRAPHHELPER_ACTION };
BEGIN_MSG_MAP_EX(CActionDialog)
//CHAIN_MSG_MAP(CDialogImpl<CActionDialog>)
CHAIN_MSG_MAP(CDialogResize<CActionDialog>)
MSG_WM_INITDIALOG(OnInitDialog)
COMMAND_ID_HANDLER_EX(IDC_FILTERGRAPHHELPER_ACTION_SAVEAS, OnSaveAs)
COMMAND_ID_HANDLER_EX(IDC_FILTERGRAPHHELPER_ACTION_OPENGSN, OnOpenGsn)
COMMAND_ID_HANDLER_EX(IDC_FILTERGRAPHHELPER_ACTION_OPENGE, OnOpenGe)
COMMAND_ID_HANDLER_EX(IDC_FILTERGRAPHHELPER_ACTION_OPENLIST, OnOpenList)
REFLECT_NOTIFICATIONS()
END_MSG_MAP()
BEGIN_DLGRESIZE_MAP(CActionDialog)
//DLGRESIZE_CONTROL(IDC_FILTERGRAPHHELPER_ACTION_, DLSZ_SIZE_X | DLSZ_SIZE_Y)
END_DLGRESIZE_MAP()
private:
CPropertyFrameDialog* m_pOwner;
BOOL m_bActivating;
CStatic m_TitleStatic;
CFont m_TitleFont;
CButton m_SaveAsButton;
CRoHyperStatic m_SaveAsDescriptionStatic;
CButton m_OpenGsnButton;
CRoHyperStatic m_OpenGsnDescriptionStatic;
CButton m_OpenGeButton;
CRoHyperStatic m_OpenGeDescriptionStatic;
CButton m_OpenListButton;
CRoHyperStatic m_OpenListDescriptionStatic;
CStringW m_sFilterGraphMonikerDisplayName;
CRoMapT<INT_PTR, BOOL> m_ChangeMap;
public:
// CActionDialog
// Window Message Handler
LRESULT OnInitDialog(HWND, LPARAM lParam)
{
m_pOwner = (CPropertyFrameDialog*) lParam;
m_bActivating = TRUE;
_ATLTRY
{
CWaitCursor WaitCursor;
m_TitleStatic = GetDlgItem(IDC_FILTERGRAPHHELPER_ACTION_TITLE);
CreateTitleFont(m_TitleFont, m_TitleStatic);
m_SaveAsButton = GetDlgItem(IDC_FILTERGRAPHHELPER_ACTION_SAVEAS);
_W(m_SaveAsDescriptionStatic.SubclassWindow(GetDlgItem(IDC_FILTERGRAPHHELPER_ACTION_SAVEASDESCRIPTION)));
m_OpenGsnButton = GetDlgItem(IDC_FILTERGRAPHHELPER_ACTION_OPENGSN);
_W(m_OpenGsnDescriptionStatic.SubclassWindow(GetDlgItem(IDC_FILTERGRAPHHELPER_ACTION_OPENGSNDESCRIPTION)));
m_OpenGeButton = GetDlgItem(IDC_FILTERGRAPHHELPER_ACTION_OPENGE);
_W(m_OpenGeDescriptionStatic.SubclassWindow(GetDlgItem(IDC_FILTERGRAPHHELPER_ACTION_OPENGEDESCRIPTION)));
m_OpenListButton = GetDlgItem(IDC_FILTERGRAPHHELPER_ACTION_OPENLIST);
_W(m_OpenListDescriptionStatic.SubclassWindow(GetDlgItem(IDC_FILTERGRAPHHELPER_ACTION_OPENLISTDESCRIPTION)));
//DlgResize_Init(FALSE, FALSE);
_ATLTRY
{
m_sFilterGraphMonikerDisplayName.Empty();
const CComQIPtr<ISpy> pSpy = m_pOwner->m_Owner.GetFilterGraph();
if(pSpy)
{
CComBSTR sFilterGraphMonikerDisplayName;
__C(pSpy->get_MonikerDisplayName(&sFilterGraphMonikerDisplayName));
m_sFilterGraphMonikerDisplayName = sFilterGraphMonikerDisplayName;
}
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
const BOOL bMonikerDisplayNameAvailable = !m_sFilterGraphMonikerDisplayName.IsEmpty();
m_OpenGsnButton.EnableWindow(bMonikerDisplayNameAvailable);
m_OpenGsnDescriptionStatic.EnableWindow(bMonikerDisplayNameAvailable);
m_OpenGeButton.EnableWindow(bMonikerDisplayNameAvailable);
m_OpenGeDescriptionStatic.EnableWindow(bMonikerDisplayNameAvailable);
m_bActivating = FALSE;
}
_ATLCATCH(Exception)
{
for(CWindow Window = GetWindow(GW_CHILD); Window; Window = Window.GetWindow(GW_HWNDNEXT))
Window.EnableWindow(FALSE);
AtlExceptionMessageBox(m_hWnd, Exception);
}
return TRUE;
}
LRESULT OnSaveAs(UINT, INT, HWND)
{
static const COMDLG_FILTERSPEC g_pFilter[] =
{
{ _T("GraphEdit Files"), _T("*.grf") },
{ _T("All Files"), _T("*.*") },
};
CPath sPath = _CommonDialogHelper::QuerySavePath(m_hWnd, g_pFilter, _T("grf"));
if(_tcslen(sPath) == 0)
return 0;
#pragma region Save
// NOTE: See http://msdn.microsoft.com/en-us/library/windows/desktop/dd377551
const CComQIPtr<IPersistStream> pPersistStream = m_pOwner->m_Owner.GetFilterGraph();
__D(pPersistStream, E_NOINTERFACE);
CComPtr<IStorage> pStorage;
{
__C(StgCreateDocfile(CStringW(sPath), STGM_CREATE | STGM_TRANSACTED | STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, &pStorage));
CComPtr<IStream> pStream;
__C(pStorage->CreateStream(L"ActiveMovieGraph", STGM_WRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream));
__C(pPersistStream->Save(pStream, TRUE));
}
__C(pStorage->Commit(STGC_DEFAULT));
#pragma endregion
MessageBeep(MB_OK);
return 0;
}
LRESULT OnOpenGsn(UINT, INT, HWND)
{
OpenMonikerWithGsn(m_sFilterGraphMonikerDisplayName, m_hWnd);
return 0;
}
LRESULT OnOpenGe(UINT, INT, HWND)
{
OpenMonikerWithGe(m_sFilterGraphMonikerDisplayName, m_hWnd);
return 0;
}
LRESULT OnOpenList(UINT, INT, HWND)
{
DoFilterGraphListPropertySheetModal(m_hWnd, &m_pOwner->m_Owner.m_Options);
return 0;
}
};
////////////////////////////////////////////////////
// CEmailLogDialog
class CEmailLogDialog :
public CDialogImpl<CEmailLogDialog>,
public CDialogResize<CEmailLogDialog>
{
public:
enum { IDD = IDD_FILTERGRAPHHELPER_EMAIL_LOG };
BEGIN_MSG_MAP_EX(CEmailLogDialog)
//CHAIN_MSG_MAP(CDialogImpl<CEmailLogDialog>)
CHAIN_MSG_MAP(CDialogResize<CEmailLogDialog>)
MSG_WM_INITDIALOG(OnInitDialog)
MSG_LVN_GETDISPINFO(IDC_FILTERGRAPHHELPER_EMAIL_LOG_FILE, OnFileListViewGetDispInfo)
//MSG_LVN_GETINFOTIP()
MSG_LVN_ITEMCHANGED(IDC_FILTERGRAPHHELPER_EMAIL_LOG_FILE, OnFileListViewItemChanged)
//COMMAND_HANDLER_EX(IDC_FILTERGRAPHHELPER_EMAIL_LOG_TRUNCATE, CBN_CHANGE, OnChanged)
//COMMAND_HANDLER_EX(IDC_FILTERGRAPHHELPER_EMAIL_LOG_DELETE, CBN_CHANGE, OnChanged)
REFLECT_NOTIFICATIONS()
END_MSG_MAP()
BEGIN_DLGRESIZE_MAP(CEmailLogDialog)
DLGRESIZE_CONTROL(IDC_FILTERGRAPHHELPER_EMAIL_LOG_FILE, DLSZ_SIZE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_FILTERGRAPHHELPER_EMAIL_LOG_TRUNCATETITLE, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_FILTERGRAPHHELPER_EMAIL_LOG_TRUNCATE, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_FILTERGRAPHHELPER_EMAIL_LOG_DELETETITLE, DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_FILTERGRAPHHELPER_EMAIL_LOG_DELETE, DLSZ_MOVE_Y)
END_DLGRESIZE_MAP()
public:
////////////////////////////////////////////////
// CFileData
class CFileData
{
public:
UINT m_nLocation;
CPath m_sPath;
ULONGLONG m_nSize;
FILETIME m_UpdateTime;
public:
// CFileData
CFileData(UINT nLocation, LPCTSTR pszDirectory, WIN32_FIND_DATA FindData)
{
m_nLocation = nLocation;
m_sPath.Combine(pszDirectory, FindData.cFileName);
m_nSize = ((ULONGLONG) FindData.nFileSizeHigh << 32) + FindData.nFileSizeLow;
m_UpdateTime = FindData.ftLastWriteTime;
}
FILETIME GetLocalUpdateTime() const
{
FILETIME UpdateTime;
_W(FileTimeToLocalFileTime(&m_UpdateTime, &UpdateTime));
return UpdateTime;
}
};
////////////////////////////////////////////////
// CFileDataSortTraits
class CFileDataSortTraits :
public CDefaultSortTraitsT<CFileData>
{
public:
// CFileDataSortTraits
static INT_PTR CompareElements(const CFileData& FileData1, const CFileData& FileData2, PARAMETERARGUMENT Parameter)
{
const INT nLocation = FileData1.m_nLocation - FileData2.m_nLocation;
if(nLocation)
return nLocation;
return _tcsicmp(FindFileName(FileData1.m_sPath), FindFileName(FileData2.m_sPath));
}
};
////////////////////////////////////////////////
// CFileDataArray
class CFileDataArray :
public CRoArrayT<CFileData>
{
public:
// CFileDataArray
static BOOL CompareLocation(const CFileData& FileData, UINT nLocation)
{
return FileData.m_nLocation == nLocation;
}
SIZE_T GetCountForLocation(UINT nLocation)
{
return GetCountThatT<UINT>(&CFileDataArray::CompareLocation, nLocation);
}
};
////////////////////////////////////////////////
// CSelectedFileData
class CSelectedFileData
{
public:
CPath m_sPath;
CString m_sName;
public:
// CSelectedFileData
};
private:
CPropertyFrameDialog* m_pOwner;
BOOL m_bActivating;
CStatic m_TitleStatic;
CFont m_TitleFont;
CRoListViewT<CFileData, CRoListControlDataTraitsT> m_FileListView;
INT m_nFileListViewGroupViewEnabled;
CRoComboBoxT<> m_TruncateComboBox;
CRoComboBoxT<> m_DeleteComboBox;
CRoMapT<INT_PTR, BOOL> m_ChangeMap;
public:
// CEmailLogDialog
CEmailLogDialog()
{
}
VOID UpdateControls()
{
}
VOID InitializeFileListView()
{
CWindowRedraw FileListViewRedraw(m_FileListView);
m_FileListView.DeleteAllItems();
m_FileListView.RemoveAllGroups();
#pragma region File
CFileDataArray FileDataArray;
static DWORD g_pnLocations[] =
{
CSIDL_COMMON_APPDATA,
CSIDL_APPDATA,
};
for(SIZE_T nLocationIndex = 0; nLocationIndex < DIM(g_pnLocations); nLocationIndex++)
_ATLTRY
{
TCHAR pszDirectory[MAX_PATH] = { 0 };
if(!SHGetSpecialFolderPath(NULL, pszDirectory, g_pnLocations[nLocationIndex], FALSE))
continue;
CFindFiles FindFiles;
for(BOOL bFound = FindFiles.FindFirstFile(pszDirectory, _T("*.*")); bFound; bFound = FindFiles.FindNextFile())
{
const WIN32_FIND_DATA& Data = FindFiles.GetFindData();
if(Data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
continue; // Directory
LPCTSTR pszExtension = FindExtension(Data.cFileName);
if(!pszExtension || !(_tcsicmp(pszExtension, _T(".log")) == 0 || _tcsicmp(pszExtension, _T(".dmp")) == 0))
continue; // Extension Mismatch
FileDataArray.Add(CFileData((UINT) nLocationIndex, pszDirectory, Data));
}
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
_SortHelper::QuickSort<CFileDataSortTraits>(FileDataArray);
if(m_nFileListViewGroupViewEnabled >= 0)
{
if(FileDataArray.GetCountForLocation(0))
m_FileListView.InsertGroup(0, 0, _T("Local Machine (Common AppData)"));
if(FileDataArray.GetCountForLocation(1))
m_FileListView.InsertGroup(1, 1, _T("Current User (AppData)"));
}
CPath sPrivateLogFileName = FindFileName(GetModulePath());
sPrivateLogFileName.RenameExtension(_T(".log"));
for(SIZE_T nIndex = 0; nIndex < FileDataArray.GetCount(); nIndex++)
{
CFileData& FileData = FileDataArray[nIndex];
INT nItem;
if(m_nFileListViewGroupViewEnabled >= 0)
nItem = m_FileListView.InsertGroupItem(m_FileListView.GetItemCount(), FileData.m_nLocation, FileData);
else
nItem = m_FileListView.InsertItem(m_FileListView.GetItemCount(), FileData);
if(_tcsicmp(FindFileName(FileData.m_sPath), sPrivateLogFileName) == 0)
m_FileListView.SetCheckState(nItem, TRUE);
}
}
SIZE_T GetFiles(CRoArrayT<CSelectedFileData>& Array)
{
_A(Array.IsEmpty());
for(INT nItem = 0; nItem < m_FileListView.GetItemCount(); nItem++)
{
if(!m_FileListView.GetCheckState(nItem))
continue;
const CFileData& FileData = m_FileListView.GetItemData(nItem);
CSelectedFileData SelectedFileData;
SelectedFileData.m_sPath = FileData.m_sPath;
CPath sName = FindFileName(FileData.m_sPath);
if(FileData.m_nLocation == 1)
{
CString sExtention = FindExtension(sName);
sName.RemoveExtension();
sName = (LPCTSTR) AtlFormatString(_T("%s (%s)%s"), sName, _T("Current User"), sExtention);
}
SelectedFileData.m_sName = (LPCTSTR) sName;
Array.Add(SelectedFileData);
}
return Array.GetCount();
}
ULONGLONG GetTruncateSize()
{
static const ULONGLONG g_pnTruncateSizes[] =
{
1i64 << 20, // 1 MB
10i64 << 20, // 10 MB
25i64 << 20, // 25 MB
50i64 << 20, // 50 MB
};
const INT nItem = m_TruncateComboBox.GetCurSel();
_A(nItem >= 0 && nItem < DIM(g_pnTruncateSizes));
return g_pnTruncateSizes[nItem];
}
BOOL GetDelete()
{
return m_DeleteComboBox.GetCurSel() == 1;
}
// Window Message Handler
LRESULT OnInitDialog(HWND, LPARAM lParam)
{
m_pOwner = (CPropertyFrameDialog*) lParam;
m_bActivating = TRUE;
_ATLTRY
{
CWaitCursor WaitCursor;
m_TitleStatic = GetDlgItem(IDC_FILTERGRAPHHELPER_EMAIL_LOG_TITLE);
CreateTitleFont(m_TitleFont, m_TitleStatic);
m_FileListView.Initialize(GetDlgItem(IDC_FILTERGRAPHHELPER_EMAIL_LOG_FILE));
m_nFileListViewGroupViewEnabled = m_FileListView.EnableGroupView(TRUE);
if(!m_nFileListViewGroupViewEnabled)
m_nFileListViewGroupViewEnabled = m_FileListView.IsGroupViewEnabled() ? 1 : -1;
m_TruncateComboBox.Initialize(GetDlgItem(IDC_FILTERGRAPHHELPER_EMAIL_LOG_TRUNCATE));
m_DeleteComboBox.Initialize(GetDlgItem(IDC_FILTERGRAPHHELPER_EMAIL_LOG_DELETE));
DlgResize_Init(FALSE, FALSE);
InitializeFileListView();
m_FileListView.SetColumnWidth(3, LVSCW_AUTOSIZE);
m_TruncateComboBox.SetCurSel(2);
m_DeleteComboBox.SetCurSel(0);
UpdateControls();
m_bActivating = FALSE;
}
_ATLCATCH(Exception)
{
for(CWindow Window = GetWindow(GW_CHILD); Window; Window = Window.GetWindow(GW_HWNDNEXT))
Window.EnableWindow(FALSE);
AtlExceptionMessageBox(m_hWnd, Exception);
}
return TRUE;
}
LRESULT OnChanged(UINT, INT_PTR nIdentifier, HWND)
{
if(m_bActivating)
return 0;
m_ChangeMap[nIdentifier] = TRUE;
UpdateControls();
return 0;
}
LRESULT OnChanged(NMHDR* pHeader)
{
return OnChanged(pHeader->code, pHeader->idFrom, pHeader->hwndFrom);
}
LRESULT OnFileListViewGetDispInfo(NMLVDISPINFO* pHeader)
{
const CFileData& FileData = m_FileListView.DataFromParameter(pHeader->item.lParam);
if(pHeader->item.mask & LVIF_TEXT)
{
CString& sTextBuffer = m_FileListView.GetTextBufferString(TRUE);
switch(pHeader->item.iSubItem)
{
case 1: // Size
sTextBuffer = _StringHelper::FormatNumber((LONGLONG) FileData.m_nSize);
break;
case 2: // Update Time
sTextBuffer = _StringHelper::FormatDateTime(FileData.GetLocalUpdateTime());
break;
case 3: // Directory
sTextBuffer = (LPCTSTR) GetPathDirectory(FileData.m_sPath);
break;
default: // File Name
sTextBuffer = FindFileName(FileData.m_sPath);
}
pHeader->item.pszText = m_FileListView.GetTextBuffer();
}
return 0;
}
LRESULT OnFileListViewItemChanged(NMLISTVIEW* pHeader)
{
return m_FileListView.OnReflectedItemChanged(pHeader);
}
};
////////////////////////////////////////////////////
// CEmailDialog
class CEmailDialog :
public CDialogImpl<CEmailDialog>,
public CDialogResize<CEmailDialog>
{
public:
enum { IDD = IDD_FILTERGRAPHHELPER_EMAIL };
BEGIN_MSG_MAP_EX(CEmailDialog)
//CHAIN_MSG_MAP(CDialogImpl<CEmailDialog>)
CHAIN_MSG_MAP(CDialogResize<CEmailDialog>)
MSG_WM_INITDIALOG(OnInitDialog)
MSG_WM_DESTROY(OnDestroy)
MSG_WM_SHOWWINDOW(OnShowWindow)
COMMAND_HANDLER_EX(IDC_FILTERGRAPHHELPER_EMAIL_FROM, EN_CHANGE, OnChanged)
COMMAND_HANDLER_EX(IDC_FILTERGRAPHHELPER_EMAIL_TO, EN_CHANGE, OnChanged)
COMMAND_HANDLER_EX(IDC_FILTERGRAPHHELPER_EMAIL_METHOD, CBN_SELENDOK, OnChanged)
COMMAND_HANDLER_EX(IDC_FILTERGRAPHHELPER_EMAIL_HOST, EN_CHANGE, OnChanged)
COMMAND_HANDLER_EX(IDC_FILTERGRAPHHELPER_EMAIL_USERNAME, EN_CHANGE, OnChanged)
COMMAND_HANDLER_EX(IDC_FILTERGRAPHHELPER_EMAIL_PASSWORD, EN_CHANGE, OnChanged)
COMMAND_HANDLER_EX(IDC_FILTERGRAPHHELPER_EMAIL_BODY, EN_CHANGE, OnChanged)
COMMAND_ID_HANDLER_EX(IDC_FILTERGRAPHHELPER_EMAIL_SEND, OnSend)
NOTIFY_HANDLER_EX(IDC_FILTERGRAPHHELPER_EMAIL_CLEANUP, CRoHyperStatic::NC_ANCHORCLICKED, OnCleanupStaticAnchorClicked)
REFLECT_NOTIFICATIONS()
ALT_MSG_MAP(IDC_FILTERGRAPHHELPER_EMAIL_FROM)
MSG_WM_PASTE(OnFromEditPaste)
END_MSG_MAP()
BEGIN_DLGRESIZE_MAP(CEmailDialog)
DLGRESIZE_CONTROL(IDC_FILTERGRAPHHELPER_EMAIL_BODY, DLSZ_SIZE_X | DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_FILTERGRAPHHELPER_EMAIL_SEND, DLSZ_MOVE_X | DLSZ_MOVE_Y)
DLGRESIZE_CONTROL(IDC_FILTERGRAPHHELPER_EMAIL_CLEANUP, DLSZ_MOVE_Y)
END_DLGRESIZE_MAP()
private:
CPropertyFrameDialog* m_pOwner;
BOOL m_bActivating;
CStatic m_TitleStatic;
CFont m_TitleFont;
CContainedWindowT<CRoEdit> m_FromEdit;
CRoEdit m_ToEdit;
CRoComboBoxT<> m_MethodComboBox;
CRoEdit m_HostEdit;
CRoEdit m_UsernameEdit;
CRoEdit m_PasswordEdit;
CRoEdit m_BodyEdit;
CButton m_SendButton;
CRoHyperStatic m_CleanupStatic;
CString m_sFilterGraphText;
CRoMapT<INT_PTR, BOOL> m_ChangeMap;
public:
// CEmailDialog
CEmailDialog() :
m_FromEdit(this, IDC_FILTERGRAPHHELPER_EMAIL_FROM)
{
}
BOOL InitializeControlsFromMessageString(const CString& sMessageString)
{
_ATLTRY
{
CObjectPtr<CMessage> pMessage;
pMessage.Construct();
pMessage->LoadTypeInfo(IDR_EMAILTOOLS);
pMessage->SetAsString(CStringA(sMessageString));
#pragma region Sender and Recipients
CComBSTR sSender, sToRecipients;
__C(pMessage->get_Sender(&sSender));
__C(pMessage->get_ToRecipients(&sToRecipients));
m_FromEdit.SetValue(CString(sSender));
m_ToEdit.SetValue(CString(sToRecipients));
#pragma endregion
CComBSTR sAuthMethods;
__C(pMessage->get_AuthMethods(&sAuthMethods));
VARIANT_BOOL bSecureSocketsLayer, bTransportLayerSecurity;
__C(pMessage->get_SecureSocketsLayer(&bSecureSocketsLayer));
__C(pMessage->get_TransportLayerSecurity(&bTransportLayerSecurity));
#pragma region Host and Port
CComBSTR sHost;
__C(pMessage->get_ServerHost(&sHost));
LONG nPort = 0;
__C(pMessage->get_ServerPort(&nPort));
CString sHostT(sHost);
if(nPort)
sHostT += AtlFormatString(_T(":%d"), nPort);
m_HostEdit.SetValue(sHostT);
#pragma endregion
#pragma region User Name and Password
CComBSTR sAuthName, sAuthPassword;
__C(pMessage->get_AuthName(&sAuthName));
__C(pMessage->get_AuthPassword(&sAuthPassword));
m_UsernameEdit.SetValue(CString(sAuthName));
m_PasswordEdit.SetValue(CString(sAuthPassword));
#pragma endregion
m_MethodComboBox.SetCurSel(0);
if(bTransportLayerSecurity != ATL_VARIANT_FALSE && sHostT.CompareNoCase(_T("smtp.gmail.com")) == 0)
{
//m_MethodComboBox.SetCurSel(0);
} else
{
if(bTransportLayerSecurity != ATL_VARIANT_FALSE)
m_MethodComboBox.SetCurSel(1);
else if(bSecureSocketsLayer != ATL_VARIANT_FALSE)
m_MethodComboBox.SetCurSel(2);
else if(CString(sAuthMethods).CompareNoCase(_T("cram-md5")) == 0)
m_MethodComboBox.SetCurSel(3);
else if(!CString(sAuthName).IsEmpty())
m_MethodComboBox.SetCurSel(4);
else
m_MethodComboBox.SetCurSel(5);
}
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
return FALSE;
}
return TRUE;
}
VOID InitializeControlsFromRegistry()
{
const CString sMessageString = _RegKeyHelper::QueryStringValue(HKEY_CURRENT_USER, REGISTRY_ROOT, _T("Email Message Template"));
if(sMessageString.IsEmpty())
return;
InitializeControlsFromMessageString(sMessageString);
}
VOID InitializeBody()
{
CString sText;
sText += _T("(add notes here; graph data will be appended below)") _T("\r\n") _T("\r\n");
sText += _T("* * *") _T("\r\n") _T("\r\n");
#define I FormatIdentifier
#pragma region System
{
sText += _T("# System") _T("\r\n") _T("\r\n");
OSVERSIONINFOEX Version;
ZeroMemory(&Version, sizeof Version);
Version.dwOSVersionInfoSize = sizeof Version;
#pragma warning(disable: 4996) // 'GetVersionExW': was declared deprecated
GetVersionEx((OSVERSIONINFO*) &Version);
#pragma warning(default: 4996)
#pragma region Version
CRoArrayT<CString> VersionArray;
VersionArray.Add(AtlFormatString(_T("%s Build %s"), I(AtlFormatString(_T("%d.%d"), Version.dwMajorVersion, Version.dwMinorVersion)), I(Version.dwBuildNumber)));
switch((Version.dwMajorVersion << 16) + Version.dwMinorVersion)
{
case 0x00050001:
VersionArray.Add(_T("Windows XP"));
break;
case 0x00050002:
if(Version.wProductType != VER_NT_WORKSTATION)
VersionArray.Add(_T("Windows Server 2003"));
break;
case 0x00060000:
if(Version.wProductType == VER_NT_WORKSTATION)
VersionArray.Add(_T("Windows Vista"));
else
VersionArray.Add(_T("Windows Server 2008"));
break;
case 0x00060001:
if(Version.wProductType == VER_NT_WORKSTATION)
VersionArray.Add(_T("Windows 7"));
else
VersionArray.Add(_T("Windows Server 2008 R2"));
break;
case 0x00060002:
if(Version.wProductType == VER_NT_WORKSTATION)
VersionArray.Add(_T("Windows 8"));
else
VersionArray.Add(_T("Windows Server 2012"));
break;
}
if(_tcslen(Version.szCSDVersion))
VersionArray.Add(Version.szCSDVersion);
if(Version.wServicePackMajor)
VersionArray.Add(AtlFormatString(_T("Service Pack %s"), I(AtlFormatString(_T("%d.%d"), Version.wServicePackMajor, Version.wServicePackMinor))));
//Version.wSuiteMask, Version.wProductType
sText += AtlFormatString(_T(" * ") _T("Version: %s") _T("\r\n"), _StringHelper::Join(VersionArray, _T("; ")));
#pragma endregion
sText += AtlFormatString(_T(" * ") _T("Computer Name: %s") _T("\r\n"), I(GetComputerName()));
TCHAR pszUserName[256] = { 0 };
DWORD nUserNameLength = DIM(pszUserName);
GetUserName(pszUserName, &nUserNameLength);
CString sUserName(pszUserName);
BOOL bAdministrator = FALSE;
bool bIsMember = FALSE;
if(CAccessToken().CheckTokenMembership(Sids::Admins(), &bIsMember) && bIsMember)
bAdministrator = TRUE;
sText += AtlFormatString(_T(" * ") _T("User Name: %s %s") _T("\r\n"), I(sUserName), bAdministrator ? _T("(Administrator)") : _T(""));
SYSTEM_INFO SystemInformation;
GetSystemInfo(&SystemInformation);
#pragma region Architecture
CString sArchitecture;
switch(SystemInformation.wProcessorArchitecture)
{
case PROCESSOR_ARCHITECTURE_INTEL:
sArchitecture = I(_T("x86"));
break;
case PROCESSOR_ARCHITECTURE_AMD64:
sArchitecture = I(_T("AMD/Intel x64"));
break;
case PROCESSOR_ARCHITECTURE_IA64:
sArchitecture = I(_T("Intel Itanium"));
break;
default:
sArchitecture = I(SystemInformation.wProcessorArchitecture, _T("0x%04X"));
}
#if defined(_WIN64)
sText += AtlFormatString(_T(" * ") _T("Architecture: %s (x64 Application)") _T("\r\n"), sArchitecture);
#else
sText += AtlFormatString(_T(" * ") _T("Architecture: %s") _T("\r\n"), sArchitecture);
#endif // defined(_WIN64)
#pragma endregion
sText += AtlFormatString(_T(" * ") _T("Processors: %s, Active Mask %s") _T("\r\n"), I(SystemInformation.dwNumberOfProcessors), I((DWORD) SystemInformation.dwActiveProcessorMask, _T("0x%X")));
sText += AtlFormatString(_T(" * ") _T("Page Size: %s") _T("\r\n"), I(SystemInformation.dwPageSize, _T("0x%X")));
sText += AtlFormatString(_T(" * ") _T("Application Address Space: %s..%s") _T("\r\n"), I(SystemInformation.lpMinimumApplicationAddress), I(SystemInformation.lpMaximumApplicationAddress));
#pragma region Memory
MEMORYSTATUSEX MemoryStatus = { sizeof MemoryStatus };
_W(GlobalMemoryStatusEx(&MemoryStatus));
sText += AtlFormatString(_T(" * ") _T("Physical Memory: %s MB") _T("\r\n"), I(_StringHelper::FormatNumber((LONG) (MemoryStatus.ullTotalPhys >> 20))));
sText += AtlFormatString(_T(" * ") _T("Committed Memory Limit: %s MB") _T("\r\n"), I(_StringHelper::FormatNumber((LONG) (MemoryStatus.ullTotalPageFile >> 20))));
#pragma endregion
}
#pragma endregion
sText += AtlFormatString(_T(" * ") _T("Module Version: %s") _T("\r\n"), I(_VersionInfoHelper::GetVersionString(_VersionInfoHelper::GetFileVersion(_VersionInfoHelper::GetModulePath()))));
SYSTEMTIME LocalTime;
GetLocalTime(&LocalTime);
sText += AtlFormatString(_T(" * ") _T("Local Time: %s") _T("\r\n"), I(_StringHelper::FormatDateTime(&LocalTime)));
sText += _T("\r\n");
#undef I
m_BodyEdit.SetValue(sText);
}
VOID UpdateControls()
{
BOOL bAllowSend = TRUE;
if(m_ToEdit.GetValue().Trim().IsEmpty())
bAllowSend = FALSE;
const INT nMethod = m_MethodComboBox.GetCurSel();
m_HostEdit.GetWindow(GW_HWNDPREV).EnableWindow(nMethod != 0); // Google Mail
m_HostEdit.EnableWindow(nMethod != 0); // Google Mail
m_UsernameEdit.GetWindow(GW_HWNDPREV).EnableWindow(nMethod != 5); // No Authentication
m_UsernameEdit.EnableWindow(nMethod != 5); // No Authentication
m_PasswordEdit.GetWindow(GW_HWNDPREV).EnableWindow(nMethod != 5); // No Authentication
m_PasswordEdit.EnableWindow(nMethod != 5); // No Authentication
if(nMethod != 0) // Google Mail
if(m_HostEdit.GetValue().Trim().IsEmpty())
bAllowSend = FALSE;
if(nMethod != 5) // No Authentication
{
if(m_UsernameEdit.GetValue().Trim().IsEmpty())
bAllowSend = FALSE;
if(m_PasswordEdit.GetValue().Trim().IsEmpty())
bAllowSend = FALSE;
}
m_SendButton.EnableWindow(bAllowSend);
}
static CString GetComputerName()
{
TCHAR pszComputerName[256] = { 0 };
DWORD nComputerNameLength = DIM(pszComputerName);
::GetComputerName(pszComputerName, &nComputerNameLength);
return pszComputerName;
}
// Window Message Handler
LRESULT OnInitDialog(HWND, LPARAM lParam)
{
m_pOwner = (CPropertyFrameDialog*) lParam;
m_bActivating = TRUE;
_ATLTRY
{
CWaitCursor WaitCursor;
m_TitleStatic = GetDlgItem(IDC_FILTERGRAPHHELPER_EMAIL_TITLE);
CreateTitleFont(m_TitleFont, m_TitleStatic);
_W(m_FromEdit.SubclassWindow(GetDlgItem(IDC_FILTERGRAPHHELPER_EMAIL_FROM)));
m_ToEdit = GetDlgItem(IDC_FILTERGRAPHHELPER_EMAIL_TO);
m_MethodComboBox.Initialize(GetDlgItem(IDC_FILTERGRAPHHELPER_EMAIL_METHOD));
m_MethodComboBox.SetCurSel(0);
m_HostEdit = GetDlgItem(IDC_FILTERGRAPHHELPER_EMAIL_HOST);
m_UsernameEdit = GetDlgItem(IDC_FILTERGRAPHHELPER_EMAIL_USERNAME);
m_PasswordEdit = GetDlgItem(IDC_FILTERGRAPHHELPER_EMAIL_PASSWORD);
m_BodyEdit = GetDlgItem(IDC_FILTERGRAPHHELPER_EMAIL_BODY);
m_BodyEdit.SetFont(m_pOwner->m_TextFont);
m_SendButton = GetDlgItem(IDC_FILTERGRAPHHELPER_EMAIL_SEND);
_W(m_CleanupStatic.SubclassWindow(GetDlgItem(IDC_FILTERGRAPHHELPER_EMAIL_CLEANUP)));
DlgResize_Init(FALSE, FALSE);
InitializeControlsFromRegistry();
InitializeBody();
m_sFilterGraphText = m_pOwner->m_Owner.GetText();
UpdateControls();
m_bActivating = FALSE;
}
_ATLCATCH(Exception)
{
for(CWindow Window = GetWindow(GW_CHILD); Window; Window = Window.GetWindow(GW_HWNDNEXT))
Window.EnableWindow(FALSE);
AtlExceptionMessageBox(m_hWnd, Exception);
}
return TRUE;
}
LRESULT OnDestroy()
{
return 0;
}
LRESULT OnShowWindow(BOOL bShowing, INT)
{
if(bShowing && !m_ChangeMap.Lookup(IDC_FILTERGRAPHHELPER_EMAIL_BODY))
InitializeBody();
return 0;
}
LRESULT OnChanged(UINT, INT_PTR nIdentifier, HWND)
{
if(m_bActivating)
return 0;
m_ChangeMap[nIdentifier] = TRUE;
UpdateControls();
return 0;
}
LRESULT OnChanged(NMHDR* pHeader)
{
return OnChanged(pHeader->code, pHeader->idFrom, pHeader->hwndFrom);
}
LRESULT OnFromEditPaste()
{
_ATLTRY
{
CString sText;
if(GetClipboardText(m_hWnd, sText))
{
const INT nLength = sText.GetLength();
if(nLength >= 128 && nLength < 8192)
{
sText.Trim();
const BOOL bResult = InitializeControlsFromMessageString(sText);
UpdateControls();
if(bResult)
return 0;
}
}
}
_ATLCATCHALL()
{
MessageBeep(MB_ICONERROR);
}
return 0;
}
LRESULT OnSend(UINT, INT, HWND)
{
CWaitCursor WaitCursor;
CObjectPtr<CMessage> pMessage;
pMessage.Construct();
#pragma region Setup
pMessage->LoadTypeInfo(IDR_EMAILTOOLS);
__C(pMessage->put_Sender(CComBSTR(m_FromEdit.GetValue())));
__C(pMessage->put_ToRecipients(CComBSTR(m_ToEdit.GetValue())));
// NOTE:
// 0 Google Mail (SMTP, TLS Connection)
// 1 SMTP, TLS Connection, Plain Text Authentication (TLS, PLAIN)
// 2 SMTP, SSL Connection, Plain Text Authentication (SSL, PLAIN)
// 3 SMTP, Digest Authentication (CRAM-MD5)
// 4 SMTP, Plain Text Authentication (PLAIN)
// 5 SMTP, No Authentication
const INT nMethod = m_MethodComboBox.GetCurSel();
__C(pMessage->put_SecureSocketsLayer((nMethod == 2) ? ATL_VARIANT_TRUE : ATL_VARIANT_FALSE));
__C(pMessage->put_TransportLayerSecurity((nMethod < 2) ? ATL_VARIANT_TRUE : ATL_VARIANT_FALSE));
if(nMethod != 5)
{
__C(pMessage->put_AuthMethods(CComBSTR(_T("plain"))));
__C(pMessage->put_AuthName(CComBSTR(m_UsernameEdit.GetValue())));
__C(pMessage->put_AuthPassword(CComBSTR(m_PasswordEdit.GetValue())));
}
switch(nMethod)
{
case 0:
__C(pMessage->put_ServerHost(CComBSTR(_T("smtp.gmail.com"))));
break;
default:
CString sHost = m_HostEdit.GetValue();
sHost.Trim();
const INT nPortPosition = sHost.Find(_T(":"));
if(nPortPosition >= 0)
{
INT nPort;
__D(AtlStringToInteger(sHost.Mid(nPortPosition + 1), nPort), E_UNNAMED);
__C(pMessage->put_ServerPort(nPort));
sHost = sHost.Left(nPortPosition);
}
__C(pMessage->put_ServerHost(CComBSTR(sHost)));
break;
}
switch(nMethod)
{
case 3:
__C(pMessage->put_AuthMethods(CComBSTR(_T("cram-md5"))));
break;
}
#pragma endregion
CStringA sMessageString = pMessage->GetAsString();
CString sText = m_BodyEdit.GetValue();
sText.TrimRight(_T("\t\n\r "));
sText += _T("\r\n") _T("\r\n") _T("* * *") _T("\r\n") _T("\r\n");
sText += m_sFilterGraphText;
__C(pMessage->put_Body(CComBSTR(sText)));
CString sSubject = AtlFormatString(_T("DirectShow Filter Graph from %s by %s"), GetComputerName(), AtlLoadString(IDS_PROJNAME));
__C(pMessage->put_Subject(CComBSTR(sSubject)));
#pragma region Attachment
CRoArrayT<CPath> DeletePathArray;
CRoArrayT<CString> FailurePathArray;
{
CEmailLogDialog& EmailLogDialog = m_pOwner->m_EmailLogDialog;
CRoArrayT<CEmailLogDialog::CSelectedFileData> Array;
if(EmailLogDialog.GetFiles(Array))
{
const ULONGLONG nTruncateSize = EmailLogDialog.GetTruncateSize();
const BOOL bDelete = EmailLogDialog.GetDelete();
for(SIZE_T nIndex = 0; nIndex < Array.GetCount(); nIndex++)
{
CEmailLogDialog::CSelectedFileData& FileData = Array[nIndex];
_ATLTRY
{
CLocalObjectPtr<CBzip2Item> pItem;
pItem->LoadFromFile(FileData.m_sPath, nTruncateSize);
CHeapPtr<BYTE> pnData;
SIZE_T nDataSize;
pItem->GetData(pnData, nDataSize);
if(nDataSize)
{
CObjectPtr<CMessage::CComAttachment> pAttachment = pMessage->GetAttachments()->Add();
_ATLTRY
{
pAttachment->SetType(L"application/bzip2");
pAttachment->SetDisposition(L"attachment");
pAttachment->SetName(CStringW(FileData.m_sName + _T(".bz2")));
CLocalObjectPtr<CUnmanagedMemoryStream> pStream;
pStream->Initialize(pnData, nDataSize);
pAttachment->LoadFromStream(pStream);
}
_ATLCATCHALL()
{
_V(pMessage->GetAttachments()->Remove(pAttachment));
_ATLRETHROW;
}
}
if(bDelete)
DeletePathArray.Add(FileData.m_sPath);
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
FailurePathArray.Add((LPCTSTR) FileData.m_sPath);
}
}
}
}
#pragma endregion
__C(pMessage->Send());
for(SIZE_T nIndex = 0; nIndex < DeletePathArray.GetCount(); nIndex++)
DeleteFile(DeletePathArray[nIndex]);
_RegKeyHelper::SetStringValue(HKEY_CURRENT_USER, REGISTRY_ROOT, _T("Email Message Template"), CString(sMessageString));
if(!FailurePathArray.IsEmpty())
{
const CString sMessage = AtlFormatString(_T("It was unable to attach the following files:") _T("\r\n\r\n") _T("%s"), _StringHelper::Join(FailurePathArray, _T("\r\n")));
AtlMessageBoxEx(m_hWnd, (LPCTSTR) sMessage, IDS_WARNING, MB_ICONWARNING | MB_OK);
}
AtlOptionalMessageBoxEx(m_hWnd, _T("CFilterGraphHelper::CPropertyFrameDialog::CEmailDialog::CredentialsSaved"), _T("The email was sent.") _T("\r\n\r\n") _T("The credentials were written into registry for further reuse. Use Erase Cached Credentials link to delete them from registry."), IDS_INFORMATION, MB_ICONINFORMATION | MB_OK);
MessageBeep(MB_OK);
return 0;
}
LRESULT OnCleanupStaticAnchorClicked(NMHDR*)
{
_RegKeyHelper::DeleteValue(HKEY_CURRENT_USER, REGISTRY_ROOT, _T("Email Message Template"));
AtlOptionalMessageBoxEx(m_hWnd, _T("CFilterGraphHelper::CPropertyFrameDialog::CEmailDialog::SavedCredentialsDeleted"), _T("Cached email credentials were removed from registry."), IDS_INFORMATION, MB_ICONINFORMATION | MB_OK);
MessageBeep(MB_OK);
return 0;
}
};
////////////////////////////////////////////////////
// CData
class CData
{
public:
/////////////////////////////////////////////////////////
// TYPE
typedef enum _TYPE
{
TYPE_UNKNOWN = 0,
TYPE_FILTERS,
TYPE_FILTER,
TYPE_FILTERPROPERTYPAGE,
TYPE_SERVICES,
TYPE_SERVICEPROPERTYPAGE,
TYPE_MEMORYALLOCATOR,
TYPE_ACTION,
TYPE_EMAIL,
TYPE_EMAIL_LOG,
} TYPE;
public:
TYPE m_Type;
CComPtr<IBaseFilter> m_pBaseFilter;
CLSID m_BaseFilterClassIdentifier;
CString m_sBaseFilterClassDescription;
CString m_sBaseFilterModulePath;
CLSID m_PropertyPageClassIdentifier;
CComPtr<IPropertyPage> m_pPropertyPage;
CObjectPtr<CPropertyPageSite> m_pSite;
BOOL m_bSiteActivated;
public:
// CData
CData(TYPE Type = TYPE_UNKNOWN) :
m_Type(Type),
m_BaseFilterClassIdentifier(CLSID_NULL),
m_PropertyPageClassIdentifier(CLSID_NULL)
{
}
CData(IBaseFilter* pBaseFilter) :
m_Type(TYPE_FILTER),
m_pBaseFilter(pBaseFilter),
m_BaseFilterClassIdentifier(CLSID_NULL),
m_PropertyPageClassIdentifier(CLSID_NULL)
{
_ATLTRY
{
CLSID ClassIdentifier = CLSID_NULL;
if(SUCCEEDED(pBaseFilter->GetClassID(&ClassIdentifier)) && ClassIdentifier != CLSID_NULL)
{
m_BaseFilterClassIdentifier = ClassIdentifier;
const CString sClassIdentifier(_PersistHelper::StringFromIdentifier(ClassIdentifier));
m_sBaseFilterClassDescription = _RegKeyHelper::QueryStringValue(HKEY_CLASSES_ROOT, AtlFormatString(_T("CLSID\\%s"), sClassIdentifier));
m_sBaseFilterModulePath = _RegKeyHelper::QueryStringValue(HKEY_CLASSES_ROOT, AtlFormatString(_T("CLSID\\%s\\InprocServer32"), sClassIdentifier));
}
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
}
CData(IBaseFilter* pBaseFilter, const CLSID& PropertyPageClassIdentifier, IPropertyPage* pPropertyPage) :
m_Type(TYPE_FILTERPROPERTYPAGE),
m_pBaseFilter(pBaseFilter),
m_BaseFilterClassIdentifier(CLSID_NULL),
m_PropertyPageClassIdentifier(PropertyPageClassIdentifier),
m_pPropertyPage(pPropertyPage),
m_bSiteActivated(FALSE)
{
_A(pPropertyPage);
}
CData(IPropertyPage* pPropertyPage) :
m_Type(TYPE_SERVICEPROPERTYPAGE),
m_BaseFilterClassIdentifier(CLSID_NULL),
m_PropertyPageClassIdentifier(CLSID_NULL),
m_pPropertyPage(pPropertyPage),
m_bSiteActivated(FALSE)
{
_A(pPropertyPage);
}
CString GetPropertyPageTitle() const
{
if(!m_pPropertyPage)
return _T("");
PROPPAGEINFO PageInformation;
ZeroMemory(&PageInformation, sizeof PageInformation);
PageInformation.cb = sizeof PageInformation;
__C(m_pPropertyPage->GetPageInfo(&PageInformation));
CString sTitle(PageInformation.pszTitle);
CoTaskMemFree(PageInformation.pszTitle);
CoTaskMemFree(PageInformation.pszDocString);
CoTaskMemFree(PageInformation.pszHelpFile);
return sTitle;
}
};
////////////////////////////////////////////////////
// CObjectPropertyPage
class CObjectPropertyPage
{
public:
CComPtr<IUnknown> m_pUnknown;
CComPtr<IPropertyPage> m_pPropertyPage;
public:
// CObjectPropertyPage
CObjectPropertyPage()
{
}
CObjectPropertyPage(IUnknown* pUnknown, IPropertyPage* pPropertyPage) :
m_pUnknown(pUnknown),
m_pPropertyPage(pPropertyPage)
{
}
};
typedef CRoArrayT<CObjectPropertyPage> CObjectPropertyPageArray;
private:
CFilterGraphHelper& m_Owner;
BOOL m_bActivating;
CRoTreeViewT<CData, CRoListControlDataTraitsT> m_TreeView;
CTreeItem m_FiltersItem;
CTreeItem m_MemoryAllocatorItem;
CTreeItem m_ActionItem;
CTreeItem m_EmailItem;
CTreeItem m_EmailLogItem;
CTabCtrl m_Tab;
CRoEdit m_TextEdit;
CRect m_TextPosition;
CFont m_TextFont;
CRoHyperStatic m_RefreshStatic;
CRoHyperStatic m_CopyStatic;
CRoHyperStatic m_SaveAsStatic;
CButton m_OkButton;
CButton m_CancelButton;
CButton m_ApplyButton;
CObjectPtr<CPropertyPageSite> m_pCurrentSite;
CMemoryAllocatorDialog m_MemoryAllocatorDialog;
CActionDialog m_ActionDialog;
CEmailDialog m_EmailDialog;
CEmailLogDialog m_EmailLogDialog;
static VOID CreateTitleFont(CFont& Font, HWND hStaticWindow = NULL)
{
_A(!Font);
CLogFont LogFont;
LogFont.SetHeight(12);
LogFont.lfWeight = FW_BOLD;
_tcsncpy_s(LogFont.lfFaceName, _T("Verdana"), _TRUNCATE);
_W(Font.CreateFontIndirect(&LogFont));
if(hStaticWindow)
CStatic(hStaticWindow).SetFont(Font);
}
VOID ShowText(BOOL bVisible, BOOL bStaticVisible = FALSE)
{
m_TextEdit.ShowWindow(bVisible ? SW_SHOW : SW_HIDE);
bStaticVisible &= bVisible;
m_RefreshStatic.ShowWindow(bStaticVisible ? SW_SHOW : SW_HIDE);
m_CopyStatic.ShowWindow(bStaticVisible ? SW_SHOW : SW_HIDE);
m_SaveAsStatic.ShowWindow(bStaticVisible ? SW_SHOW : SW_HIDE);
}
public:
// CPropertyFrameDialog
CPropertyFrameDialog(CFilterGraphHelper* pOwner) :
m_Owner(*pOwner)
{
}
CRect GetTextEditPosition() const
{
CRect Position;
_W(m_TextEdit.GetWindowRect(Position));
_W(ScreenToClient(Position));
return Position;
}
VOID UpdateTree()
{
CWindowRedraw TreeViewRedraw(m_TreeView);
m_TreeView.DeleteAllItems();
CTreeItem LastItem;
#pragma region Filter
CTreeItem FiltersItem = m_TreeView.InsertItem(NULL, NULL, CData(CData::TYPE_FILTERS), _T("Filters"));
_FilterGraphHelper::CFilterArray FilterArray;
_FilterGraphHelper::GetGraphFilters(m_Owner.m_pFilterGraph, FilterArray);
CTreeItem PreviousFilterItem;
for(SIZE_T nIndex = 0; nIndex < FilterArray.GetCount(); nIndex++)
{
const CComPtr<IBaseFilter>& pBaseFilter = FilterArray[nIndex];
CData Data(pBaseFilter);
CString sText(_FilterGraphHelper::GetFilterName(pBaseFilter));
if(!Data.m_sBaseFilterClassDescription.IsEmpty() && sText.Find(Data.m_sBaseFilterClassDescription) < 0)
sText += AtlFormatString(_T(" (%s)"), Data.m_sBaseFilterClassDescription);
CTreeItem FilterItem = m_TreeView.InsertItem(FiltersItem, PreviousFilterItem, Data, sText);
PreviousFilterItem = FilterItem;
#pragma region Property Page
const CComQIPtr<ISpecifyPropertyPages> pSpecifyPropertyPages = pBaseFilter;
if(!pSpecifyPropertyPages)
continue;
_ATLTRY
{
CAUUID Pages;
ZeroMemory(&Pages, sizeof Pages);
__C(pSpecifyPropertyPages->GetPages(&Pages));
CComHeapPtr<CLSID> pClassIdentifiers;
pClassIdentifiers.Attach(Pages.pElems);
CTreeItem PreviousPageItem;
for(UINT nPageIndex = 0; nPageIndex < Pages.cElems; nPageIndex++)
{
const CLSID& ClassIdentifier = pClassIdentifiers[nPageIndex];
if(ClassIdentifier == CLSID_NULL)
continue; // Fake
_ATLTRY
{
CComPtr<IPropertyPage> pPropertyPage;
const HRESULT nCoCreateInstanceResult = pPropertyPage.CoCreateInstance(ClassIdentifier);
_A(SUCCEEDED(nCoCreateInstanceResult) || nCoCreateInstanceResult == REGDB_E_CLASSNOTREG);
if(nCoCreateInstanceResult == REGDB_E_CLASSNOTREG)
continue; // Missing [Optional] Page
__C(nCoCreateInstanceResult);
CData Data(pBaseFilter, ClassIdentifier, pPropertyPage);
Data.m_pSite.Construct()->Initialize(this, pBaseFilter, pPropertyPage);
CTreeItem PageItem = m_TreeView.InsertItem(FilterItem, PreviousPageItem, Data, Data.GetPropertyPageTitle());
PreviousPageItem = PageItem;
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
}
m_TreeView.Expand(FilterItem);
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
#pragma endregion
}
m_TreeView.Expand(FiltersItem);
m_FiltersItem.m_hTreeItem = FiltersItem;
m_FiltersItem.m_pTreeView = &m_TreeView;
LastItem = FiltersItem;
#pragma endregion
#pragma region Services
_ATLTRY
{
CObjectPropertyPageArray ObjectPropertyPageArray;
const CComQIPtr<IServiceProvider> pServiceProvider = m_Owner.m_pFilterGraph;
if(pServiceProvider)
{
#pragma region RunPropertyBagAware
CComPtr<IRunPropertyBagAware> pRunPropertyBagAware;
if(SUCCEEDED(pServiceProvider->QueryService<IRunPropertyBagAware>(__uuidof(IRunPropertyBagAware), &pRunPropertyBagAware)))
_ATLTRY
{
_A(pRunPropertyBagAware);
CObjectPtr<CRunPropertyBagPropertyPage> pRunPropertyBagPropertyPage;
pRunPropertyBagPropertyPage.Construct();
ObjectPropertyPageArray.Add(CObjectPropertyPage(pRunPropertyBagAware, pRunPropertyBagPropertyPage));
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
#pragma endregion
#pragma region RunEventAware
CComPtr<IRunEventAware> pRunEventAware;
if(SUCCEEDED(pServiceProvider->QueryService<IRunEventAware>(__uuidof(IRunEventAware), &pRunEventAware)))
_ATLTRY
{
_A(pRunEventAware);
CObjectPtr<CRunEventPropertyPage> pRunEventPropertyPage;
pRunEventPropertyPage.Construct();
ObjectPropertyPageArray.Add(CObjectPropertyPage(pRunEventAware, pRunEventPropertyPage));
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
#pragma endregion
}
if(!ObjectPropertyPageArray.IsEmpty())
{
CTreeItem ServicesItem = m_TreeView.InsertItem(NULL, LastItem, CData(CData::TYPE_SERVICES), _T("Services"));
LastItem = ServicesItem;
CTreeItem PreviousServiceItem;
for(auto&& ObjectPropertyPage: ObjectPropertyPageArray)
{
CData Data(ObjectPropertyPage.m_pPropertyPage);
Data.m_pSite.Construct()->Initialize(this, ObjectPropertyPage.m_pUnknown, ObjectPropertyPage.m_pPropertyPage);
CTreeItem ServiceItem = m_TreeView.InsertItem(ServicesItem, PreviousServiceItem, Data, Data.GetPropertyPageTitle());
PreviousServiceItem = ServiceItem;
}
m_TreeView.Expand(ServicesItem);
}
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
#pragma endregion
#pragma region Other
CTreeItem MemoryAllocatorItem = m_TreeView.InsertItem(NULL, LastItem, CData(CData::TYPE_MEMORYALLOCATOR), _T("Memory Allocators"));
m_MemoryAllocatorItem.m_hTreeItem = MemoryAllocatorItem;
m_MemoryAllocatorItem.m_pTreeView = &m_TreeView;
CTreeItem ActionItem = m_TreeView.InsertItem(NULL, MemoryAllocatorItem, CData(CData::TYPE_ACTION), _T("Action"));
m_ActionItem.m_hTreeItem = ActionItem;
m_ActionItem.m_pTreeView = &m_TreeView;
CTreeItem EmailItem = m_TreeView.InsertItem(NULL, ActionItem, CData(CData::TYPE_EMAIL), _T("Email"));
m_EmailItem.m_hTreeItem = EmailItem;
m_EmailItem.m_pTreeView = &m_TreeView;
CTreeItem EmailLogItem = m_TreeView.InsertItem(EmailItem, NULL, CData(CData::TYPE_EMAIL_LOG), _T("Log Files"));
m_EmailLogItem.m_hTreeItem = EmailLogItem;
m_EmailLogItem.m_pTreeView = &m_TreeView;
#pragma endregion
m_TreeView.Expand(EmailItem);
}
VOID HideCurrentSite()
{
if(!m_pCurrentSite)
return;
if(m_pCurrentSite->m_pPropertyPage)
__C(m_pCurrentSite->m_pPropertyPage->Show(SW_HIDE));
m_pCurrentSite.Release();
}
VOID HandleStatusChange(CPropertyPageSite* pPropertyPageSite)
{
_A(pPropertyPageSite);
m_ApplyButton.EnableWindow(pPropertyPageSite->IsDirty());
}
VOID Apply()
{
if(!m_pCurrentSite || !m_pCurrentSite->m_pPropertyPage)
return;
__C(m_pCurrentSite->m_pPropertyPage->Apply());
HandleStatusChange(m_pCurrentSite);
}
INT_PTR DoModal(HWND hParentWindow = GetActiveWindow())
{
return CDialogWithAccelerators::DoModal(hParentWindow);
}
// CDialogResize
VOID DlgResize_UpdateLayout(INT nWidth, INT nHeight)
{
__super::DlgResize_UpdateLayout(nWidth, nHeight);
const CRect Position = GetTextEditPosition();
if(m_pCurrentSite && m_pCurrentSite->m_pPropertyPage)
_V(m_pCurrentSite->m_pPropertyPage->Move(Position));
_W(m_MemoryAllocatorDialog.SetWindowPos(NULL, Position, SWP_NOZORDER | SWP_NOACTIVATE));
_W(m_ActionDialog.SetWindowPos(NULL, Position, SWP_NOZORDER | SWP_NOACTIVATE));
_W(m_EmailDialog.SetWindowPos(NULL, Position, SWP_NOZORDER | SWP_NOACTIVATE));
_W(m_EmailLogDialog.SetWindowPos(NULL, Position, SWP_NOZORDER | SWP_NOACTIVATE));
}
// CDialogWithAcceleratorsT
BOOL TranslateAccelerator(MSG* pMessage)
{
CTreeItem TreeItem = m_TreeView.GetSelectedItem();
if(TreeItem)
{
CData& Data = m_TreeView.GetItemData(TreeItem);
if(Data.m_Type == CData::TYPE_FILTERPROPERTYPAGE)
{
if(Data.m_pPropertyPage)
if(Data.m_pPropertyPage->TranslateAccelerator(pMessage) == S_OK)
return TRUE;
}
}
return __super::TranslateAccelerator(pMessage);
}
// Window Message Handler
LRESULT OnInitDialog(HWND, LPARAM)
{
m_bActivating = TRUE;
_ATLTRY
{
CWaitCursor WaitCursor;
CAboutDialog::UpdateCaption(*this);
#pragma region System Menu
CMenuHandle Menu = GetSystemMenu(FALSE);
_W(Menu.AppendMenu(MF_SEPARATOR));
_W(Menu.AppendMenu(MF_STRING, ID_APP_ABOUT, _T("&About...")));
#pragma endregion
#pragma region Icon
SetIcon(AtlLoadIconImage(IDI_MODULE, LR_COLOR, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON)), TRUE);
SetIcon(AtlLoadIconImage(IDI_MODULE, LR_COLOR, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)), FALSE);
#pragma endregion
m_TreeView.Initialize(GetDlgItem(IDC_FILTERGRAPHHELPER_PROPERTYFRAME_TREE));
m_TextEdit = GetDlgItem(IDC_FILTERGRAPHHELPER_PROPERTYFRAME_TEXT);
CRect TextPosition;
_W(m_TextEdit.GetWindowRect(TextPosition));
_W(ScreenToClient(TextPosition));
m_TextPosition = TextPosition;
CLogFont TextFont;
CFontHandle(AtlGetDefaultGuiFont()).GetLogFont(TextFont);
_tcsncpy_s(TextFont.lfFaceName, _T("Courier New"), _TRUNCATE);
TextFont.SetHeight(8);
m_TextFont = TextFont.CreateFontIndirect();
m_TextEdit.SetFont(m_TextFont);
m_RefreshStatic.SubclassWindow(GetDlgItem(IDC_FILTERGRAPHHELPER_PROPERTYFRAME_REFRESH));
m_CopyStatic.SubclassWindow(GetDlgItem(IDC_FILTERGRAPHHELPER_PROPERTYFRAME_COPY));
m_SaveAsStatic.SubclassWindow(GetDlgItem(IDC_FILTERGRAPHHELPER_PROPERTYFRAME_SAVEAS));
CRoHyperStatic::ArrangeHorizontally(&m_RefreshStatic, &m_CopyStatic, &m_SaveAsStatic, NULL);
m_OkButton = GetDlgItem(IDOK);
m_CancelButton = GetDlgItem(IDCANCEL);
m_ApplyButton = GetDlgItem(IDC_FILTERGRAPHHELPER_PROPERTYFRAME_APPLY);
__E(m_MemoryAllocatorDialog.Create(m_hWnd, (LPARAM) this));
__E(m_ActionDialog.Create(m_hWnd, (LPARAM) this));
__E(m_EmailDialog.Create(m_hWnd, (LPARAM) this));
__E(m_EmailLogDialog.Create(m_hWnd, (LPARAM) this));
DlgResize_Init(TRUE);
UpdateTree();
m_FiltersItem.Select();
m_FiltersItem.EnsureVisible();
CRect Position;
_W(GetWindowRect(Position));
Position.right += Position.Width() / 2;
Position.bottom += Position.Width() / 4;
_W(SetWindowPos(NULL, Position, SWP_NOMOVE | SWP_NOZORDER));
_W(CenterWindow());
m_bActivating = FALSE;
}
_ATLCATCH(Exception)
{
for(CWindow Window = GetWindow(GW_CHILD); Window; Window = Window.GetWindow(GW_HWNDNEXT))
Window.EnableWindow(FALSE);
AtlExceptionMessageBox(m_hWnd, Exception);
}
return TRUE;
}
LRESULT OnDestroy()
{
#pragma region Deactivate and Terminate Sites
for(POSITION Position = m_TreeView.GetDataList().GetHeadPosition(); Position; m_TreeView.GetDataList().GetNext(Position))
{
CData& Data = m_TreeView.GetDataList().GetAt(Position);
if(!Data.m_pSite)
continue;
if(Data.m_bSiteActivated)
{
const HRESULT nDeactivateResult = Data.m_pPropertyPage->Deactivate();
_Z35_DSHRESULT(nDeactivateResult);
Data.m_bSiteActivated = FALSE;
}
Data.m_pSite->Terminate();
}
#pragma endregion
return 0;
}
LRESULT OnTreeViewGetInfoTip(NMTVGETINFOTIP* pHeader)
{
_A(pHeader);
if(!pHeader->hItem)
return 0;
CData& Data = m_TreeView.GetItemData(pHeader->hItem);
CString sInfoTip;
if(Data.m_pBaseFilter)
{
if(!Data.m_pPropertyPage)
{
sInfoTip.AppendFormat(_T("Name: %ls") _T("\r\n"), _FilterGraphHelper::GetFilterName(Data.m_pBaseFilter));
if(Data.m_BaseFilterClassIdentifier != CLSID_NULL)
sInfoTip.AppendFormat(_T("Class Identifier: %ls") _T("\r\n"), _PersistHelper::StringFromIdentifier(Data.m_BaseFilterClassIdentifier));
if(!Data.m_sBaseFilterClassDescription.IsEmpty())
sInfoTip.AppendFormat(_T("Class Description: %s") _T("\r\n"), Data.m_sBaseFilterClassDescription);
if(!Data.m_sBaseFilterModulePath.IsEmpty())
sInfoTip.AppendFormat(_T("Module Path: %s") _T("\r\n"), Data.m_sBaseFilterModulePath);
} else
{
// TODO: ...
}
}
sInfoTip.TrimRight(_T("\t\n\r "));
_tcsncpy_s(pHeader->pszText, pHeader->cchTextMax, sInfoTip, _TRUNCATE);
#pragma region Clipboard Copy
if(GetKeyState(VK_CONTROL) < 0 && GetKeyState(VK_SHIFT) < 0)
_ATLTRY
{
SetClipboardText(m_hWnd, sInfoTip);
MessageBeep(MB_OK);
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
MessageBeep(MB_ICONERROR);
}
#pragma endregion
return 0;
}
LRESULT OnTreeViewSelChanged(NMTREEVIEW* pHeader)
{
_A(pHeader);
#pragma region Tree Item
CTreeItem TreeItem(pHeader->itemNew.hItem);
if(TreeItem)
{
CData& Data = m_TreeView.GetItemData(TreeItem);
if(Data.m_Type != CData::TYPE_MEMORYALLOCATOR)
m_MemoryAllocatorDialog.ShowWindow(SW_HIDE);
if(Data.m_Type != CData::TYPE_ACTION)
m_ActionDialog.ShowWindow(SW_HIDE);
if(Data.m_Type != CData::TYPE_EMAIL)
m_EmailDialog.ShowWindow(SW_HIDE);
if(Data.m_Type != CData::TYPE_EMAIL_LOG)
m_EmailLogDialog.ShowWindow(SW_HIDE);
#pragma region Filter
if(Data.m_pBaseFilter)
{
#pragma region Property Page
if(Data.m_pPropertyPage)
{
ShowText(FALSE);
if(Data.m_pSite != m_pCurrentSite)
HideCurrentSite();
if(!Data.m_bSiteActivated)
{
__C(Data.m_pPropertyPage->Activate(m_hWnd, GetTextEditPosition(), TRUE));
Data.m_bSiteActivated = TRUE;
} else
__C(Data.m_pPropertyPage->Move(GetTextEditPosition()));
__C(Data.m_pPropertyPage->Show(SW_SHOWNORMAL));
m_pCurrentSite = Data.m_pSite;
HandleStatusChange(m_pCurrentSite);
} else
#pragma endregion
#pragma region Text
{
CWaitCursor WaitCursor;
HideCurrentSite();
ShowText(TRUE, FALSE);
CString sText;
sText += AtlFormatString(_T("## ") _T("Filter %ls") _T("\r\n") _T("\r\n"), _FilterGraphHelper::GetFilterName(Data.m_pBaseFilter));
sText += m_Owner.GetFilterText(Data.m_pBaseFilter);
sText += _T("\r\n");
#pragma region Connection
_FilterGraphHelper::CPinArray InputPinArray, OutputPinArray;
_FilterGraphHelper::GetFilterPins(Data.m_pBaseFilter, PINDIR_INPUT, InputPinArray);
_FilterGraphHelper::GetFilterPins(Data.m_pBaseFilter, PINDIR_OUTPUT, OutputPinArray);
if(!InputPinArray.IsEmpty() || !OutputPinArray.IsEmpty())
{
sText += AtlFormatString(_T("## ") _T("Connections") _T("\r\n") _T("\r\n"));
if(!InputPinArray.IsEmpty())
{
sText += AtlFormatString(_T("### ") _T("Input") _T("\r\n") _T("\r\n"));
for(SIZE_T nPinIndex = 0; nPinIndex < InputPinArray.GetCount(); nPinIndex++)
{
const CComPtr<IPin>& pInputPin = InputPinArray[nPinIndex];
const CComPtr<IPin> pOutputPin = _FilterGraphHelper::GetPeerPin(pInputPin);
if(!pOutputPin)
continue;
sText += AtlFormatString(_T(" * ") _T("%s") _T("\r\n"), m_Owner.GetConnectionText(pOutputPin, pInputPin));
}
sText += _T("\r\n");
}
if(!OutputPinArray.IsEmpty())
{
sText += AtlFormatString(_T("### ") _T("Output") _T("\r\n") _T("\r\n"));
for(SIZE_T nPinIndex = 0; nPinIndex < OutputPinArray.GetCount(); nPinIndex++)
{
const CComPtr<IPin>& pOutputPin = OutputPinArray[nPinIndex];
const CComPtr<IPin> pInputPin = _FilterGraphHelper::GetPeerPin(pOutputPin);
if(!pInputPin)
continue;
sText += AtlFormatString(_T(" * ") _T("%s") _T("\r\n"), m_Owner.GetConnectionText(pOutputPin, pInputPin));
}
sText += _T("\r\n");
}
}
#pragma endregion
#pragma region Media Type
_FilterGraphHelper::CPinArray PinArray;
if(_FilterGraphHelper::GetFilterPins(Data.m_pBaseFilter, PinArray))
{
sText += AtlFormatString(_T("## ") _T("Media Types") _T("\r\n") _T("\r\n"));
for(SIZE_T nPinIndex = 0; nPinIndex < PinArray.GetCount(); nPinIndex++)
{
const CComPtr<IPin>& pPin = PinArray[nPinIndex];
CString sPinText = AtlFormatString(_T("%s"), FormatIdentifier(_FilterGraphHelper::GetPinFullName(pPin)));
const CComPtr<IPin> pPeerPin = _FilterGraphHelper::GetPeerPin(pPin);
if(pPeerPin)
sPinText += AtlFormatString(_T(", %s"), FormatIdentifier(_FilterGraphHelper::GetPinFullName(pPeerPin)));
sText += AtlFormatString(_T("%d. ") _T("%s") _T("\r\n"), 1 + nPinIndex, sPinText);
_ATLTRY
{
CMediaType pMediaType;
if(pPeerPin)
pMediaType = _FilterGraphHelper::GetPinMediaType(pPin);
else
pMediaType = _FilterGraphHelper::EnumerateFirstPinMediaType(pPin);
if(!pMediaType)
continue;
sText += m_Owner.GetMediaTypeText(pMediaType);
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
}
sText += _T("\r\n");
}
#pragma endregion
#pragma region Runtime Property Bag
_ATLTRY
{
const CString sPropertyBagText = CRunPropertyBagHelper::GetPropertyBagText(Data.m_pBaseFilter, CComQIPtr<ISpy>(m_Owner.m_pFilterGraph));
if(!sPropertyBagText.IsEmpty())
{
sText += AtlFormatString(_T("## ") _T("Runtime Properties") _T("\r\n") _T("\r\n"));
sText += sPropertyBagText;
sText += _T("\r\n");
}
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
#pragma endregion
m_TextEdit.SetValue(sText);
m_ApplyButton.EnableWindow(FALSE);
}
#pragma endregion
} else
#pragma endregion
#pragma region Service Property Page
if(Data.m_pPropertyPage)
{
ShowText(FALSE);
if(Data.m_pSite != m_pCurrentSite)
HideCurrentSite();
if(!Data.m_bSiteActivated)
{
__C(Data.m_pPropertyPage->Activate(m_hWnd, GetTextEditPosition(), TRUE));
Data.m_bSiteActivated = TRUE;
} else
__C(Data.m_pPropertyPage->Move(GetTextEditPosition()));
__C(Data.m_pPropertyPage->Show(SW_SHOWNORMAL));
m_pCurrentSite = Data.m_pSite;
HandleStatusChange(m_pCurrentSite);
} else
#pragma endregion
#pragma region Other
{
CWaitCursor WaitCursor;
HideCurrentSite();
switch(Data.m_Type)
{
#pragma region TYPE_MEMORYALLOCATOR
case CData::TYPE_MEMORYALLOCATOR:
ShowText(FALSE);
_W(m_MemoryAllocatorDialog.SetWindowPos(NULL, GetTextEditPosition(), SWP_NOZORDER | SWP_SHOWWINDOW));
break;
#pragma endregion
#pragma region TYPE_ACTION
case CData::TYPE_ACTION:
ShowText(FALSE);
_W(m_ActionDialog.SetWindowPos(NULL, GetTextEditPosition(), SWP_NOZORDER | SWP_SHOWWINDOW));
break;
#pragma endregion
#pragma region TYPE_EMAIL
case CData::TYPE_EMAIL:
ShowText(FALSE);
_W(m_EmailDialog.SetWindowPos(NULL, GetTextEditPosition(), SWP_NOZORDER | SWP_SHOWWINDOW));
break;
#pragma endregion
#pragma region TYPE_EMAIL_LOG
case CData::TYPE_EMAIL_LOG:
ShowText(FALSE);
_W(m_EmailLogDialog.SetWindowPos(NULL, GetTextEditPosition(), SWP_NOZORDER | SWP_SHOWWINDOW));
break;
#pragma endregion
default:
UpdateText();
ShowText(TRUE, TRUE);
m_MemoryAllocatorDialog.ShowWindow(SW_HIDE);
m_ActionDialog.ShowWindow(SW_HIDE);
m_EmailDialog.ShowWindow(SW_HIDE);
m_EmailLogDialog.ShowWindow(SW_HIDE);
}
m_ApplyButton.EnableWindow(FALSE);
}
#pragma endregion
} else
#pragma endregion
#pragma region No Tree Item
{
HideCurrentSite();
ShowText(FALSE);
m_MemoryAllocatorDialog.ShowWindow(SW_HIDE);
m_ActionDialog.ShowWindow(SW_HIDE);
m_EmailDialog.ShowWindow(SW_HIDE);
m_EmailLogDialog.ShowWindow(SW_HIDE);
m_ApplyButton.EnableWindow(FALSE);
}
#pragma endregion
return 0;
}
LRESULT OnTreeViewItemExplanding(NMTREEVIEW* pHeader)
{
if(pHeader->action == TVE_COLLAPSE)
return TRUE; // Prevent Collapsing
return 0;
}
LRESULT OnTreeViewDblClk(NMHDR*)
{
CTreeItem TreeItem = m_TreeView.GetSelectedItem();
if(!TreeItem)
return 0;
CData& Data = m_TreeView.GetItemData(TreeItem);
if(!Data.m_pBaseFilter)
return 0;
COlePropertyFrameDialog Dialog(Data.m_pBaseFilter);
if(!Dialog.SetObjectPages())
return 0;
Dialog.DoModal(m_hWnd);
return 0;
}
VOID UpdateText()
{
m_TextEdit.SetValue(m_Owner.GetText());
const INT nTextLength = m_TextEdit.GetWindowTextLength();
//m_RefreshStatic.EnableWindow(TRUE);
m_CopyStatic.EnableWindow(nTextLength > 0);
m_SaveAsStatic.EnableWindow(nTextLength > 0);
}
LRESULT OnRefreshAnchorClicked(NMHDR*)
{
UpdateText();
MessageBeep(MB_OK);
return 0;
}
LRESULT OnCopyAnchorClicked(NMHDR*)
{
SetClipboardText(m_hWnd, m_TextEdit.GetValue());
MessageBeep(MB_OK);
return 0;
}
LRESULT OnSaveAsAnchorClicked(NMHDR*)
{
static const COMDLG_FILTERSPEC g_pFilter[] =
{
{ _T("Markdown Files"), _T("*.md") },
{ _T("Text Files"), _T("*.txt") },
{ _T("BZip2 Compressed Markdown Files"), _T("*.md.bz2") },
{ _T("All Files"), _T("*.*") },
};
CPath sPath = _CommonDialogHelper::QuerySavePath(m_hWnd, g_pFilter, _T("md"));
if(!_tcslen(sPath))
return 0;
CAtlFile File;
__C(File.Create(sPath, GENERIC_WRITE, FILE_SHARE_READ, CREATE_ALWAYS));
_ATLTRY
{
CStringA sText = Utf8StringFromString(CStringW(m_TextEdit.GetValue()));
static const BYTE g_pnByteOrderMark[] = { 0xEF, 0xBB, 0xBF, 0x00 };
sText.Insert(0, (LPCSTR) g_pnByteOrderMark);
if(_tcsicmp(GetPathExtension(sPath), _T(".bz2")) == 0)
{
CLocalObjectPtr<CBzip2Item> pItem;
pItem->SetRawData((const BYTE*) (LPCSTR) sText, sText.GetLength());
CHeapPtr<BYTE> pnData;
SIZE_T nDataSize = 0;
pItem->GetData(pnData, nDataSize);
__C(File.Write(pnData, (DWORD) nDataSize));
} else
__C(File.Write(sText, (DWORD) sText.GetLength()));
}
_ATLCATCHALL()
{
File.Close();
_W(DeleteFile(sPath));
_ATLRETHROW;
}
MessageBeep(MB_OK);
return 0;
}
LRESULT OnSysCommand(UINT nCommand, CPoint)
{
switch(nCommand)
{
case ID_APP_ABOUT:
{
CAboutDialog Dialog;
Dialog.DoModal(m_hWnd);
}
break;
default:
SetMsgHandled(FALSE);
}
return 0;
}
LRESULT OnOk(UINT, INT nIdentifier, HWND)
{
_ATLTRY
{
#pragma region Apply All
for(POSITION Position = m_TreeView.GetDataList().GetHeadPosition(); Position; m_TreeView.GetDataList().GetNext(Position))
{
CData& Data = m_TreeView.GetDataList().GetAt(Position);
if(!Data.m_pSite)
continue;
_A(Data.m_pPropertyPage);
if(Data.m_bSiteActivated && Data.m_pSite->IsDirty())
__C(Data.m_pPropertyPage->Apply());
}
#pragma endregion
}
_ATLCATCH(Exception)
{
_Z_ATLEXCEPTION(Exception);
AtlMessageBoxEx(m_hWnd, (LPCTSTR) Ds::FormatResult(Exception), IDS_ERROR, MB_ICONERROR | MB_OK);
return 0;
}
EndDialog(nIdentifier);
return 0;
}
LRESULT OnCancel(UINT, INT nIdentifier, HWND)
{
EndDialog(nIdentifier);
return 0;
}
LRESULT OnApply(UINT, INT, HWND)
{
_ATLTRY
{
Apply();
}
_ATLCATCH(Exception)
{
_Z_ATLEXCEPTION(Exception);
AtlMessageBoxEx(m_hWnd, (LPCTSTR) Ds::FormatResult(Exception), IDS_ERROR, MB_ICONERROR | MB_OK);
}
return 0;
}
LRESULT OnTreeWalkUp(UINT, INT, HWND)
{
CTreeItem TreeItem = m_TreeView.GetSelectedItem();
CTreeItem ParentTreeItem = TreeItem.GetParent();
if(!ParentTreeItem)
return 0;
m_TreeView.SetFocus();
m_TreeView.Select(ParentTreeItem, TVGN_CARET);
return 0;
}
LRESULT OnActionCommand(UINT, INT nIdentifier, HWND)
{
return m_ActionDialog.SendMessage(WM_COMMAND, nIdentifier);
}
};
private:
mutable CRoCriticalSection m_DataCriticalSection;
CProcessData m_ProcessData;
CComPtr<IFilterGraph> m_pFilterGraph;
COptions m_Options;
public:
// CFilterGraphHelper
static HRESULT WINAPI UpdateRegistry(BOOL bRegister)
{
_Z2(atlTraceRegistrar, 2, _T("bRegister %d\n"), bRegister);
_ATLTRY
{
UpdateRegistryFromResource<CFilterGraphHelper>(bRegister);
}
_ATLCATCH(Exception)
{
_C(Exception);
}
return S_OK;
}
CFilterGraphHelper()
{
_Z4_THIS();
}
~CFilterGraphHelper()
{
_Z4_THIS();
}
static CString FormatIdentifier(LPCSTR pszValue)
{
CString sText;
if(pszValue && *pszValue)
{
sText = _T("``");
sText.Insert(1, CString(pszValue));
}
return sText;
}
static CString FormatIdentifier(LPCWSTR pszValue)
{
CString sText;
if(pszValue && *pszValue)
{
sText = _T("``");
sText.Insert(1, CString(pszValue));
}
return sText;
}
static CString FormatIdentifier(LONG nValue)
{
CString sText;
sText = _T("``");
sText.Insert(1, _StringHelper::FormatNumber(nValue));
return sText;
}
static CString FormatIdentifier(ULONG nValue)
{
return FormatIdentifier((LONG) nValue);
}
static CString FormatIdentifier(BOOL nValue)
{
return FormatIdentifier((LONG) nValue);
}
static CString FormatIdentifier(LONGLONG nValue)
{
CString sText;
sText = _T("``");
sText.Insert(1, _StringHelper::FormatNumber(nValue));
return sText;
}
static CString FormatIdentifier(LONG nValue, LPCTSTR pszFormat)
{
CString sText;
sText = _T("``");
sText.Insert(1, AtlFormatString(pszFormat, nValue));
return sText;
}
static CString FormatIdentifier(const VOID* pvValue, LPCTSTR pszFormat = _T("0x%p"))
{
CString sText;
sText = _T("``");
sText.Insert(1, AtlFormatString(pszFormat, pvValue));
return sText;
}
#define I FormatIdentifier
static CString FormatPhysicalConnectorType(PhysicalConnectorType Value)
{
struct
{
PhysicalConnectorType Value;
LPCSTR pszName;
} g_pMap[] =
{
#define A(x) { x, #x },
A(PhysConn_Video_Tuner)
A(PhysConn_Video_Composite)
A(PhysConn_Video_SVideo)
A(PhysConn_Video_RGB)
A(PhysConn_Video_YRYBY)
A(PhysConn_Video_SerialDigital)
A(PhysConn_Video_ParallelDigital)
A(PhysConn_Video_SCSI)
A(PhysConn_Video_AUX)
A(PhysConn_Video_1394)
A(PhysConn_Video_USB)
A(PhysConn_Video_VideoDecoder)
A(PhysConn_Video_VideoEncoder)
A(PhysConn_Video_SCART)
A(PhysConn_Video_Black)
A(PhysConn_Audio_Tuner)
A(PhysConn_Audio_Line)
A(PhysConn_Audio_Mic)
A(PhysConn_Audio_AESDigital)
A(PhysConn_Audio_SPDIFDigital)
A(PhysConn_Audio_SCSI)
A(PhysConn_Audio_AUX)
A(PhysConn_Audio_1394)
A(PhysConn_Audio_USB)
A(PhysConn_Audio_AudioDecoder)
#undef A
};
for(SIZE_T nIndex = 0; nIndex < DIM(g_pMap); nIndex++)
if(g_pMap[nIndex].Value == Value)
return CString(g_pMap[nIndex].pszName);
return AtlFormatString(_T("0x%04X"), Value);
}
static CString FormatPins(_FilterGraphHelper::CPinArray& PinArray)
{
CRoArrayT<CString> Array;
for(SIZE_T nIndex = 0; nIndex < PinArray.GetCount(); nIndex++)
{
const CComPtr<IPin>& pPin = PinArray[nIndex];
CString sText = I(_FilterGraphHelper::GetPinName(pPin));
const CComPtr<IPin> pPeerPin = _FilterGraphHelper::GetPeerPin(pPin);
if(pPeerPin)
sText += AtlFormatString(_T(" (%s)"), I(_FilterGraphHelper::GetPinFullName(pPeerPin)));
Array.Add(sText);
}
return _StringHelper::Join(Array, _T(", "));
}
static CString GetFilterText(IBaseFilter* pBaseFilter, const CProcessData* pProcessData, IReferenceClock* pFilterGraphReferenceClock = NULL)
{
CString sText;
#pragma region COM
CString sPath;
const CStringW sClassIdentifierString = _FilterGraphHelper::GetFilterClassIdentifierString(pBaseFilter);
if(!sClassIdentifierString.IsEmpty())
{
CLSID ClassIdentifier = CLSID_NULL;
const BOOL bClassIdentifierAvailable = _PersistHelper::ClassIdentifierFromString(sClassIdentifierString, ClassIdentifier);
if(bClassIdentifierAvailable && ClassIdentifier != CLSID_NULL)
{
sText += AtlFormatString(_T(" * ") _T("Class: %s %s") _T("\r\n"), I(sClassIdentifierString), I(_FilterGraphHelper::GetFilterClassDescription(pBaseFilter)));
_ATLTRY
{
sPath = _RegKeyHelper::QueryStringValue(HKEY_CLASSES_ROOT, AtlFormatString(_T("CLSID\\%ls\\InprocServer32"), sClassIdentifierString));
if(!sPath.IsEmpty())
{
sText += AtlFormatString(_T(" * ") _T("Inproc Server: %s") _T("\r\n"), I(sPath));
const ULONGLONG nProductVersion = _VersionInfoHelper::GetProductVersion(sPath);
if(nProductVersion && (nProductVersion + 1))
sText += AtlFormatString(_T(" * ") _T("Product Version: %s") _T("\r\n"), I(_VersionInfoHelper::GetVersionString(nProductVersion)));
const ULONGLONG nFileVersion = _VersionInfoHelper::GetFileVersion(sPath);
if(nFileVersion && (nFileVersion + 1))
sText += AtlFormatString(_T(" * ") _T("File Version: %s") _T("\r\n"), I(_VersionInfoHelper::GetVersionString(nFileVersion)));
}
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
}
}
if(_tcslen(sPath) == 0 && pProcessData && pProcessData->m_nIdentifier == GetCurrentProcessId())
_ATLTRY
{
const VOID* pvVirtualTable = *((const VOID**) pBaseFilter);
MEMORY_BASIC_INFORMATION Information;
if(VirtualQueryEx(GetCurrentProcess(), pvVirtualTable, &Information, sizeof Information))
{
TCHAR pszPath[MAX_PATH] = { 0 };
if(GetModuleFileName((HMODULE) Information.AllocationBase, pszPath, DIM(pszPath)))
{
sPath = pszPath;
sText += AtlFormatString(_T(" * ") _T("Virtual Table Location: %s") _T("\r\n"), I(sPath));
const ULONGLONG nProductVersion = _VersionInfoHelper::GetProductVersion(sPath);
if(nProductVersion && (nProductVersion + 1))
sText += AtlFormatString(_T(" * ") _T("Product Version: %s") _T("\r\n"), I(_VersionInfoHelper::GetVersionString(nProductVersion)));
const ULONGLONG nFileVersion = _VersionInfoHelper::GetFileVersion(sPath);
if(nFileVersion && (nFileVersion + 1))
sText += AtlFormatString(_T(" * ") _T("File Version: %s") _T("\r\n"), I(_VersionInfoHelper::GetVersionString(nFileVersion)));
}
}
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
#pragma endregion
#pragma region Pin
_FilterGraphHelper::CPinArray InputPinArray;
if(_FilterGraphHelper::GetFilterPins(pBaseFilter, PINDIR_INPUT, InputPinArray))
sText += AtlFormatString(_T(" * ") _T("Input Pins: %s") _T("\r\n"), FormatPins(InputPinArray));
_FilterGraphHelper::CPinArray OutputPinArray;
if(_FilterGraphHelper::GetFilterPins(pBaseFilter, PINDIR_OUTPUT, OutputPinArray))
sText += AtlFormatString(_T(" * ") _T("Output Pins: %s") _T("\r\n"), FormatPins(OutputPinArray));
#pragma endregion
#pragma region IReferenceClock
const CComQIPtr<IReferenceClock> pReferenceClock = pBaseFilter;
if(pReferenceClock)
{
CRoArrayT<CString> Array;
Array.Add(I(_T("Available")));
if(pReferenceClock == pFilterGraphReferenceClock)
Array.Add(I(_T("Selected")));
sText += AtlFormatString(_T(" * ") _T("Reference Clock: %s") _T("\r\n"), _StringHelper::Join(Array, _T(", ")));
}
#pragma endregion
#pragma region IFileSourceFilter
const CComQIPtr<IFileSourceFilter> pFileSourceFilter = pBaseFilter;
if(pFileSourceFilter)
_ATLTRY
{
CComHeapPtr<OLECHAR> pszFileName;
CMediaType pMediaType;
pMediaType.Allocate(MEDIATYPE_NULL, MEDIASUBTYPE_NULL);
const HRESULT nGetCurFileResult = pFileSourceFilter->GetCurFile(&pszFileName, pMediaType);
_Z45_DSHRESULT(nGetCurFileResult);
if(SUCCEEDED(nGetCurFileResult))
sText += AtlFormatString(_T(" * ") _T("File Source: %s") _T("\r\n"), I(pszFileName));
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
#pragma endregion
#pragma region IFileSinkFilter
const CComQIPtr<IFileSinkFilter> pFileSinkFilter = pBaseFilter;
if(pFileSinkFilter)
_ATLTRY
{
CComHeapPtr<OLECHAR> pszFileName;
CMediaType pMediaType;
pMediaType.Allocate(MEDIATYPE_NULL, MEDIASUBTYPE_NULL);
const HRESULT nGetCurFileResult = pFileSinkFilter->GetCurFile(&pszFileName, pMediaType);
_Z45_DSHRESULT(nGetCurFileResult);
if(SUCCEEDED(nGetCurFileResult))
sText += AtlFormatString(_T(" * ") _T("File Sink: %s") _T("\r\n"), I(pszFileName));
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
#pragma endregion
#pragma region IMediaSeeking
const CComQIPtr<IMediaSeeking> pMediaSeeking = pBaseFilter;
if(pMediaSeeking)
_ATLTRY
{
sText += AtlFormatString(_T(" * ") _T("Media Seeking/Position") _T("\r\n"));
DWORD nCapabilities = 0;
if(SUCCEEDED(pMediaSeeking->GetCapabilities(&nCapabilities)))
sText += AtlFormatString(_T(" * ") _T("Capabilities: %s") _T("\r\n"), I(AtlFormatString(_T("0x%X"), nCapabilities)));
LONGLONG nDuration = 0, nPosition = 0, nStopPosition = 0;
if(SUCCEEDED(pMediaSeeking->GetDuration(&nDuration)))
sText += AtlFormatString(_T(" * ") _T("Duration: %s (%s seconds)") _T("\r\n"), I(_FilterGraphHelper::FormatSecondTime((DOUBLE) nDuration / 1E7)), I(_StringHelper::FormatNumber((DOUBLE) nDuration / 1E7, 3)));
if(SUCCEEDED(pMediaSeeking->GetCurrentPosition(&nPosition)))
sText += AtlFormatString(_T(" * ") _T("Position: %s (%s seconds)") _T("\r\n"), I(_FilterGraphHelper::FormatSecondTime((DOUBLE) nPosition / 1E7)), I(_StringHelper::FormatNumber((DOUBLE) nPosition / 1E7, 3)));
if(SUCCEEDED(pMediaSeeking->GetStopPosition(&nStopPosition)))
sText += AtlFormatString(_T(" * ") _T("Stop Position: %s (%s seconds)") _T("\r\n"), I(_FilterGraphHelper::FormatSecondTime((DOUBLE) nStopPosition / 1E7)), I(_StringHelper::FormatNumber((DOUBLE) nStopPosition / 1E7, 3)));
DOUBLE fRate = 1.0;
if(SUCCEEDED(pMediaSeeking->GetRate(&fRate)))
sText += AtlFormatString(_T(" * ") _T("Rate: %s") _T("\r\n"), I(_StringHelper::FormatNumber(fRate, 3)));
LONGLONG nPreroll = 0;
if(SUCCEEDED(pMediaSeeking->GetPreroll(&nPreroll)) && nPreroll)
sText += AtlFormatString(_T(" * ") _T("Preroll: %s seconds") _T("\r\n"), I(_StringHelper::FormatNumber((DOUBLE) nPreroll / 1E7, 3)));
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
#pragma endregion
#pragma region IAMCrossbar
const CComQIPtr<IAMCrossbar> pAmCrossbar = pBaseFilter;
if(pAmCrossbar)
_ATLTRY
{
sText += AtlFormatString(_T(" * ") _T("Crossbar:") _T("\r\n"));
LONG nOutputPinCount = 0, nInputPinCount = 0;
__C(pAmCrossbar->get_PinCounts(&nOutputPinCount, &nInputPinCount));
sText += AtlFormatString(_T(" * ") _T("Pins: %s Input, %s Output") _T("\r\n"), I(nInputPinCount), I(nOutputPinCount));
#pragma region Input
for(LONG nInputPinIndex = 0; nInputPinIndex < nInputPinCount; nInputPinIndex++)
_ATLTRY
{
CRoArrayT<CString> Array;
LONG nRelatedPinIndex = -1;
LONG nPhysicalType = 0; // PhysicalConnectorType
__C(pAmCrossbar->get_CrossbarPinInfo(TRUE, nInputPinIndex, &nRelatedPinIndex, &nPhysicalType));
if(nRelatedPinIndex >= 0)
Array.Add(AtlFormatString(_T("Related %s"), I(nRelatedPinIndex)));
Array.Add(AtlFormatString(_T("Physical Type %s"), I(FormatPhysicalConnectorType((PhysicalConnectorType) nPhysicalType))));
sText += AtlFormatString(_T(" * ") _T("Input Pin %s: %s") _T("\r\n"), I(nInputPinIndex), _StringHelper::Join(Array, _T("; ")));
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
#pragma endregion
#pragma region Output
for(LONG nOutputPinIndex = 0; nOutputPinIndex < nOutputPinCount; nOutputPinIndex++)
_ATLTRY
{
CRoArrayT<CString> Array;
LONG nRelatedPinIndex = -1;
LONG nPhysicalType = 0; // PhysicalConnectorType
__C(pAmCrossbar->get_CrossbarPinInfo(FALSE, nOutputPinIndex, &nRelatedPinIndex, &nPhysicalType));
if(nRelatedPinIndex >= 0)
Array.Add(AtlFormatString(_T("Related %s"), I(nRelatedPinIndex)));
if(nPhysicalType > 0)
Array.Add(AtlFormatString(_T("Physical Type %s"), I(FormatPhysicalConnectorType((PhysicalConnectorType) nPhysicalType))));
LONG nRoutedInputPinIndex = -1;
const HRESULT nGetIsRoutedToResult = pAmCrossbar->get_IsRoutedTo(nOutputPinIndex, &nRoutedInputPinIndex);
_A(nGetIsRoutedToResult == S_OK || nRoutedInputPinIndex == -1);
if(nRoutedInputPinIndex >= 0)
Array.Add(AtlFormatString(_T("Routed to Input Pin %s"), I(nRoutedInputPinIndex)));
CRoArrayT<CString> PinArray;
for(LONG nInputPinIndex = 0; nInputPinIndex < nInputPinCount; nInputPinIndex++)
{
const HRESULT nCanRouteResult = pAmCrossbar->CanRoute(nOutputPinIndex, nInputPinIndex);
if(nCanRouteResult == S_OK)
PinArray.Add(I(nInputPinIndex));
}
if(!PinArray.IsEmpty())
Array.Add(AtlFormatString(_T("Routeable to Input Pins %s"), _StringHelper::Join(PinArray, _T(", "))));
sText += AtlFormatString(_T(" * ") _T("Output Pin %s: %s") _T("\r\n"), I(nOutputPinIndex), _StringHelper::Join(Array, _T("; ")));
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
#pragma endregion
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
#pragma endregion
return sText;
}
static CString GetConnectionText(IPin* pOutputPin, IPin* pInputPin)
{
_A(pOutputPin && pInputPin);
CString sText = AtlFormatString(_T("%s - %s"), I(_FilterGraphHelper::GetPinFullName(pOutputPin)), I(_FilterGraphHelper::GetPinFullName(pInputPin)));
_ATLTRY
{
const CMediaType pMediaType = _FilterGraphHelper::GetPinMediaType(pOutputPin);
if(pMediaType)
{
CStringW sMajorType = _FilterGraphHelper::FormatMajorType(pMediaType->majortype);
CStringW sSubtype;
if(pMediaType->subtype != MEDIASUBTYPE_NULL)
sSubtype = _FilterGraphHelper::FormatSubtype(pMediaType->majortype, pMediaType->subtype);
CRoArrayT<CString> Array;
Array.Add(I(sMajorType));
if(!sSubtype.IsEmpty())
Array.Add(I(sSubtype));
#pragma region MEDIATYPE_Video
if(pMediaType->majortype == MEDIATYPE_Video)
{
const CVideoInfoHeader2 VideoInfoHeader2 = pMediaType.GetCompatibleVideoInfoHeader2();
const CSize Extent = VideoInfoHeader2.GetExtent();
if(Extent.cx || Extent.cy)
Array.Add(AtlFormatString(_T("%s x %s"), I(Extent.cx), I(Extent.cy)));
if(VideoInfoHeader2.AvgTimePerFrame > 0)
Array.Add(AtlFormatString(_T("%s frames/sec"), I(_StringHelper::FormatNumber(1E7 / VideoInfoHeader2.AvgTimePerFrame, 3))));
} else
#pragma endregion
#pragma region MEDIATYPE_Audio
if(pMediaType->majortype == MEDIATYPE_Audio)
{
const CWaveFormatEx* pWaveFormatEx = pMediaType.GetWaveFormatEx();
if(pWaveFormatEx)
{
if(pWaveFormatEx->nSamplesPerSec)
Array.Add(AtlFormatString(_T("%s Hz"), I(pWaveFormatEx->nSamplesPerSec)));
if(pWaveFormatEx->nChannels)
Array.Add(AtlFormatString(_T("%s channels"), I(pWaveFormatEx->nChannels)));
if(pWaveFormatEx->wBitsPerSample)
Array.Add(AtlFormatString(_T("%s bits"), I(pWaveFormatEx->wBitsPerSample)));
}
}
#pragma endregion
sText += AtlFormatString(_T(" (%s)"), _StringHelper::Join(Array, _T(", ")));
}
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
return sText;
}
static CString GetMediaTypeText(const CMediaType& pMediaType)
{
CString sText;
#pragma region AM_MEDIA_TYPE
#define J(x) I(pMediaType->x)
#define K1(x) sText += AtlFormatString(_T(" * `") _T(#x) _T("`: %s") _T("\r\n"), J(x))
sText += AtlFormatString(_T(" * ") _T("Data: %s") _T("\r\n"), I(AtlFormatData((const BYTE*) (const AM_MEDIA_TYPE*) pMediaType, sizeof *pMediaType).TrimRight()));
sText += AtlFormatString(_T(" * ") _T("`majortype`: %s") _T("\r\n"), I(_FilterGraphHelper::FormatMajorType(pMediaType->majortype)));
if(pMediaType->subtype != MEDIASUBTYPE_NULL)
sText += AtlFormatString(_T(" * ") _T("`subtype`: %s") _T("\r\n"), I(_FilterGraphHelper::FormatSubtype(pMediaType->majortype, pMediaType->subtype)));
K1(bFixedSizeSamples);
K1(bTemporalCompression);
K1(lSampleSize);
if(pMediaType->formattype != GUID_NULL)
sText += AtlFormatString(_T(" * ") _T("`formattype`: %s") _T("\r\n"), I(_FilterGraphHelper::FormatFormatType(pMediaType->formattype)));
if(pMediaType->pUnk)
sText += AtlFormatString(_T(" * ") _T("`pUnk`: %s") _T("\r\n"), I(AtlFormatString(_T("0x%p"), pMediaType->pUnk)));
if(pMediaType->cbFormat)
{
K1(cbFormat);
if(pMediaType->pbFormat)
sText += AtlFormatString(_T(" * ") _T("Format Data, `pbFormat`: %s") _T("\r\n"), I(AtlFormatData(pMediaType->pbFormat, pMediaType->cbFormat).TrimRight()));
}
#undef J
#undef K1
#pragma endregion
const BYTE* pnExtraData = NULL;
SIZE_T nExtraDataSize = 0;
#pragma region FORMAT_VideoInfo
if(pMediaType->formattype == FORMAT_VideoInfo)
{
sText += AtlFormatString(_T(" * ") _T("As `VIDEOINFOHEADER`:") _T("\r\n"));
const VIDEOINFOHEADER* pVideoInfoHeader = (const VIDEOINFOHEADER*) pMediaType->pbFormat;
if(pVideoInfoHeader && pMediaType->cbFormat >= sizeof *pVideoInfoHeader)
{
#define J(x) I(pVideoInfoHeader->x)
#define K1(x) sText += AtlFormatString(_T(" * `") _T(#x) _T("`: %s") _T("\r\n"), J(x))
sText += AtlFormatString(_T(" * ") _T("`rcSource`: (%s, %s) - (%s, %s)") _T("\r\n"), J(rcSource.left), J(rcSource.top), J(rcSource.right), J(rcSource.bottom));
sText += AtlFormatString(_T(" * ") _T("`rcTarget`: (%s, %s) - (%s, %s)") _T("\r\n"), J(rcTarget.left), J(rcTarget.top), J(rcTarget.right), J(rcTarget.bottom));
K1(dwBitRate);
K1(dwBitErrorRate);
sText += AtlFormatString(_T(" * ") _T("`AvgTimePerFrame`: %s units") _T("\r\n"), I(_FilterGraphHelper::FormatReferenceTime(pVideoInfoHeader->AvgTimePerFrame)));
K1(bmiHeader.biSize);
K1(bmiHeader.biWidth);
K1(bmiHeader.biHeight);
K1(bmiHeader.biPlanes);
K1(bmiHeader.biBitCount);
sText += AtlFormatString(_T(" * ") _T("`bmiHeader.biCompression`: %s") _T("\r\n"), I(_FilterGraphHelper::GetFourccCodeString(pVideoInfoHeader->bmiHeader.biCompression)));
K1(bmiHeader.biSizeImage);
K1(bmiHeader.biXPelsPerMeter);
K1(bmiHeader.biYPelsPerMeter);
K1(bmiHeader.biClrUsed);
K1(bmiHeader.biClrImportant);
#undef J
#undef K1
nExtraDataSize = pMediaType->cbFormat - sizeof *pVideoInfoHeader;
}
} else
#pragma endregion
#pragma region FORMAT_VideoInfo2
if(pMediaType->formattype == FORMAT_VideoInfo2)
{
sText += AtlFormatString(_T(" * ") _T("As `VIDEOINFOHEADER2`:") _T("\r\n"));
const VIDEOINFOHEADER2* pVideoInfoHeader2 = (const VIDEOINFOHEADER2*) pMediaType->pbFormat;
if(pVideoInfoHeader2 && pMediaType->cbFormat >= sizeof *pVideoInfoHeader2)
{
#define J(x) I(pVideoInfoHeader2->x)
#define K1(x) sText += AtlFormatString(_T(" * `") _T(#x) _T("`: %s") _T("\r\n"), J(x))
#define K2(x, y) sText += AtlFormatString(_T(" * `") _T(#x) _T("`: %s") _T("\r\n"), I(pVideoInfoHeader2->x, y))
sText += AtlFormatString(_T(" * ") _T("rcSource: (%s, %s) - (%s, %s)") _T("\r\n"), J(rcSource.left), J(rcSource.top), J(rcSource.right), J(rcSource.bottom));
sText += AtlFormatString(_T(" * ") _T("rcTarget: (%s, %s) - (%s, %s)") _T("\r\n"), J(rcTarget.left), J(rcTarget.top), J(rcTarget.right), J(rcTarget.bottom));
K1(dwBitRate);
K1(dwBitErrorRate);
sText += AtlFormatString(_T(" * ") _T("`AvgTimePerFrame`: %s units") _T("\r\n"), I(_FilterGraphHelper::FormatReferenceTime(pVideoInfoHeader2->AvgTimePerFrame)));
K2(dwInterlaceFlags, _T("0x%X"));
K2(dwCopyProtectFlags, _T("0x%X"));
K1(dwPictAspectRatioX);
K1(dwPictAspectRatioY);
K2(dwControlFlags, _T("0x%X"));
K1(bmiHeader.biSize);
K1(bmiHeader.biWidth);
K1(bmiHeader.biHeight);
K1(bmiHeader.biPlanes);
K1(bmiHeader.biBitCount);
sText += AtlFormatString(_T(" * ") _T("`bmiHeader.biCompression`: %s") _T("\r\n"), I(_FilterGraphHelper::GetFourccCodeString(pVideoInfoHeader2->bmiHeader.biCompression)));
K1(bmiHeader.biSizeImage);
K1(bmiHeader.biXPelsPerMeter);
K1(bmiHeader.biYPelsPerMeter);
K1(bmiHeader.biClrUsed);
K1(bmiHeader.biClrImportant);
#undef J
#undef K1
#undef K2
nExtraDataSize = pMediaType->cbFormat - sizeof *pVideoInfoHeader2;
if(nExtraDataSize)
{
sText += AtlFormatString(_T(" * ") _T("Extra Data: (%d bytes)") _T("\r\n"), nExtraDataSize);
nExtraDataSize = 0;
}
}
} else
#pragma endregion
#pragma region FORMAT_MPEG2Video
if(pMediaType->formattype == FORMAT_MPEG2Video)
{
sText += AtlFormatString(_T(" * ") _T("As `MPEG2VIDEOINFO`:") _T("\r\n"));
const MPEG2VIDEOINFO* pMpeg2VideoInfo = (const MPEG2VIDEOINFO*) pMediaType->pbFormat;
if(pMpeg2VideoInfo && pMediaType->cbFormat >= offsetof(MPEG2VIDEOINFO, dwSequenceHeader)) //sizeof *pMpeg2VideoInfo)
{
#define J(x) I(pMpeg2VideoInfo->x)
#define K1(x) sText += AtlFormatString(_T(" * `") _T(#x) _T("`: %s") _T("\r\n"), J(x))
#define K2(x, y) sText += AtlFormatString(_T(" * `") _T(#x) _T("`: %s") _T("\r\n"), I(pMpeg2VideoInfo->x, y))
sText += AtlFormatString(_T(" * ") _T("`hdr.rcSource`: (%s, %s) - (%s, %s)") _T("\r\n"), J(hdr.rcSource.left), J(hdr.rcSource.top), J(hdr.rcSource.right), J(hdr.rcSource.bottom));
sText += AtlFormatString(_T(" * ") _T("`hdr.rcTarget`: (%s, %s) - (%s, %s)") _T("\r\n"), J(hdr.rcTarget.left), J(hdr.rcTarget.top), J(hdr.rcTarget.right), J(hdr.rcTarget.bottom));
K1(hdr.dwBitRate);
K1(hdr.dwBitErrorRate);
sText += AtlFormatString(_T(" * ") _T("`hdr.AvgTimePerFrame`: %s") _T("\r\n"), I(_FilterGraphHelper::FormatReferenceTime(pMpeg2VideoInfo->hdr.AvgTimePerFrame)));
K2(hdr.dwInterlaceFlags, _T("0x%X"));
K2(hdr.dwCopyProtectFlags, _T("0x%X"));
K1(hdr.dwPictAspectRatioX);
K1(hdr.dwPictAspectRatioY);
K2(hdr.dwControlFlags, _T("0x%X"));
K1(hdr.bmiHeader.biSize);
K1(hdr.bmiHeader.biWidth);
K1(hdr.bmiHeader.biHeight);
K1(hdr.bmiHeader.biPlanes);
K1(hdr.bmiHeader.biBitCount);
sText += AtlFormatString(_T(" * ") _T("`hdr.bmiHeader.biCompression`: %s") _T("\r\n"), I(_FilterGraphHelper::GetFourccCodeString(pMpeg2VideoInfo->hdr.bmiHeader.biCompression)));
K1(hdr.bmiHeader.biSizeImage);
K1(hdr.bmiHeader.biXPelsPerMeter);
K1(hdr.bmiHeader.biYPelsPerMeter);
K1(hdr.bmiHeader.biClrUsed);
K1(hdr.bmiHeader.biClrImportant);
K2(dwStartTimeCode, _T("0x%08X"));
K1(cbSequenceHeader);
K1(dwProfile);
K1(dwLevel);
K2(dwFlags, _T("0x%08X"));
#undef J
#undef K1
#undef K2
#undef J
nExtraDataSize = pMediaType->cbFormat - (offsetof(MPEG2VIDEOINFO, dwSequenceHeader) //sizeof *pMpeg2VideoInfo
- sizeof pMpeg2VideoInfo->dwSequenceHeader);
}
} else
#pragma endregion
#pragma region FORMAT_WaveFormatEx
if(pMediaType->formattype == FORMAT_WaveFormatEx)
{
const WAVEFORMATEX* pWaveFormatEx = (const WAVEFORMATEX*) pMediaType->pbFormat;
if(pWaveFormatEx && pMediaType->cbFormat >= sizeof *pWaveFormatEx)
{
if(pWaveFormatEx->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
{
// WARN: Check pMediaType->cbFormat
const WAVEFORMATEXTENSIBLE* pWaveFormatExtensible = (const WAVEFORMATEXTENSIBLE*) pMediaType->pbFormat;
#define J(x) I(pWaveFormatExtensible->x)
#define K1(x) sText += AtlFormatString(_T(" * `") _T(#x) _T("`: %s") _T("\r\n"), J(x))
#define K2(x, y) sText += AtlFormatString(_T(" * `") _T(#x) _T("`: %s") _T("\r\n"), I(pWaveFormatExtensible->x, y))
sText += AtlFormatString(_T(" * ") _T("As `WAVEFORMATEXTENSIBLE`:") _T("\r\n"));
K2(Format.wFormatTag, _T("0x%02X"));
K1(Format.nChannels);
K1(Format.nSamplesPerSec);
K1(Format.nAvgBytesPerSec);
K1(Format.nBlockAlign);
K1(Format.wBitsPerSample);
K1(Format.cbSize);
K1(Samples.wValidBitsPerSample);
K2(dwChannelMask, _T("0x%02X"));
sText += AtlFormatString(_T(" * ") _T("`SubFormat`: %s") _T("\r\n"), I(_PersistHelper::StringFromIdentifier(pWaveFormatExtensible->SubFormat)));
#undef J
#undef K1
#undef K2
nExtraDataSize = pWaveFormatEx->cbSize - (sizeof *pWaveFormatExtensible - sizeof *pWaveFormatEx);
} else
{
#define J(x) I(pWaveFormatEx->x)
#define K1(x) sText += AtlFormatString(_T(" * `") _T(#x) _T("`: %s") _T("\r\n"), J(x))
#define K2(x, y) sText += AtlFormatString(_T(" * `") _T(#x) _T("`: %s") _T("\r\n"), I(pWaveFormatEx->x, y))
K2(wFormatTag, _T("0x%02X"));
K1(nChannels);
K1(nSamplesPerSec);
K1(nAvgBytesPerSec);
K1(nBlockAlign);
K1(wBitsPerSample);
K1(cbSize);
#undef J
#undef K1
#undef K2
nExtraDataSize = pWaveFormatEx->cbSize;
}
}
}
#pragma endregion
#pragma region Extra Data
if(nExtraDataSize)
{
if(!pnExtraData)
{
if(nExtraDataSize > pMediaType->cbFormat)
nExtraDataSize = pMediaType->cbFormat;
pnExtraData = pMediaType->pbFormat + pMediaType->cbFormat - nExtraDataSize;
}
const SSIZE_T nExtraDataExcessSize = (pnExtraData + nExtraDataSize) - (pMediaType->pbFormat + pMediaType->cbFormat);
if(nExtraDataExcessSize > 0)
nExtraDataSize -= min((SIZE_T) nExtraDataExcessSize, nExtraDataSize);
sText += AtlFormatString(_T(" * ") _T("Extra Data: %s") _T("\r\n"), I(AtlFormatData(pnExtraData, nExtraDataSize).TrimRight()));
}
#pragma endregion
return sText;
}
static CString GetText(IFilterGraph* pFilterGraph, const CProcessData* pProcessData = NULL)
{
if(!pFilterGraph)
return (LPCTSTR) NULL;
const CComQIPtr<IServiceProvider> pServiceProvider = pFilterGraph;
const CComQIPtr<ISpy> pSpy = pFilterGraph;
CString sText;
sText += AtlFormatString(_T("# ") _T("Filter Graph") _T("\r\n") _T("\r\n"));
#pragma region Graph Parameters
if(pProcessData)
sText += AtlFormatString(_T("* ") _T("Process: %s (%s) %s") _T("\r\n"), I(pProcessData->m_nIdentifier), I(pProcessData->m_nIdentifier, _T("0x%X")), I(FindFileName(pProcessData->m_sImagePath)));
#pragma region IMediaControl
OAFilterState State = (OAFilterState) -1;
const CComQIPtr<IMediaControl> pMediaControl = pFilterGraph;
if(pMediaControl)
_ATLTRY
{
const HRESULT nGetStateResult = pMediaControl->GetState(0, &State);
_Z45_DSHRESULT(nGetStateResult);
static const LPCTSTR g_ppszStates[] = { _T("Stopped"), _T("Paused"), _T("Running"), };
if(SUCCEEDED(nGetStateResult) && (SIZE_T) State < DIM(g_ppszStates))
sText += AtlFormatString(_T("* ") _T("State: %s") _T("\r\n"), I(g_ppszStates[(SIZE_T) State]));
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
#pragma endregion
#pragma region IMediaPosition
const CComQIPtr<IMediaPosition> pMediaPosition = pFilterGraph;
if(pMediaPosition)
_ATLTRY
{
DOUBLE fDuration = 0, fPosition = 0;
const HRESULT nGetDurationResult = pMediaPosition->get_Duration(&fDuration);
_Z45_DSHRESULT(nGetDurationResult);
if(fDuration > 0)
{
sText += AtlFormatString(_T("* ") _T("Duration: %s (%s seconds)") _T("\r\n"), I(_FilterGraphHelper::FormatSecondTime(fDuration)), I(_StringHelper::FormatNumber(fDuration, 3)));
const HRESULT nCurrentPositionResult = pMediaPosition->get_CurrentPosition(&fPosition);
_Z45_DSHRESULT(nCurrentPositionResult);
if(SUCCEEDED(nCurrentPositionResult))
sText += AtlFormatString(_T("* ") _T("Position: %s (%s seconds)") _T("\r\n"), I(_FilterGraphHelper::FormatSecondTime(fPosition)), I(_StringHelper::FormatNumber(fPosition, 3)));
}
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
#pragma endregion
if(pProcessData)
{
if(!pProcessData->m_sDisplayName.IsEmpty())
sText += AtlFormatString(_T("* ") _T("Display Name: %s") _T("\r\n"), I(pProcessData->m_sDisplayName));
if(_tcslen(pProcessData->m_sImagePath))
{
const CString sDirectory = (LPCTSTR) GetPathDirectory(pProcessData->m_sImagePath);
if(!sDirectory.IsEmpty())
sText += AtlFormatString(_T("* ") _T("Process Directory: %s") _T("\r\n"), I(sDirectory));
}
}
const CComQIPtr<IMediaFilter> pMediaFilter = pFilterGraph;
CComPtr<IReferenceClock> pFilterGraphReferenceClock;
const HRESULT nGetSyncSourceResult = pMediaFilter->GetSyncSource(&pFilterGraphReferenceClock);
_Z45_DSHRESULT(nGetSyncSourceResult);
sText += _T("\r\n");
#pragma endregion
#pragma region Filter
_FilterGraphHelper::CFilterArray FilterArray;
_FilterGraphHelper::GetGraphFilters(pFilterGraph, FilterArray);
if(!FilterArray.IsEmpty())
{
sText += AtlFormatString(_T("## ") _T("Filters") _T("\r\n") _T("\r\n"));
for(SIZE_T nIndex = 0; nIndex < FilterArray.GetCount(); nIndex++)
_ATLTRY
{
const CComPtr<IBaseFilter>& pBaseFilter = FilterArray[nIndex];
sText += AtlFormatString(_T("%d. ") _T("%ls") _T("\r\n"), nIndex + 1, _FilterGraphHelper::GetFilterName(pBaseFilter));
sText += GetFilterText(pBaseFilter, pProcessData, pFilterGraphReferenceClock);
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
sText += _T("\r\n");
#pragma region Connection
sText += AtlFormatString(_T("## ") _T("Connections") _T("\r\n") _T("\r\n"));
INT nConnectionIndex = 0;
for(auto&& pBaseFilter: FilterArray)
{
_FilterGraphHelper::CPinArray PinArray;
_FilterGraphHelper::GetFilterPins(pBaseFilter, PINDIR_OUTPUT, PinArray);
for(auto&& pOutputPin: PinArray)
{
const CComPtr<IPin> pInputPin = _FilterGraphHelper::GetPeerPin(pOutputPin);
if(!pInputPin)
continue;
sText += AtlFormatString(_T("%d. ") _T("%s") _T("\r\n"), ++nConnectionIndex, GetConnectionText(pOutputPin, pInputPin));
}
}
sText += _T("\r\n");
#pragma endregion
#pragma region Media Type
sText += AtlFormatString(_T("## ") _T("Media Types") _T("\r\n") _T("\r\n"));
INT nGlobalPinIndex = 0;
CRoListT<CComPtr<IPin>> PinList;
for(SIZE_T nFilterIndex = 0; nFilterIndex < FilterArray.GetCount(); nFilterIndex++)
{
const CComPtr<IBaseFilter>& pBaseFilter = FilterArray[nFilterIndex];
_FilterGraphHelper::CPinArray PinArray;
_FilterGraphHelper::GetFilterPins(pBaseFilter, PinArray);
for(SIZE_T nPinIndex = 0; nPinIndex < PinArray.GetCount(); nPinIndex++)
{
const CComPtr<IPin>& pPin = PinArray[nPinIndex];
if(PinList.FindFirst(pPin))
continue;
PinList.AddTail(pPin);
CString sPinText = AtlFormatString(_T("%s"), I(_FilterGraphHelper::GetPinFullName(pPin)));
const CComPtr<IPin> pPeerPin = _FilterGraphHelper::GetPeerPin(pPin);
if(pPeerPin)
{
PinList.AddTail(pPeerPin);
sPinText += AtlFormatString(_T(", %s"), I(_FilterGraphHelper::GetPinFullName(pPeerPin)));
}
sText += AtlFormatString(_T("%d. ") _T("%s") _T("\r\n"), ++nGlobalPinIndex, sPinText);
_ATLTRY
{
CMediaType pMediaType;
if(pPeerPin)
pMediaType = _FilterGraphHelper::GetPinMediaType(pPin);
else
pMediaType = _FilterGraphHelper::EnumerateFirstPinMediaType(pPin);
if(!pMediaType)
continue;
sText += GetMediaTypeText(pMediaType);
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
}
}
sText += _T("\r\n");
#pragma endregion
if(State > State_Stopped)
{
#pragma region Memory Allocator
INT nConnectionIndex = 0;
for(auto&& pBaseFilter: FilterArray)
{
_FilterGraphHelper::CPinArray PinArray;
_FilterGraphHelper::GetFilterPins(pBaseFilter, PINDIR_INPUT, PinArray);
for(auto&& pInputPin: PinArray)
{
_ATLTRY
{
const CComQIPtr<IMemInputPin> pMemInputPin = pInputPin;
if(!pMemInputPin)
continue; // No IMemInputPin
const CComPtr<IPin> pOutputPin = _FilterGraphHelper::GetPeerPin(pInputPin);
if(!pOutputPin)
continue; // Not Connected
CComPtr<IMemAllocator> pMemAllocator;
pMemInputPin->GetAllocator(&pMemAllocator);
if(!pMemAllocator)
continue; // No Memory Allocator
ALLOCATOR_PROPERTIES Properties;
const HRESULT nGetPropertiesResult = pMemAllocator->GetProperties(&Properties);
_Z45_DSHRESULT(nGetPropertiesResult);
if(FAILED(nGetPropertiesResult))
continue; // No Memory Allocator Properties
const CComQIPtr<IMemAllocatorCallbackTemp> pMemAllocatorCallbackTemp = pMemAllocator;
BOOL bFreeCountAvailable;
LONG nFreeCount;
if(pMemAllocatorCallbackTemp)
{
const HRESULT nGetFreeCountResult = pMemAllocatorCallbackTemp->GetFreeCount(&nFreeCount);
_Z45_DSHRESULT(nGetFreeCountResult);
bFreeCountAvailable = SUCCEEDED(nGetFreeCountResult);
} else
bFreeCountAvailable = FALSE;
CString sConnectionText = AtlFormatString(_T("%s - %s"), I(_FilterGraphHelper::GetPinFullName(pInputPin)), I(_FilterGraphHelper::GetPinFullName(pOutputPin)));
sConnectionText += _T(": ");
CRoArrayT<CString> Array;
Array.Add(AtlFormatString(_T("%s buffers"), I(Properties.cBuffers)));
if(bFreeCountAvailable)
Array.Add(AtlFormatString(_T("%s free buffers"), I(nFreeCount)));
Array.Add(AtlFormatString(_T("%s bytes per buffer"), I(Properties.cbBuffer)));
if(Properties.cbAlign > 1)
Array.Add(AtlFormatString(_T("%s byte alignment"), I(Properties.cbAlign)));
if(Properties.cbPrefix > 0)
Array.Add(AtlFormatString(_T("%s byte prefix"), I(Properties.cbPrefix)));
sConnectionText += _StringHelper::Join(Array, _T(", "));
if(!nConnectionIndex)
sText += AtlFormatString(_T("## ") _T("Memory Allocators") _T("\r\n") _T("\r\n"));
sText += AtlFormatString(_T("%d. ") _T("%s") _T("\r\n"), ++nConnectionIndex, sConnectionText);
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
}
}
if(nConnectionIndex)
sText += _T("\r\n");
#pragma endregion
}
#pragma region IMediaSeeking
BOOL bMediaSeekingHeaderAdded = FALSE;
for(SIZE_T nFilterIndex = 0; nFilterIndex < FilterArray.GetCount(); nFilterIndex++)
{
const CComPtr<IBaseFilter>& pBaseFilter = FilterArray[nFilterIndex];
_FilterGraphHelper::CPinArray PinArray;
_FilterGraphHelper::GetFilterPins(pBaseFilter, PINDIR_OUTPUT, PinArray);
for(SIZE_T nPinIndex = 0; nPinIndex < PinArray.GetCount(); nPinIndex++)
{
const CComPtr<IPin>& pOutputPin = PinArray[nPinIndex];
const CComQIPtr<IMediaSeeking> pMediaSeeking = pOutputPin;
if(!pMediaSeeking)
continue;
if(!bMediaSeekingHeaderAdded)
{
sText += AtlFormatString(_T("## ") _T("Media Seeking/Position") _T("\r\n") _T("\r\n"));
bMediaSeekingHeaderAdded = TRUE;
}
sText += AtlFormatString(_T("* ") _T("Pin: %s") _T("\r\n"), I(_FilterGraphHelper::GetPinFullName(pOutputPin)));
_ATLTRY
{
DWORD nCapabilities = 0;
if(SUCCEEDED(pMediaSeeking->GetCapabilities(&nCapabilities)))
sText += AtlFormatString(_T(" * ") _T("Capabilities: %s") _T("\r\n"), I(AtlFormatString(_T("0x%X"), nCapabilities)));
LONGLONG nDuration = 0, nPosition = 0, nStopPosition = 0;
if(SUCCEEDED(pMediaSeeking->GetDuration(&nDuration)))
sText += AtlFormatString(_T(" * ") _T("Duration: %s (%s seconds)") _T("\r\n"), I(_FilterGraphHelper::FormatSecondTime((DOUBLE) nDuration / 1E7)), I(_StringHelper::FormatNumber((DOUBLE) nDuration / 1E7, 3)));
if(SUCCEEDED(pMediaSeeking->GetCurrentPosition(&nPosition)))
sText += AtlFormatString(_T(" * ") _T("Position: %s (%s seconds)") _T("\r\n"), I(_FilterGraphHelper::FormatSecondTime((DOUBLE) nPosition / 1E7)), I(_StringHelper::FormatNumber((DOUBLE) nPosition / 1E7, 3)));
if(SUCCEEDED(pMediaSeeking->GetStopPosition(&nStopPosition)))
sText += AtlFormatString(_T(" * ") _T("Stop Position: %s (%s seconds)") _T("\r\n"), I(_FilterGraphHelper::FormatSecondTime((DOUBLE) nStopPosition / 1E7)), I(_StringHelper::FormatNumber((DOUBLE) nStopPosition / 1E7, 3)));
DOUBLE fRate = 1.0;
if(SUCCEEDED(pMediaSeeking->GetRate(&fRate)))
sText += AtlFormatString(_T(" * ") _T("Rate: %s") _T("\r\n"), I(_StringHelper::FormatNumber(fRate, 3)));
LONGLONG nPreroll = 0;
if(SUCCEEDED(pMediaSeeking->GetPreroll(&nPreroll)) && nPreroll)
sText += AtlFormatString(_T(" * ") _T("Preroll: %s seconds") _T("\r\n"), I(_StringHelper::FormatNumber((DOUBLE) nPreroll / 1E7, 3)));
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
}
}
if(bMediaSeekingHeaderAdded)
sText += _T("\r\n");
#pragma endregion
#pragma region Runtime Property Bag
const CString sRunPropertyBagHeader = AtlFormatString(_T("## ") _T("Runtime Properties") _T("\r\n") _T("\r\n"));
BOOL bRunPropertyBagHeaderAdded = FALSE;
{
const CString sPropertyBagText = CRunPropertyBagHelper::GetPropertyBagText(pFilterGraph, pSpy);
if(!sPropertyBagText.IsEmpty())
{
sText += sRunPropertyBagHeader;
bRunPropertyBagHeaderAdded = TRUE;
sText += sPropertyBagText;
sText += _T("\r\n");
}
}
for(auto&& pBaseFilter: FilterArray)
{
_ATLTRY
{
const CString sPropertyBagText = CRunPropertyBagHelper::GetPropertyBagText(pBaseFilter, pSpy);
if(sPropertyBagText.IsEmpty())
continue;
if(!bRunPropertyBagHeaderAdded)
{
sText += sRunPropertyBagHeader;
bRunPropertyBagHeaderAdded = TRUE;
}
sText += AtlFormatString(_T("### ") _T("Filter: %ls") _T("\r\n") _T("\r\n"), _FilterGraphHelper::GetFilterName(pBaseFilter));
sText += sPropertyBagText;
sText += _T("\r\n");
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
}
#pragma endregion
}
#pragma endregion
#pragma region Clock
{
sText += AtlFormatString(_T("## ") _T("Clock") _T("\r\n") _T("\r\n"));
CComPtr<IReferenceClock> pCurrentReferenceClock;
_ATLTRY
{
const CComQIPtr<IMediaFilter> pMediaFilter = pFilterGraph;
if(pMediaFilter)
__C(pMediaFilter->GetSyncSource(&pCurrentReferenceClock));
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
CStringW sCurrentName;
for(auto&& pBaseFilter: FilterArray)
{
const CComQIPtr<IReferenceClock> pReferenceClock = pBaseFilter;
if(!pReferenceClock)
continue;
const CStringW sName = _FilterGraphHelper::GetFilterName(pBaseFilter);
CRoArrayT<CString> Array;
_ATLTRY
{
if(pCurrentReferenceClock == pReferenceClock)
{
sCurrentName = sName;
Array.Add(_T("Current"));
}
Array.Add(I(pReferenceClock));
REFERENCE_TIME nTime = 0;
__C(pReferenceClock->GetTime(&nTime));
Array.Add(I(_FilterGraphHelper::FormatReferenceTime(nTime)));
Array.Add(I(AtlFormatString(_T("0x%I64X"), nTime)));
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
sText += AtlFormatString(_T(" * ") _T("%s (%s)") _T("\r\n"), I(sName), _StringHelper::Join(Array, _T(", ")));
}
if(pCurrentReferenceClock)
{
if(sCurrentName.IsEmpty())
{
CRoArrayT<CString> Array;
_ATLTRY
{
Array.Add(I(pCurrentReferenceClock));
REFERENCE_TIME nTime = 0;
__C(pCurrentReferenceClock->GetTime(&nTime));
Array.Add(I(_FilterGraphHelper::FormatReferenceTime(nTime)));
Array.Add(I(AtlFormatString(_T("0x%I64X"), nTime)));
}
_ATLCATCHALL()
{
_Z_EXCEPTION();
}
sText += AtlFormatString(_T(" * ") _T("Current: External (%s)") _T("\r\n"), _StringHelper::Join(Array, _T(", ")));
}
} else
sText += AtlFormatString(_T(" * ") _T("Current: None") _T("\r\n"));
sText += _T("\r\n");
}
#pragma endregion
return sText;
}
#undef I
CComPtr<IFilterGraph> GetFilterGraph() const
{
CRoCriticalSectionLock DataLock(m_DataCriticalSection);
return m_pFilterGraph;
}
VOID SetFilterGraph(IFilterGraph* pFilterGraph, CProcessData* pProcessData = NULL)
{
CRoCriticalSectionLock DataLock(m_DataCriticalSection);
if(!pProcessData)
{
m_ProcessData = CProcessData();
const CComQIPtr<ISpyEx> pSpyEx = pFilterGraph;
if(pSpyEx)
m_ProcessData.m_nIdentifier = GetCurrentProcessId();
} else
m_ProcessData = *pProcessData;
m_pFilterGraph = pFilterGraph;
}
BOOL SetFilterGraph(IUnknown* pFilterGraphUnknown, CProcessData* pProcessData = NULL)
{
CComQIPtr<IFilterGraph> pFilterGraph;
if(pFilterGraphUnknown)
{
pFilterGraph = pFilterGraphUnknown;
if(!pFilterGraph)
{
const CComQIPtr<IBaseFilter> pBaseFilter = pFilterGraphUnknown;
if(!pBaseFilter)
{
const CComQIPtr<IPin> pPin = pFilterGraphUnknown;
if(pPin)
pFilterGraph = _FilterGraphHelper::GetFilterGraph(_FilterGraphHelper::GetPinFilter(pPin));
} else
pFilterGraph = _FilterGraphHelper::GetFilterGraph(pBaseFilter);
}
}
SetFilterGraph(pFilterGraph, pProcessData);
return pFilterGraph != NULL;
}
CString GetFilterText(IBaseFilter* pBaseFilter) const
{
return GetFilterText(pBaseFilter, m_ProcessData.m_nIdentifier ? &m_ProcessData : NULL);
}
CString GetText() const
{
CRoCriticalSectionLock DataLock(m_DataCriticalSection);
return GetText(m_pFilterGraph, m_ProcessData.m_nIdentifier ? &m_ProcessData : NULL);
}
static LPCTSTR GetPlatformName()
{
#if defined(_WIN64)
return _T("x64");
#else
return _T("Win32");
#endif // defined(_WIN64)
}
static BOOL OpenMonikerWithGsn(LPCWSTR pszMonikerDisplayName, HWND hParentWindow = GetActiveWindow())
{
_A(pszMonikerDisplayName);
static const LPCTSTR g_pszValueName = _T("GraphStudioNext Path");
static const LPCTSTR g_pszFileName = _T("graphstudionext.exe");
const CString sValueName = AtlFormatString(_T("%s (%s)"), g_pszValueName, GetPlatformName());
CString sPath = _RegKeyHelper::QueryStringValue(HKEY_CURRENT_USER, REGISTRY_ROOT, sValueName);
if(!FileExists(sPath))
sPath.Empty();
#pragma region Current Directory
if(sPath.IsEmpty())
{
sPath = (LPCTSTR) Combine(GetPathDirectory(GetModulePath()), g_pszFileName);
if(!FileExists(sPath))
sPath.Empty();
}
#pragma endregion
#pragma region Application Registry
if(sPath.IsEmpty())
{
#if defined(_WIN64)
static const LPCTSTR g_pszValueName = _T("exeLocation64");
#else
static const LPCTSTR g_pszValueName = _T("exeLocation");
#endif // defined(_WIN64)
sPath = _RegKeyHelper::QueryStringValue(HKEY_CURRENT_USER, _T("Software\\MONOGRAM\\GraphStudioNext"), g_pszValueName);
if(!FileExists(sPath))
sPath.Empty();
}
#pragma endregion
if(sPath.IsEmpty())
{
static const COMDLG_FILTERSPEC g_pFilter[] =
{
{ _T("Executable Files"), _T("*.exe") },
{ _T("All Files"), _T("*.*") },
};
sPath = (LPCTSTR) _CommonDialogHelper::QueryOpenPath(hParentWindow, g_pFilter, _T("exe"), g_pszFileName);
if(sPath.IsEmpty())
return FALSE;
_RegKeyHelper::SetStringValue(HKEY_CURRENT_USER, REGISTRY_ROOT, sValueName, sPath);
}
CWaitCursor WaitCursor;
CString sParameters = AtlFormatString(_T("-a \"%ls\""), pszMonikerDisplayName);
SHELLEXECUTEINFO Infomation;
ZeroMemory(&Infomation, sizeof Infomation);
Infomation.cbSize = sizeof Infomation;
Infomation.lpFile = sPath;
Infomation.lpParameters = sParameters;
Infomation.nShow = SW_SHOWNORMAL;
__E(ShellExecuteEx(&Infomation));
return TRUE;
}
static BOOL OpenMonikerWithGe(LPCWSTR pszMonikerDisplayName, HWND hParentWindow = GetActiveWindow())
{
static const LPCTSTR g_pszValueName = _T("GraphEdit Path");
static const LPCTSTR g_pszFileName = _T("graphedt.exe");
const CString sValueName = AtlFormatString(_T("%s (%s)"), g_pszValueName, GetPlatformName());
CString sPath = _RegKeyHelper::QueryStringValue(HKEY_CURRENT_USER, REGISTRY_ROOT, sValueName);
if(!FileExists(sPath))
sPath.Empty();
#pragma region Current Directory
if(sPath.IsEmpty())
{
sPath = (LPCTSTR) Combine(GetPathDirectory(GetModulePath()), g_pszFileName);
if(!FileExists(sPath))
sPath.Empty();
}
#pragma endregion
// SUGG: Look for Windows SDK
if(sPath.IsEmpty())
{
static const COMDLG_FILTERSPEC g_pFilter[] =
{
{ _T("Executable Files"), _T("*.exe") },
{ _T("All Files"), _T("*.*") },
};
sPath = (LPCTSTR) _CommonDialogHelper::QueryOpenPath(hParentWindow, g_pFilter, _T("exe"), g_pszFileName);
if(sPath.IsEmpty())
return FALSE;
_RegKeyHelper::SetStringValue(HKEY_CURRENT_USER, REGISTRY_ROOT, sValueName, sPath);
}
CStringW sFilterGraphMonikerDisplayName = pszMonikerDisplayName;
const INT nSeparatorPosition = sFilterGraphMonikerDisplayName.Find(L';');
if(nSeparatorPosition >= 0)
sFilterGraphMonikerDisplayName = sFilterGraphMonikerDisplayName.Left(nSeparatorPosition);
CWaitCursor WaitCursor;
CString sParameters = AtlFormatString(_T("-a %ls"), sFilterGraphMonikerDisplayName);
SHELLEXECUTEINFO Infomation;
ZeroMemory(&Infomation, sizeof Infomation);
Infomation.cbSize = sizeof Infomation;
Infomation.lpFile = sPath;
Infomation.lpParameters = sParameters;
Infomation.nShow = SW_SHOWNORMAL;
__E(ShellExecuteEx(&Infomation));
return TRUE;
}
// IFilterGraphHelper
STDMETHOD(get_FilterGraph)(IUnknown** ppFilterGraphUnknown) override
{
_Z4(atlTraceCOM, 4, _T("...\n"));
_ATLTRY
{
__D(ppFilterGraphUnknown, E_POINTER);
*ppFilterGraphUnknown = GetFilterGraph().Detach();
}
_ATLCATCH(Exception)
{
_C(Exception);
}
return S_OK;
}
STDMETHOD(put_FilterGraph)(IUnknown* pFilterGraphUnknown) override
{
_Z4(atlTraceCOM, 4, _T("pFilterGraphUnknown 0x%p\n"), pFilterGraphUnknown);
_ATLTRY
{
if(!SetFilterGraph(pFilterGraphUnknown))
return S_FALSE;
}
_ATLCATCH(Exception)
{
_C(Exception);
}
return S_OK;
}
STDMETHOD(get_Text)(BSTR* psText) override
{
_Z4(atlTraceCOM, 4, _T("...\n"));
_ATLTRY
{
__D(psText, E_POINTER);
CRoCriticalSectionLock DataLock(m_DataCriticalSection);
*psText = CComBSTR(GetText(m_pFilterGraph)).Detach();
}
_ATLCATCH(Exception)
{
_C(Exception);
}
return S_OK;
}
STDMETHOD(DoPropertyFrameModal)(LONG nParentWindowHandle) override
{
_Z4(atlTraceCOM, 4, _T("nParentWindowHandle 0x%08X\n"), nParentWindowHandle);
_ATLTRY
{
CWindow ParentWindow = (HWND) (LONG_PTR) nParentWindowHandle;
if(!ParentWindow)
ParentWindow = GetActiveWindow();
//__D(!ParentWindow || ParentWindow.IsWindow(), E_INVALIDARG);
const CComQIPtr<IFilterGraph2> pFilterGraph2 = GetFilterGraph();
__D(pFilterGraph2, E_NOINTERFACE);
CPropertyFrameDialog PropertyFrameDialog(this);
PropertyFrameDialog.DoModal(ParentWindow);
}
_ATLCATCH(Exception)
{
_C(Exception);
}
return S_OK;
}
STDMETHOD(DoFilterGraphListModal)(LONG nParentWindowHandle) override
{
_Z4(atlTraceCOM, 4, _T("nParentWindowHandle 0x%08X\n"), nParentWindowHandle);
_ATLTRY
{
CWindow ParentWindow = (HWND) (LONG_PTR) nParentWindowHandle;
if(!ParentWindow)
ParentWindow = GetActiveWindow();
//__D(!ParentWindow || ParentWindow.IsWindow(), E_INVALIDARG);
DoFilterGraphListPropertySheetModal(ParentWindow, &m_Options);
}
_ATLCATCH(Exception)
{
_C(Exception);
}
return S_OK;
}
STDMETHOD(OpenGraphStudioNext)(LONG nParentWindowHandle, BSTR sMonikerDisplayName, VARIANT_BOOL* pbResult) override
{
_Z4(atlTraceCOM, 4, _T("nParentWindowHandle 0x%08X, sMonikerDisplayName \"%s\"\n"), nParentWindowHandle, CString(sMonikerDisplayName));
_ATLTRY
{
__D(sMonikerDisplayName && *sMonikerDisplayName, E_INVALIDARG);
CWindow ParentWindow = (HWND) (LONG_PTR) nParentWindowHandle;
if(!ParentWindow)
ParentWindow = GetActiveWindow();
//__D(!ParentWindow || ParentWindow.IsWindow(), E_INVALIDARG);
const BOOL bResult = OpenMonikerWithGsn(sMonikerDisplayName, ParentWindow);
if(pbResult)
*pbResult = bResult ? ATL_VARIANT_TRUE : ATL_VARIANT_FALSE;
}
_ATLCATCH(Exception)
{
_C(Exception);
}
return S_OK;
}
STDMETHOD(OpenGraphEdit)(LONG nParentWindowHandle, BSTR sMonikerDisplayName, VARIANT_BOOL* pbResult) override
{
_Z4(atlTraceCOM, 4, _T("nParentWindowHandle 0x%08X, sMonikerDisplayName \"%s\"\n"), nParentWindowHandle, CString(sMonikerDisplayName));
_ATLTRY
{
__D(sMonikerDisplayName && *sMonikerDisplayName, E_INVALIDARG);
CWindow ParentWindow = (HWND) (LONG_PTR) nParentWindowHandle;
if(!ParentWindow)
ParentWindow = GetActiveWindow();
//__D(!ParentWindow || ParentWindow.IsWindow(), E_INVALIDARG);
const BOOL bResult = OpenMonikerWithGe(sMonikerDisplayName, ParentWindow);
if(pbResult)
*pbResult = bResult ? ATL_VARIANT_TRUE : ATL_VARIANT_FALSE;
}
_ATLCATCH(Exception)
{
_C(Exception);
}
return S_OK;
}
STDMETHOD(get_Options)(VARIANT* pvOptions) override
{
_Z4(atlTraceCOM, 4, _T("this 0x%p\n"), this);
_ATLTRY
{
__D(pvOptions, E_POINTER);
VariantInit(pvOptions);
__C(m_Options.GetVariant().Detach(pvOptions));
}
_ATLCATCH(Exception)
{
_C(Exception);
}
return S_OK;
}
STDMETHOD(put_Options)(VARIANT vOptions) override
{
_Z4(atlTraceCOM, 4, _T("this 0x%p, vOptions.vt %s\n"), this, reinterpret_cast<CComVariantArray&>(vOptions).FormatType());
_ATLTRY
{
m_Options.SetVariant(vOptions);
}
_ATLCATCH(Exception)
{
_C(Exception);
}
return S_OK;
}
STDMETHOD(ResetMediaSampleTrace)(VARIANT vProcessIdentifier) override
{
_Z4(atlTraceCOM, 4, _T("this 0x%p, vProcessIdentifier %s\n"), this, reinterpret_cast<CComVariantArray&>(vProcessIdentifier).Format(TRUE));
_ATLTRY
{
DWORD nProcessIdentifier = 0;
if(vProcessIdentifier.vt > VT_NULL)
nProcessIdentifier = (DWORD) reinterpret_cast<CComVariantArray&>(vProcessIdentifier).GetAsType(VT_I4).lVal;
MediaSampleTrace_Reset(nProcessIdentifier);
}
_ATLCATCH(Exception)
{
_C(Exception);
}
return S_OK;
}
STDMETHOD(LockMediaSampleTrace)(IUnknown** ppLockUnknown) override
{
_Z4(atlTraceCOM, 4, _T("this 0x%p\n"), this);
_ATLTRY
{
__D(ppLockUnknown, E_POINTER);
*ppLockUnknown = MediaSampleTrace_Lock().Detach();
}
_ATLCATCH(Exception)
{
_C(Exception);
}
return S_OK;
}
STDMETHOD(GetMediaSampleTrace)(VARIANT vProcessIdentifier, BSTR* psText) override
{
_Z4(atlTraceCOM, 4, _T("this 0x%p, vProcessIdentifier %s\n"), this, reinterpret_cast<CComVariantArray&>(vProcessIdentifier).Format(TRUE));
_ATLTRY
{
__D(psText, E_POINTER);
DWORD nProcessIdentifier = 0;
if(vProcessIdentifier.vt > VT_NULL)
nProcessIdentifier = (DWORD) reinterpret_cast<CComVariantArray&>(vProcessIdentifier).GetAsType(VT_I4).lVal;
*psText = CComBSTR(MediaSampleTrace_Get(nProcessIdentifier)).Detach();
}
_ATLCATCH(Exception)
{
_C(Exception);
}
return S_OK;
}
};
OBJECT_ENTRY_AUTO(__uuidof(FilterGraphHelper), CFilterGraphHelper)
inline HRESULT FilterGraphHelper_DoPropertyFrameModal(LONG nParentWindowHandle, IUnknown* pFilterGraphUnknown)
{
CLocalObjectPtr<CFilterGraphHelper> pFilterGraphHelper;
pFilterGraphHelper->SetFilterGraph(pFilterGraphUnknown);
return pFilterGraphHelper->DoPropertyFrameModal(nParentWindowHandle);
}
inline HRESULT FilterGraphHelper_DoFilterGraphListModal(LONG nParentWindowHandle)
{
CLocalObjectPtr<CFilterGraphHelper> pFilterGraphHelper;
return pFilterGraphHelper->DoFilterGraphListModal(nParentWindowHandle);
}
inline HRESULT FilterGraphHelper_OpenGraphStudioNext(LONG nParentWindowHandle, LPCWSTR pszMonikerDisplayName, VARIANT_BOOL* pbResult)
{
CLocalObjectPtr<CFilterGraphHelper> pFilterGraphHelper;
return pFilterGraphHelper->OpenGraphStudioNext(nParentWindowHandle, CComBSTR(pszMonikerDisplayName), pbResult);
}
inline HRESULT FilterGraphHelper_OpenGraphEdit(LONG nParentWindowHandle, LPCWSTR pszMonikerDisplayName, VARIANT_BOOL* pbResult)
{
CLocalObjectPtr<CFilterGraphHelper> pFilterGraphHelper;
return pFilterGraphHelper->OpenGraphEdit(nParentWindowHandle, CComBSTR(pszMonikerDisplayName), pbResult);
}
|
[
"roman@9f0a43ce-f1ea-4ba9-b87d-1d20923592e0"
] |
roman@9f0a43ce-f1ea-4ba9-b87d-1d20923592e0
|
e614274865907265f9a32b7f82514622471c0ce4
|
338ada9f31639dbb5c36a44aed779f7c19c5fbde
|
/Analytical Report/Analysis/Analysis.cpp
|
5337d386b5d0822cc3e6ab388b6d4b5dd031422e
|
[
"MIT"
] |
permissive
|
kev-fung/Mineral-Recovery
|
30003a9da683d0ffe1bbfce6378e91eb0630f744
|
338a3cec586180873fc1f22fb38ab14823122236
|
refs/heads/master
| 2020-09-12T14:45:48.533740
| 2019-11-26T14:01:15
| 2019-11-26T14:01:15
| 222,455,410
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 9,479
|
cpp
|
#include <iostream>
#include <vector>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <string>
#include "Genetic_Algorithm.h"
#include "Circuit.h"
using namespace std;
void analysis1(string name, int num_units, int num_circuits, double prob_CO, double prob_Mut, double tol, double max_iter, int bestIndCnt, int minIte, int maxIte, bool time_GA, int avg_q, int quant, double model[6])
{
vector<int> best_circuit;
double ratio;
double avg_fitness;
int avg_it;
double avg_time;
stringstream fname;
fstream f1;
fname << name << ".csv";
f1.open(fname.str().c_str(), ios_base::out);
// Run the GA with varying input parameter x.
for (int x = 0; x < quant; x++)
{
avg_fitness = 0.;
avg_it = 0.;
avg_time = 0.;
// MUST CHANGE THIS!!!
ratio = (double)(x + 1) / ((double)quant / 2); // 0 - 1 range
// prob_Mut = ((double)(x + 1) / (double)quant) / 40.;
f1 << ratio;
model[0] = -model[1] * ratio;
cout << "TESTING: " << ratio << endl;
// Run the GA avg_q times to work out the average fitness.
for (int i = 0; i < avg_q; i++)
{
Genetic_Algorithm GA(num_units, num_circuits, prob_CO, prob_Mut, tol, max_iter, model, time_GA);
best_circuit = GA.runAlgo(bestIndCnt, minIte, maxIte);
if (time_GA)
{
// Print the output.
cout << "Output best vector" << endl;
for (int j = 0; j < 2 * num_units + 1; j++)
{
cout << best_circuit[j] << " ";
}
}
Circuit circ;
double best_fitness;
best_fitness = circ.Evaluate_Circuit(best_circuit, tol, max_iter);
cout << "Fitness: " << best_fitness;
cout << endl;
avg_fitness += best_fitness / avg_q;
avg_it += GA.it / avg_q;
avg_time += GA.tdif / avg_q;
}
cout << endl;
f1 << "," << avg_fitness << "," << avg_it << "," << avg_time << endl;
}
f1.close();
}
void analysis2(string name, int num_units, int num_circuits, double prob_CO, double prob_Mut, double tol, double max_iter, int bestIndCnt, int minIte, int maxIte, bool time_GA, int avg_q, int quant, double model[6])
{
vector<int> best_circuit;
double ratio;
double avg_fitness;
int avg_it;
double avg_time;
stringstream fname;
fstream f1;
fname << name << ".csv";
f1.open(fname.str().c_str(), ios_base::out);
// Run the GA with varying input parameter x.
for (int x = 0; x < quant; x++)
{
avg_fitness = 0.;
avg_it = 0.;
avg_time = 0.;
// MUST CHANGE THIS!!!
ratio = (double)(x + 1) / ((double)quant / 2); // 0 - 1 range
// prob_Mut = ((double)(x + 1) / (double)quant) / 40.;
f1 << ratio;
model[2] = -model[3] * ratio;
cout << "TESTING: " << ratio << endl;
// Run the GA avg_q times to work out the average fitness.
for (int i = 0; i < avg_q; i++)
{
Genetic_Algorithm GA(num_units, num_circuits, prob_CO, prob_Mut, tol, max_iter, model, time_GA);
best_circuit = GA.runAlgo(bestIndCnt, minIte, maxIte);
if (time_GA)
{
// Print the output.
cout << "Output best vector" << endl;
for (int j = 0; j < 2 * num_units + 1; j++)
{
cout << best_circuit[j] << " ";
}
}
Circuit circ;
double best_fitness;
best_fitness = circ.Evaluate_Circuit(best_circuit, tol, max_iter);
cout << "Fitness: " << best_fitness;
cout << endl;
avg_fitness += best_fitness / avg_q;
avg_it += GA.it / avg_q;
avg_time += GA.tdif / avg_q;
}
cout << endl;
f1 << "," << avg_fitness << "," << avg_it << "," << avg_time << endl;
}
f1.close();
}
void analysis3(string name, int num_units, int num_circuits, double prob_CO, double prob_Mut, double tol, double max_iter, int bestIndCnt, int minIte, int maxIte, bool time_GA, int avg_q, int quant, double model[6])
{
vector<int> best_circuit;
double ratio;
double avg_fitness;
int avg_it;
double avg_time;
stringstream fname;
fstream f1;
fname << name << ".csv";
f1.open(fname.str().c_str(), ios_base::out);
// Run the GA with varying input parameter x.
for (int x = 0; x < quant; x++)
{
avg_fitness = 0.;
avg_it = 0.;
avg_time = 0.;
// MUST CHANGE THIS!!!
ratio = (double)(x + 1) / ((double)quant / 2); // 0 - 1 range
// prob_Mut = ((double)(x + 1) / (double)quant) / 40.;
f1 << ratio;
model[4] = -model[5] * ratio;
cout << "TESTING: " << ratio << endl;
// Run the GA avg_q times to work out the average fitness.
for (int i = 0; i < avg_q; i++)
{
Genetic_Algorithm GA(num_units, num_circuits, prob_CO, prob_Mut, tol, max_iter, model, time_GA);
best_circuit = GA.runAlgo(bestIndCnt, minIte, maxIte);
if (time_GA)
{
// Print the output.
cout << "Output best vector" << endl;
for (int j = 0; j < 2 * num_units + 1; j++)
{
cout << best_circuit[j] << " ";
}
}
Circuit circ;
double best_fitness;
best_fitness = circ.Evaluate_Circuit(best_circuit, tol, max_iter);
cout << "Fitness: " << best_fitness;
cout << endl;
avg_fitness += best_fitness / avg_q;
avg_it += GA.it / avg_q;
avg_time += GA.tdif / avg_q;
}
cout << endl;
f1 << "," << avg_fitness << "," << avg_it << "," << avg_time << endl;
}
f1.close();
}
void analysis(string name, int num_units, int num_circuits, double prob_CO, double prob_Mut, double tol, double max_iter, int bestIndCnt, int minIte, int maxIte, bool time_GA, int avg_q, int quant, double model[6])
{
vector<int> best_circuit;
double waste;
double avg_fitness;
int avg_it;
double avg_time;
stringstream fname;
fstream f1;
fname << name << ".csv";
f1.open(fname.str().c_str(), ios_base::out);
// Run the GA with varying input parameter x.
for (int x = 0; x < quant; x++)
{
avg_fitness = 0.;
avg_it = 0.;
avg_time = 0.;
// MUST CHANGE THIS!!!
model[1] = ((double)(x) / (10.0 / 2)) * -1000.0; // 0 - 1 range
// prob_Mut = ((double)(x + 1) / (double)quant) / 40.;
f1 << model[1];
cout << "TESTING: " << model[1] << endl;
// Run the GA avg_q times to work out the average fitness.
for (int i = 0; i < avg_q; i++)
{
Genetic_Algorithm GA(num_units, num_circuits, prob_CO, prob_Mut, tol, max_iter, model, time_GA);
best_circuit = GA.runAlgo(bestIndCnt, minIte, maxIte);
if (time_GA)
{
// Print the output.
cout << "Output best vector" << endl;
for (int j = 0; j < 2 * num_units + 1; j++)
{
cout << best_circuit[j] << " ";
}
}
Circuit circ;
double best_fitness;
best_fitness = circ.Evaluate_Circuit(best_circuit, tol, max_iter);
cout << "Fitness: " << best_fitness;
cout << endl;
avg_fitness += best_fitness / avg_q;
avg_it += GA.it / avg_q;
avg_time += GA.tdif / avg_q;
}
cout << endl;
f1 << "," << avg_fitness << "," << avg_it << "," << avg_time << endl;
}
f1.close();
}
int main()
{
// int num_units = 10;
// int num_circuits = 100;
// double prob_CO = 1.;
// double prob_Mut = 0.004;
//
// double circuit_model[6];
// circuit_model[0] = 100.; // cprice
// circuit_model[1] = -500.; // tcost
// circuit_model[2] = 10.; // cfeed
// circuit_model[3] = 100.; // tfeed
// circuit_model[4] = 0.20; // cfrac
// circuit_model[5] = 0.05; // tfrac
//
// double tol = 1e-6;
// double max_iter = 2e3;
//
// int bestIndCnt = 2000; // Minimum number of iterations for the best circuit to be the same
// int minIte = 0; // Minimum number of iterations to be done
// int maxIte = 10000; // Maximum number of iterations possible
// bool time_GA = true;
//
// vector<int> best_circuit;
//
// int avg_q = 5;
// int quant = 10;
//
// // Cprice/tcost ratio
// string file_name = "ctprice_ratio";
// analysis1(file_name, num_units, num_circuits, prob_CO, prob_Mut, tol, max_iter, bestIndCnt, minIte, maxIte, time_GA, avg_q, quant, circuit_model);
//
// // Cfeed/tfeed ratio
// file_name = "ctfeed_ratio";
// analysis2(file_name, num_units, num_circuits, prob_CO, prob_Mut, tol, max_iter, bestIndCnt, minIte, maxIte, time_GA, avg_q, quant, circuit_model);
//
// // Cfrac/tfrac ratio
// file_name = "ctfrac_ratio";
// analysis3(file_name, num_units, num_circuits, prob_CO, prob_Mut, tol, max_iter, bestIndCnt, minIte, maxIte, time_GA, avg_q, quant, circuit_model);
//
//
int num_units = 10;
int num_circuits = 100;
double prob_CO = 1.;
double prob_Mut = 0.004;
double circuit_model[6];
circuit_model[0] = 200.; // cprice
circuit_model[1] = -500.; // tcost
circuit_model[2] = 10.; // cfeed
circuit_model[3] = 100.; // tfeed
circuit_model[4] = 0.20; // cfrac
circuit_model[5] = 0.05; // tfrac
double tol = 1e-6;
double max_iter = 2e3;
int bestIndCnt = 2000; // Minimum number of iterations for the best circuit to be the same
int minIte = 0; // Minimum number of iterations to be done
int maxIte = 10000; // Maximum number of iterations possible
bool time_GA = true;
vector<int> best_circuit;
int avg_q = 5;
int quant = 7;
string name = "PurityvsRecovery";
analysis(name, num_units, num_circuits, prob_CO, prob_Mut, tol, max_iter, bestIndCnt, minIte, maxIte, time_GA, avg_q, quant, circuit_model);
//Genetic_Algorithm GA(num_units, num_circuits, prob_CO, prob_Mut, tol, max_iter, circuit_model, time_GA);
//best_circuit = GA.runAlgo(bestIndCnt, minIte, maxIte);
//if (time_GA)
//{
// // Print the output.
// cout << "Output best vector" << endl;
// for (int j = 0; j < 2 * num_units + 1; j++)
// {
// cout << best_circuit[j] << " ";
// }
//}
//Circuit circ;
//double best_fitness;
//best_fitness = circ.Evaluate_Circuit(best_circuit, tol, max_iter);
//cout << "Fitness: " << best_fitness;
//cout << endl;
system("pause");
return 0;
}
|
[
"deirdree.polak@gmail.com"
] |
deirdree.polak@gmail.com
|
8ba8f459634bf1c284a3a69a32360bf947806f31
|
8663866dca43b34ecdc1fc666b1c6d6fb2774b35
|
/EDAerolineas/grafo.h
|
6ceee0d14b858e4845217acd8d81ed5c1d18b7f7
|
[] |
no_license
|
anthonylle/EDProgra2
|
90932dd40d0a5dbf5d0926790fd52ac86dfc5120
|
9a2b84a24e1a8e4aa0fd727f964720821bd1fb7b
|
refs/heads/master
| 2021-05-31T22:54:40.109307
| 2016-06-09T03:28:54
| 2016-06-09T03:28:54
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 830
|
h
|
#ifndef GRAFO_H
#define GRAFO_H
#include "bstree.h"
#include "nodociudad.h"
#include "matrizadyacencia.h"
class Grafo
{
private:
int contador;
BSTree<int, NodoCiudad* > arbol;/*Árbol binario que guardará un entero identificador y un
puntero a NodoCiudad para guardar la ciudad asignada al identificador*/
std::string nombre;//string que representa el nombre de la ciudad a introducir.
MatrizAdyacencia conexiones;//Inicialización de la matriz de adyacencia.
public:
Grafo();//Declaración del constructor.
~Grafo();//DEclaración del destructor
void insertarCiudad(std::string nombre);//Declaración de método para insertar una ciudad.
NodoCiudad* obtenerCiudad(std::string nombre);//Declaración de método para obtener una ciudad.
};
#endif // GRAFO_H
|
[
"ameyitfabian@gmail.com"
] |
ameyitfabian@gmail.com
|
5ba131cd6d39dd2d8b01d66724ec7b47dda31642
|
4d4e3d98bae55907afdddae21eaa913843ebd99a
|
/cpp/Algorithms/Algorithms/main.cpp
|
b7d978edb09d26e0c917c609c7fdacdf9e9cd31d
|
[] |
no_license
|
tatumalenko/leetcode-codewars-etc
|
587f584eaaed03cb77ec6841bfe4f7e6b2dc516e
|
7c0207e5c645517fd4a6703d79989fe8360261cf
|
refs/heads/master
| 2022-02-26T12:54:13.185050
| 2020-12-02T00:24:54
| 2020-12-02T00:24:54
| 194,419,659
| 0
| 0
| null | 2022-02-12T08:23:28
| 2019-06-29T15:20:33
|
JavaScript
|
UTF-8
|
C++
| false
| false
| 158
|
cpp
|
//
// main.cpp
// Algorithms
//
// Created by Tatum Alenko on 2019-07-08.
// Copyright © 2019 Tatum Alenko. All rights reserved.
//
#include <iostream>
|
[
"tatum.alenko@gmail.com"
] |
tatum.alenko@gmail.com
|
bb9c94472c30138062269312eea196c8ca30bad0
|
7d271763ac289e075ae834dbae8bcc95ab710761
|
/Flyweight_Expr_Command_Factory.h
|
ffb35aba248495cff67a0d9e9d1bef52afff702f
|
[] |
no_license
|
arvindnair/aooadassign5
|
6e1a407fb32092ede3d12ffc5b99abc3dbce6344
|
12fbce92e22eeba36be2f04c05f8c0674b10f005
|
refs/heads/master
| 2020-04-18T00:24:03.042381
| 2016-08-31T23:53:03
| 2016-08-31T23:53:03
| 67,081,779
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,393
|
h
|
//==============================================================================
/**
* Honor Pledge:
*
* I pledge that I have neither given nor received any help
* on this assignment.
*/
//==============================================================================
#ifndef _FLYWEIGHT_EXPR_COMMAND_FACTORY_H_
#define _FLYWEIGHT_EXPR_COMMAND_FACTORY_H_
#include "Expr_Command_Factory.h"
/**
* @class Flyweight_Expr_Command_Factory
*
* Implementation of Flyweight_Expr_Command_Factory.
*/
class Flyweight_Expr_Command_Factory : public Expr_Command_Factory
{
public:
/// Default constructor.
Flyweight_Expr_Command_Factory (void);
/// Destructor.
virtual ~Flyweight_Expr_Command_Factory (void);
/**
* Creates and returns a new Number Command object.
*
* @return New Number Command object.
*/
virtual Num_Command * create_num_command (int num);
/**
* Creates a new Addition Command object and stores in Add variable
* if called for the first time.It returns a reference to add variable.
*
* @return Reference to Add Variable.
*/
virtual Add_Command * create_add_command (void);
/**
* Creates a new Subtraction Command object and stores in Subtract variable
* if called for the first time.It returns a reference to subtract variable.
*
* @return Reference to Subtract Variable.
*/
virtual Subtract_Command * create_subtract_command (void);
/**
* Creates a new Multiplication Command object and stores in Multiply variable
* if called for the first time.It returns a reference to multiply variable.
*
* @return Reference to Subtract Variable.
*/
virtual Multiply_Command * create_multiply_command (void);
/**
* Creates a new Division Command object and stores in Divide variable
* if called for the first time.It returns a reference to Divide variable.
*
* @return Reference to Divide Variable.
*/
virtual Divide_Command * create_divide_command (void);
/**
* Creates a new Modulus Command object and stores in Modulus variable
* if called for the first time.It returns a reference to modulus variable.
*
* @return Reference to modulus Variable.
*/
virtual Modulus_Command * create_modulus_command (void);
/**
* Creates a new Left Parenthesis Command object and stores in Left Parenthesis variable
* if called for the first time.It returns a reference to Left Parenthesis variable.
*
* @return Reference to Left Parenthesis Variable.
*/
virtual Left_Parenthesis_Command * create_left_parenthesis_command (void);
/**
* Creates a new Right Parenthesis Command object and stores in Right Parenthesis variable
* if called for the first time.It returns a reference to Right Parenthesis variable.
*
* @return Reference to Right Parenthesis Variable.
*/
virtual Right_Parenthesis_Command * create_right_parenthesis_command (void);
private:
//Add Command Variable
Add_Command * add_;
//Subtract Command Variable
Subtract_Command * subtract_;
//Multiply Command Variable
Multiply_Command * multiply_;
//Divide Command Variable
Divide_Command * divide_;
//Modulus Command Variable
Modulus_Command * modulus_;
//Left Parenthesis (Open Parenthesis) Variable
Left_Parenthesis_Command * left_par_;
//Right Parenthesis (Right Parenthesis) Variable
Right_Parenthesis_Command * right_par_;
};
#endif // !_FLYWEIGHT_EXPR_COMMAND_FACTORY_H_
|
[
"arvnair@iupui.edu"
] |
arvnair@iupui.edu
|
2ef850505a0170c7ab8bace7582ef571c8cdc23f
|
e3ac6d1aafff3fdfb95159c54925aded869711ed
|
/Temp/StagingArea/Data/il2cppOutput/t948015015.h
|
6a7f68fc1110f195484abc08b48b8d0b01185b1c
|
[] |
no_license
|
charlantkj/refugeeGame-
|
21a80d17cf5c82eed2112f04ac67d8f3b6761c1d
|
d5ea832a33e652ed7cdbabcf740e599497a99e4d
|
refs/heads/master
| 2021-01-01T05:26:18.635755
| 2016-04-24T22:33:48
| 2016-04-24T22:33:48
| 56,997,457
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 549
|
h
|
#pragma once
#include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <stdint.h>
struct t799562310;
struct t537683269;
struct t1363551830;
struct Il2CppObject;
#include "t2585444626.h"
#include "t2779279689.h"
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
struct t948015015 : public t2585444626
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
|
[
"charlotteantschukovkjaer@Charlottes-MacBook-Air.local"
] |
charlotteantschukovkjaer@Charlottes-MacBook-Air.local
|
980127ce992cb176eed416595f203d58f4cc83bb
|
d5658c5a2060f303fd8c7dbc054ff21bb378b098
|
/include/CTanTable.h
|
d38020261706cf124064f0bccd48cdacf7a16a8d
|
[
"MIT"
] |
permissive
|
colinw7/CMath
|
668a1914b9aca6018baed714512739489ba6a6d9
|
117c95ef41da0a3de3a5e8985779ba4d1993298c
|
refs/heads/master
| 2023-04-10T21:49:53.223900
| 2023-04-03T15:59:05
| 2023-04-03T15:59:05
| 10,445,237
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,051
|
h
|
#ifndef CTAN_TABLE_H
#define CTAN_TABLE_H
#include <cmath>
class CTanTable {
public:
CTanTable(uint size=500) :
size_(size) {
di_ = 2.0*M_PI/size_;
idi_ = 1.0/di_;
init();
}
~CTanTable() {
delete [] lookup_;
}
uint getSize() const { return size_; }
void setSize(uint size) {
if (size == size_) return;
delete [] lookup_;
size_ = size;
di_ = 2.0*M_PI/size_;
idi_ = 1.0/di_;
lookup_ = nullptr;
init();
}
double tan(double a) {
while (a >= 2.0*M_PI) a -= 2.0*M_PI;
while (a < 0.0) a += 2.0*M_PI;
a *= idi_;
int ia = int(a);
double ra = a - ia;
double t1 = lookup_[ia ];
double t2 = lookup_[ia + 1];
return (t1 + ra*(t2 - t1));
}
private:
void init() {
if (! lookup_)
lookup_ = new double [size_ + 1];
for (uint i = 0; i <= size_; ++i)
lookup_[i] = ::tan(di_*i);
}
private:
uint size_ { 500 };
double *lookup_ { nullptr };
double di_ { 1 };
double idi_ { 1 };
};
#endif
|
[
"colinw@nc.rr.com"
] |
colinw@nc.rr.com
|
6fb1e90d1e2f2e0e9018df15c68b7251029323cb
|
a56252fda5c9e42eff04792c6e16e413ad51ba1a
|
/resources/home/dnanexus/root/include/TMVA/RuleFit.h
|
27c35077f0a9e7cd3c83eb58409b8f8420ee8af3
|
[
"LGPL-2.1-or-later",
"LGPL-2.1-only",
"Apache-2.0"
] |
permissive
|
edawson/parliament2
|
4231e692565dbecf99d09148e75c00750e6797c4
|
2632aa3484ef64c9539c4885026b705b737f6d1e
|
refs/heads/master
| 2021-06-21T23:13:29.482239
| 2020-12-07T21:10:08
| 2020-12-07T21:10:08
| 150,246,745
| 0
| 0
|
Apache-2.0
| 2019-09-11T03:22:55
| 2018-09-25T10:21:03
|
Python
|
UTF-8
|
C++
| false
| false
| 8,858
|
h
|
// @(#)root/tmva $Id$
// Author: Andreas Hoecker, Joerg Stelzer, Fredrik Tegenfeldt, Helge Voss
/**********************************************************************************
* Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
* Package: TMVA *
* Class : RuleFit *
* Web : http://tmva.sourceforge.net *
* *
* Description: *
* A class implementing various fits of rule ensembles *
* *
* Authors (alphabetical): *
* Fredrik Tegenfeldt <Fredrik.Tegenfeldt@cern.ch> - Iowa State U., USA *
* Helge Voss <Helge.Voss@cern.ch> - MPI-KP Heidelberg, Ger. *
* *
* Copyright (c) 2005: *
* CERN, Switzerland *
* Iowa State U. *
* MPI-K Heidelberg, Germany *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted according to the terms listed in LICENSE *
* (http://tmva.sourceforge.net/LICENSE) *
**********************************************************************************/
#ifndef ROOT_TMVA_RuleFit
#define ROOT_TMVA_RuleFit
#include "TMVA/DecisionTree.h"
#include "TMVA/RuleEnsemble.h"
#include "TMVA/RuleFitParams.h"
#include "TMVA/Event.h"
#include <algorithm>
#include <random>
namespace TMVA {
class MethodBase;
class MethodRuleFit;
class MsgLogger;
class RuleFit {
public:
// main constructor
RuleFit( const TMVA::MethodBase *rfbase );
// empty constructor
RuleFit( void );
virtual ~RuleFit( void );
void InitNEveEff();
void InitPtrs( const TMVA::MethodBase *rfbase );
void Initialize( const TMVA::MethodBase *rfbase );
void SetMsgType( EMsgType t );
void SetTrainingEvents( const std::vector<const TMVA::Event *> & el );
void ReshuffleEvents()
{
std::shuffle(fTrainingEventsRndm.begin(), fTrainingEventsRndm.end(), fRNGEngine);
}
void SetMethodBase( const MethodBase *rfbase );
// make the forest of trees for rule generation
void MakeForest();
// build a tree
void BuildTree( TMVA::DecisionTree *dt );
// save event weights
void SaveEventWeights();
// restore saved event weights
void RestoreEventWeights();
// boost events based on the given tree
void Boost( TMVA::DecisionTree *dt );
// calculate and print some statistics on the given forest
void ForestStatistics();
// calculate the discriminating variable for the given event
Double_t EvalEvent( const Event& e );
// calculate sum of
Double_t CalcWeightSum( const std::vector<const TMVA::Event *> *events, UInt_t neve=0 );
// do the fitting of the coefficients
void FitCoefficients();
// calculate variable and rule importance from a set of events
void CalcImportance();
// set usage of linear term
void SetModelLinear() { fRuleEnsemble.SetModelLinear(); }
// set usage of rules
void SetModelRules() { fRuleEnsemble.SetModelRules(); }
// set usage of linear term
void SetModelFull() { fRuleEnsemble.SetModelFull(); }
// set minimum importance allowed
void SetImportanceCut( Double_t minimp=0 ) { fRuleEnsemble.SetImportanceCut(minimp); }
// set minimum rule distance - see RuleEnsemble
void SetRuleMinDist( Double_t d ) { fRuleEnsemble.SetRuleMinDist(d); }
// set path related parameters
void SetGDTau( Double_t t=0.0 ) { fRuleFitParams.SetGDTau(t); }
void SetGDPathStep( Double_t s=0.01 ) { fRuleFitParams.SetGDPathStep(s); }
void SetGDNPathSteps( Int_t n=100 ) { fRuleFitParams.SetGDNPathSteps(n); }
// make visualization histograms
void SetVisHistsUseImp( Bool_t f ) { fVisHistsUseImp = f; }
void UseImportanceVisHists() { fVisHistsUseImp = kTRUE; }
void UseCoefficientsVisHists() { fVisHistsUseImp = kFALSE; }
void MakeVisHists();
void FillVisHistCut(const Rule * rule, std::vector<TH2F *> & hlist);
void FillVisHistCorr(const Rule * rule, std::vector<TH2F *> & hlist);
void FillCut(TH2F* h2,const TMVA::Rule *rule,Int_t vind);
void FillLin(TH2F* h2,Int_t vind);
void FillCorr(TH2F* h2,const TMVA::Rule *rule,Int_t v1, Int_t v2);
void NormVisHists(std::vector<TH2F *> & hlist);
void MakeDebugHists();
Bool_t GetCorrVars(TString & title, TString & var1, TString & var2);
// accessors
UInt_t GetNTreeSample() const { return fNTreeSample; }
Double_t GetNEveEff() const { return fNEveEffTrain; } // reweighted number of events = sum(wi)
const Event* GetTrainingEvent(UInt_t i) const { return static_cast< const Event *>(fTrainingEvents[i]); }
Double_t GetTrainingEventWeight(UInt_t i) const { return fTrainingEvents[i]->GetWeight(); }
// const Event* GetTrainingEvent(UInt_t i, UInt_t isub) const { return &(fTrainingEvents[fSubsampleEvents[isub]])[i]; }
const std::vector< const TMVA::Event * > & GetTrainingEvents() const { return fTrainingEvents; }
// const std::vector< Int_t > & GetSubsampleEvents() const { return fSubsampleEvents; }
// void GetSubsampleEvents(Int_t sub, UInt_t & ibeg, UInt_t & iend) const;
void GetRndmSampleEvents(std::vector< const TMVA::Event * > & evevec, UInt_t nevents);
//
const std::vector< const TMVA::DecisionTree *> & GetForest() const { return fForest; }
const RuleEnsemble & GetRuleEnsemble() const { return fRuleEnsemble; }
RuleEnsemble * GetRuleEnsemblePtr() { return &fRuleEnsemble; }
const RuleFitParams & GetRuleFitParams() const { return fRuleFitParams; }
RuleFitParams * GetRuleFitParamsPtr() { return &fRuleFitParams; }
const MethodRuleFit * GetMethodRuleFit() const { return fMethodRuleFit; }
const MethodBase * GetMethodBase() const { return fMethodBase; }
private:
// copy constructor
RuleFit( const RuleFit & other );
// copy method
void Copy( const RuleFit & other );
std::vector<const TMVA::Event *> fTrainingEvents; // all training events
std::vector<const TMVA::Event *> fTrainingEventsRndm; // idem, but randomly shuffled
std::vector<Double_t> fEventWeights; // original weights of the events - follows fTrainingEvents
UInt_t fNTreeSample; // number of events in sub sample = frac*neve
Double_t fNEveEffTrain; // reweighted number of events = sum(wi)
std::vector< const TMVA::DecisionTree *> fForest; // the input forest of decision trees
RuleEnsemble fRuleEnsemble; // the ensemble of rules
RuleFitParams fRuleFitParams; // fit rule parameters
const MethodRuleFit *fMethodRuleFit; // pointer the method which initialized this RuleFit instance
const MethodBase *fMethodBase; // pointer the method base which initialized this RuleFit instance
Bool_t fVisHistsUseImp; // if true, use importance as weight; else coef in vis hists
mutable MsgLogger* fLogger; // message logger
MsgLogger& Log() const { return *fLogger; }
static const Int_t randSEED = 0; // set to 1 for debugging purposes or to zero for random seeds
std::default_random_engine fRNGEngine;
ClassDef(RuleFit,0); // Calculations for Friedman's RuleFit method
};
}
#endif
|
[
"slzarate96@gmail.com"
] |
slzarate96@gmail.com
|
826a3f6af42aa91a578a8ab4ab95e3a65e7a2fdd
|
c766bece263e5149d0dbab04ea20308bf1191ab8
|
/AdobeInDesignCCProductsSDK.2020/source/public/includes/PMReal.h
|
086d65502c65155ecfc844fb132f3d7ee2671289
|
[] |
no_license
|
stevenstong/adobe-tools
|
37a36868619db90984d5303187305c9da1e024f7
|
c74d61d882363a91da4938fd525b97f83084cb2e
|
refs/heads/master
| 2022-04-08T17:31:35.516938
| 2020-03-18T20:57:40
| 2020-03-18T20:57:40
| 248,061,036
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 17,254
|
h
|
//========================================================================================
//
// $File: //depot/devtech/15.0/plugin/source/public/includes/PMReal.h $
//
// Owner: jargast
//
// $Author: pmbuilder $
//
// $DateTime: 2019/10/11 10:48:01 $
//
// $Revision: #2 $
//
// $Change: 1061132 $
//
// Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
//
// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
// with the terms of the Adobe license agreement accompanying it. If you have received
// this file from a source other than Adobe, then your use, modification, or
// distribution of it requires the prior written permission of Adobe.
//
//========================================================================================
#pragma once
#ifndef __PMReal__
#define __PMReal__
#include <math.h>
#include "K2Assert.h"
#ifdef WINDOWS
#include <stdio.h>
#include <float.h>
#endif
#if defined(DEBUG)
#include <limits>
#endif
constexpr double kPMRealEpsilon = 1.0e-8;
constexpr double kPMPi = 3.141592653589793238462643383279502884197169399375105820974944;
constexpr double kPMMaxReal = 8.9884656743115795e+307;
// NOTE: Code Generation 7/24/96
//
// MSFT VC is quite good at inlining things and produces code nearly
// identical to using doubles.
//
// MW's shipping compiler is not as good -- it seems to only inline
// one level deep so that an inline containing an inline is never
// expanded. There are other compiler back ends for MW that we could
// try.
/**
Simple wrapper class for a floating point value in InDesign. Analogous to a
built-in C/C++ double.
NOTE: Implicit type casting
Implicit type casting has not been added to PMReal on purpose.
Leaving out implicit type casting allows the compiler to make
unambigous choices for math operations containing mixed types.
Additionally, implicit type casting can be hazardous to your
coding health, so instead we have provided explicit functions
for conversion.
NOTE: Constructor conversions
We only have one constructor taking a double to avoid
ambiguous calls. This does mean that implicit conversion
happens when going to a PMReal. Be careful in your code.
To make the class at all useable it had to implicit conversion
one direction or the other and we chose the constructor.
NOTE: Why a class?
Why are we using a class and not a double? Primarily to hide
the epsilon comparisons behind operator definitions. It may
also help us out in the future if we have to add anything -- It
will be easier to add to this class than change from a typedef.
*/
class PMReal
{
// ----- Constructors/destructors
public:
typedef base_type data_type;
/**
default constructor. initialize to 0.0
*/
constexpr PMReal() noexcept : fRealValue(0.0)
{
}
/**
Copy constructor.
@param other IN The PMReal to initialize this object from
*/
constexpr PMReal(const PMReal& ) noexcept = default;
constexpr PMReal(PMReal&&) noexcept = default;
/**
Constructs this object from the specified double.
@param d IN The value to initialize this object to
*/
constexpr PMReal(double d) noexcept : fRealValue(d)
{
}
/**
Converts a fixed-point number to a PMReal. Fixed-point numbers use 16/16
bit format.
@param fx IN The fixed-point number to convert
@return The fixed-point number as a PMReal
*/
friend PMReal ToPMReal(Fixed fx);
// PMREALCLEANUP
//operator double() { return fRealValue; }
//operator const double&() const { return fRealValue; }
// ----- Conversion operators
/**
Converts a PMReal to a double.
@param r IN The PMReal to convert
@return The PMReal as a double
*/
friend double ToDouble(const PMReal& r) noexcept;
/**
Converts a PMReal to a float.
@param r IN The PMReal to convert
@return The PMReal as a float
*/
friend float ToFloat(const PMReal& r);
/**
Converts a PMReal to a fixed-point number. Fixed-point numbers use 16/16
bit format.
@param r IN The PMReal to convert
@return The PMReal as a fixed-point number
*/
friend Fixed ToFixed(const PMReal& r);
/**
Converts a PMReal to an int16.
NOTE: This just casts the PMReal's value to an int16.
@param r IN The PMReal to convert
@return The PMReal as an int16 value
*/
friend int16 ToInt16(const PMReal& r);
/**
Converts a PMReal to a uint16.
NOTE: This just casts the PMReal's value to a uint16.
@param r IN The PMReal to convert
@return The PMReal as a uint16 value
*/
friend uint16 ToUInt16(const PMReal& r);
/**
Converts a PMReal to an int32.
NOTE: This just casts the PMReal's value to an int32.
@param r IN The PMReal to convert
@return The PMReal as an int32 value
*/
friend int32 ToInt32(const PMReal& r);
/**
Converts a PMReal to a uint16.
NOTE: This just casts the PMReal's value to a uint32.
@param r IN The PMReal to convert
@return The PMReal as an uint32 value
*/
friend uint32 ToUInt32(const PMReal& r);
// ----- Math operators
/**
Negates a PMReal.
@param a IN The PMReal to negate
@return The negated PMReal
*/
friend PMReal operator -(const PMReal& a);
/**
Adds two PMReals.
@param a IN The first PMReal to add
@param b IN The second PMReal to add
@return The sum of the two PMReals
*/
friend PMReal operator +(const PMReal& a, const PMReal& b);
/**
Subtracts two PMReals.
@param a IN The first PMReal to subtract
@param b IN The second PMReal to subtract
@return The difference of the two PMReals
*/
friend PMReal operator -(const PMReal& a, const PMReal& b);
/**
Multiplies two PMReals.
@param a IN The first PMReal to multiply
@param b IN The second PMReal to multiply
@return The sum of the two PMReals
*/
friend PMReal operator *(const PMReal& a, const PMReal& b);
/**
Divides a PMReal by another.
@param a IN The numerator
@param b IN The denominator
@return The result of the division
*/
friend PMReal operator /(const PMReal& a, const PMReal& b);
// ----- Math functions
/**
Rounds a PMReal to nearest integer value.
@param a IN The PMReal to round
@return The rounded value
*/
friend PMReal Round(const PMReal& a);
/**
Calculates floor of a PMReal by rounding down to integer value.
@param a IN The PMReal to round
@return The result of the floor calculation
*/
friend PMReal Floor(const PMReal& a);
/**
Calculates ceiling of a PMReal by rounding up to integer value.
@param a IN The PMReal to round
@return The result of the ceiling calculation
*/
friend PMReal Ceiling(const PMReal& a);
/**
Calculates absolute value of a PMReal.
@param a IN The PMReal whose absolute value is calculated
@return The absolute value of the input value
*/
friend PMReal abs(const PMReal& a);
/**
Calculates the nearest multiple of factor to a.
result = Round(a / factor) * factor
@param a IN The number whose nearest multiple is to be calculated
@param factor IN The factor to use in the calculation
@return The nearest multiple of factor to a
*/
friend PMReal NearestMultiple(const PMReal& a, const PMReal& factor);
/**
Calculates modulo (floating point remainder) of two PMReals.
@param a IN The numerator
@param b IN The denominator
@return The modulo of the two input values
*/
friend PMReal Mod(const PMReal& a, const PMReal& b);
// ----- Assignment Operators
/**
Assigns a value to this object.
@param c IN The value to assign
@return A reference to this object, so assignments can be chained
*/
PMReal& operator=(const PMReal &) noexcept = default;
PMReal& operator=(PMReal &&) noexcept = default;
/**
Increments this object by a value.
@param a IN The amount to increment by
@return A reference to this object, so assignments can be chained
*/
PMReal& operator +=(const PMReal& a);
/**
Decrements this object by a value.
@param a IN The amount to decrement by
@return A reference to this object, so assignments can be chained
*/
PMReal& operator -=(const PMReal& a);
/**
Multiples this object by a value.
@param a IN The amount to multiply by
@return A reference to this object, so assignments can be chained
*/
PMReal& operator *=(const PMReal& a);
/**
Divides this object by a value.
@param a IN The amount to divide by
@return A reference to this object, so assignments can be chained
*/
PMReal& operator /=(const PMReal& a);
// ----- Comparison Operators
/**
Compare two PMReals for equality, using implicit epsilon.
@param a IN The first PMReal to compare
@param b IN The second PMReal to compare
@return kTrue if the values are equal, else kFalse
*/
friend bool16 operator ==(const PMReal& a, const PMReal& b) noexcept;
/**
Compare two PMReals for inequality, using implicit epsilon.
@param a IN The first PMReal to compare
@param b IN The second PMReal to compare
@return kTrue if the values are not equal, else kFalse if they're equal
*/
friend bool16 operator !=(const PMReal& a, const PMReal& b) noexcept;
/**
Determines if one PMReal is less than another, using implicit epsilon.
@param a IN The first PMReal to compare
@param b IN The second PMReal to compare
@return kTrue if first PMReal is less than the second, else kFalse
*/
friend bool16 operator <(const PMReal& a, const PMReal& b) noexcept;
/**
Determines if one PMReal is greater than another, using implicit epsilon.
@param a IN The first PMReal to compare
@param b IN The second PMReal to compare
@return kTrue if first PMReal is greater than the second, else kFalse
*/
friend bool16 operator >(const PMReal& a, const PMReal& b) noexcept;
/**
Determines if one PMReal is less than or equal to another, using implicit
epsilon.
@param a IN The first PMReal to compare
@param b IN The second PMReal to compare
@return kTrue if first PMReal is less than or equal to the second, else kFalse
*/
friend bool16 operator <=(const PMReal& a, const PMReal& b) noexcept;
/**
Determines if one PMReal is greater than or equal to another, using
implicit epsilon.
@param a IN The first PMReal to compare
@param b IN The second PMReal to compare
@return kTrue if first PMReal is greater than or equal to the second, else kFalse
*/
friend bool16 operator >=(const PMReal& a, const PMReal& b) noexcept;
/**
Convenience operator for comparing two angles (in degrees) with implicit
epsilon.
Note: For the purposes of the comparison treats 360 as equal to zero.
@param a IN The first angle to compare
@param b IN The second angle to compare
@return kTrue if the values are equal, else kFalse
*/
friend bool16 AnglesEqual(const PMReal& a, const PMReal& b) noexcept;
/**
Function for comparing two PMReal values using a custom epsilon value.
@param a IN the first PMReal to compare
@param b IN the second PMReal to compare
@param epsilon IN the epsilon value used to compare the two PMReal values.
@return kTrue if the values are equal, else kFalse
*/
friend bool16 EqualsWithEpsilon(const PMReal& a, const PMReal& b, double epsilon) noexcept;
private:
double fRealValue;
};
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
// Math operators
inline PMReal operator-(const PMReal& r)
{
#ifdef WINDOWS
// Verify that exception handling is what we expect.
ASSERT_MSG(kDefaultFPUExceptions == _controlfp(0, 0), FORMAT_ARGS("Unexpected floating point control word! You may see floating point exceptions (actual:0x%8.8X expected:0x%8.8X)",_controlfp(0, 0), kDefaultFPUExceptions));
#endif
return -r.fRealValue;
}
inline PMReal operator+(const PMReal& a, const PMReal& b)
{
#ifdef WINDOWS
// Verify that exception handling is what we expect.
ASSERT_MSG(kDefaultFPUExceptions == _controlfp(0, 0), FORMAT_ARGS("Unexpected floating point control word! You may see floating point exceptions (actual:0x%8.8X expected:0x%8.8X)",_controlfp(0, 0), kDefaultFPUExceptions));
#endif
return a.fRealValue + b.fRealValue;
}
inline PMReal operator-(const PMReal& a, const PMReal& b)
{
#ifdef WINDOWS
// Verify that exception handling is what we expect.
ASSERT_MSG(kDefaultFPUExceptions == _controlfp(0, 0), FORMAT_ARGS("Unexpected floating point control word! You may see floating point exceptions (actual:0x%8.8X expected:0x%8.8X)",_controlfp(0, 0), kDefaultFPUExceptions));
#endif
return a.fRealValue - b.fRealValue;
}
inline PMReal operator*(const PMReal& a, const PMReal& b)
{
#ifdef WINDOWS
// Verify that exception handling is what we expect.
ASSERT_MSG(kDefaultFPUExceptions == _controlfp(0, 0), FORMAT_ARGS("Unexpected floating point control word! You may see floating point exceptions (actual:0x%8.8X expected:0x%8.8X)",_controlfp(0, 0), kDefaultFPUExceptions));
#endif
return a.fRealValue * b.fRealValue;
}
inline PMReal operator/(const PMReal& a, const PMReal& b)
{
#ifdef WINDOWS
// Verify that exception handling is what we expect.
ASSERT_MSG(kDefaultFPUExceptions == _controlfp(0, 0), FORMAT_ARGS("Unexpected floating point control word! You may see floating point exceptions (actual:0x%8.8X expected:0x%8.8X)",_controlfp(0, 0), kDefaultFPUExceptions));
#endif
return a.fRealValue / b.fRealValue;
}
// Math functions
inline PMReal Floor(const PMReal& a)
{
//return (a.fRealValue < 0.0 && a.fRealValue != double(int32(a.fRealValue)) ? int32(a.fRealValue - 1.0) : int32(a.fRealValue));
return ::floor (a.fRealValue);
}
inline PMReal Ceiling(const PMReal& a)
{
return (a.fRealValue > 0.0 && a.fRealValue != double(int32(a.fRealValue)) ? int32(a.fRealValue + 1.0) : int32(a.fRealValue));
}
inline PMReal Round(const PMReal& a)
{
PMReal r(a.fRealValue + 0.5);
return ::Floor(r);
}
inline PMReal abs(const PMReal& a)
{
// NOTE: Implicit construction on return
return ::fabs(a.fRealValue);
}
inline PMReal NearestMultiple(const PMReal&a, const PMReal& factor)
{
return ::Round (a / factor) * factor;
}
inline PMReal Mod(const PMReal& a, const PMReal& b)
{
// NOTE: Implicit construction on return
return ::fmod(a.fRealValue, b.fRealValue);
}
// Conversion operators
inline Fixed ToFixed(const PMReal& r)
{
ASSERT(static_cast<int32>(r.fRealValue) >= kMinInt16);
ASSERT(static_cast<int32>(r.fRealValue) <= kMaxInt16);
PMReal a(::Round(r * 65536.0));
return int32(a.fRealValue);
}
inline double ToDouble (const PMReal& r) noexcept
{
return r.fRealValue;
}
inline float ToFloat (const PMReal& r)
{
return (float) r.fRealValue;
}
inline int16 ToInt16 (const PMReal& r)
{
ASSERT(r.fRealValue >= kMinInt16);
ASSERT(r.fRealValue <= kMaxInt16);
return (int16) r.fRealValue;
}
inline uint16 ToUInt16 (const PMReal& r)
{
ASSERT(r.fRealValue >= 0.0);
ASSERT(r.fRealValue <= kMaxUInt16);
return (uint16) r.fRealValue;
}
inline int32 ToInt32 (const PMReal& r)
{
ASSERT_MSG(r.fRealValue >= kMinInt32, FORMAT_ARGS("Value %4.4f is too small to convert to int32",r.fRealValue));
ASSERT_MSG(r.fRealValue <= kMaxInt32, FORMAT_ARGS("Value %4.4f is too large to convert to int32",r.fRealValue));
return (int32) r.fRealValue;
}
inline uint32 ToUInt32 (const PMReal& r)
{
ASSERT(r.fRealValue >= 0.0);
ASSERT(r.fRealValue <= kMaxUInt32);
return (uint32) r.fRealValue;
}
inline PMReal ToPMReal (Fixed fx)
{
// NOTE: Implicit construction on return
return double(fx) * 0.0000152587890625; // 1/65536
}
inline PMReal& PMReal::operator+=(const PMReal& a)
{
fRealValue += a.fRealValue;
return *this;
}
inline PMReal& PMReal::operator-=(const PMReal& a)
{
fRealValue -= a.fRealValue;
return *this;
}
inline PMReal& PMReal::operator*=(const PMReal& a)
{
fRealValue *= a.fRealValue;
return *this;
}
inline PMReal& PMReal::operator/=(const PMReal& a)
{
fRealValue /= a.fRealValue;
return *this;
}
// Comparison operators
inline bool16 operator<(const PMReal& a, const PMReal& b) noexcept
{
return a.fRealValue < (b.fRealValue - kPMRealEpsilon);
}
inline bool16 operator>(const PMReal& a, const PMReal& b) noexcept
{
return a.fRealValue > (b.fRealValue + kPMRealEpsilon);
}
inline bool16 operator<=(const PMReal& a, const PMReal& b) noexcept
{
return a.fRealValue <= (b.fRealValue + kPMRealEpsilon);
}
inline bool16 operator>=(const PMReal& a, const PMReal& b) noexcept
{
return a.fRealValue >= (b.fRealValue - kPMRealEpsilon);
}
inline bool16 operator==(const PMReal& a, const PMReal& b) noexcept
{
return ::fabs(a.fRealValue - b.fRealValue) < kPMRealEpsilon;
}
inline bool16 operator!=(const PMReal& a, const PMReal& b) noexcept
{
return !(a == b);
}
// allow epsilon compare with angles in degress (360 == 0)
inline bool16 AnglesEqual(const PMReal& a, const PMReal& b) noexcept
{
if (a == b)
return kTrue;
else if (a > b)
return ::fabs((a.fRealValue - 360.0) - b.fRealValue) < kPMRealEpsilon;
else
return ::fabs(a.fRealValue - (b.fRealValue - 360.0)) < kPMRealEpsilon;
}
inline bool16 EqualsWithEpsilon(const PMReal& a, const PMReal& b, double epsilon) noexcept
{
return ::fabs(a.fRealValue - b.fRealValue) < epsilon;
}
#endif
|
[
"steven.tong@hcl.com"
] |
steven.tong@hcl.com
|
ebb30ce79776bec7ea7b989538509d10b5d63e2e
|
621047574f2f478a7faeda1fb0e484b1779a582c
|
/Itk/itkGPUMeanImageFilter3/src/itkGPUMeanImageFilter.cxx
|
83f34bd7e0a24ae2ab590b7510e6091f0c6b8427
|
[] |
no_license
|
CSIM-Toolkits/opencl
|
54135cbba0db66366f219c52427c16e7a433cf87
|
744ac5df4436319be9cbb19eb7c0b9262cedc7b5
|
refs/heads/master
| 2020-03-26T10:18:57.303048
| 2018-08-31T12:00:02
| 2018-08-31T12:00:02
| 144,791,482
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 14,719
|
cxx
|
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkMeanImageFilter.h"
#include "itkImportImageFilter.h"
#include "itkCastImageFilter.h"
#include "itkImageLinearIteratorWithIndex.h"
using namespace std;
#include <Configure.h>
cl_double setupTime; /**< time taken to setup OpenCL resources and building kernel */
cl_double kernelTime; /**< time taken to run kernel and read result back */
cl::Context context; /**< CL context */
std::vector<cl::Device> devices; /**< CL device list */
std::vector<cl::Device> device; /**< CL device to be used */
std::vector<cl::Platform> platforms; /**< list of platforms */
cl::Buffer inputImage2D; /**< CL Input image2d */
cl::Buffer outputImage2D; /**< CL Output image2d */
cl::CommandQueue commandQueue; /**< CL command queue */
cl::Program program; /**< CL program */
cl::Kernel kernel; /**< CL kernel */
short* pixelData; /**< Pointer to image data */
short* pixelDataOut; /**< Pointer to image data */
cl_uint pixelSize; /**< Size of a pixel in BMP format> */
cl_uint width; /**< Width of image */
cl_uint height; /**< Height of image */
cl_uint deep; /**< Deep of image */
size_t kernelWorkGroupSize; /**< Group Size returned by kernel */
size_t blockSizeX; /**< Work-group size in x-direction */
size_t blockSizeY; /**< Work-group size in y-direction */
int main(int argc, char *argv[])
{
blockSizeX=256;
blockSizeY=1;
if( argc < 3 )
{
std::cerr << "Error: missing arguments" << std::endl;
std::cerr << "inputfile outputfile [num_dimensions]" << std::endl;
return EXIT_FAILURE;
}
typedef itk::Image<short, 3> ImageType;
typedef itk::Image<unsigned char, 3> OutPutImageType;
typedef itk::ImageFileReader< ImageType > ReaderType;
typedef itk::ImageFileWriter< OutPutImageType > WriterType;
typedef itk::ImportImageFilter< short, 3 > ImportFilterType;
ImportFilterType::Pointer importFilter = ImportFilterType::New();
typedef itk::CastImageFilter<ImageType, OutPutImageType > CastFilterType;
CastFilterType::Pointer castFilter = CastFilterType::New();
typename ReaderType::Pointer reader = ReaderType::New();
typename WriterType::Pointer writer = WriterType::New();
reader->SetFileName( argv[1] );
reader->Update();
typename ImageType::Pointer image = reader->GetOutput();
typename ImageType::RegionType region = image->GetLargestPossibleRegion();
typename ImageType::SizeType size = region.GetSize();
std::cout << "width : " << size[0] << std::endl;
std::cout << "heigth : " << size[1] << std::endl;
std::cout << "deep : " << size[2] << std::endl;
//std::cout << reader<< std::endl;
//std::cout << image<< std::endl;
width= size[0];
height=size[1];
deep=size[2];
pixelData = (short*)malloc(size[0]*size[1]*size[2] * sizeof(short));
memcpy( pixelData, image->GetBufferPointer(), size[0]*size[1]*size[2]*sizeof(short));
pixelDataOut = (short*)malloc(size[0]*size[1]*size[2] * sizeof(short));
// error check
CHECK_ALLOCATION(pixelDataOut,
"Failed to allocate memory! (outputImageData)");
// initialize the Image data to NULL
memset(pixelDataOut, 0, width * height *deep * sizeof(short));
int sizePixel = (size[0]*size[1]*size[2]);
/*
typedef itk::ImageLinearIteratorWithIndex< ImageType > IteratorType;
IteratorType inputIt( image, image->GetRequestedRegion() );
inputIt.SetDirection(0);
for ( inputIt.GoToBegin(); ! inputIt.IsAtEnd(); inputIt.NextLine())
{
inputIt.GoToBeginOfLine();
while ( ! inputIt.IsAtEndOfLine() )
{
std::cout<< inputIt.Get()<<std::endl;
++inputIt;
}
}
*/
/*
int valueMax=0;
for(int i=0; i< sizePixel;i++ ){
std::cout<<"Index["<< i << "] = " << pixelData[i]<<std::endl;
if(valueMax<pixelData[i]){
valueMax = pixelData[i];
}
}
std::cout << "Máximo : " << valueMax << std::endl;
*/
//------
cl_int err = CL_SUCCESS;
cl_device_type dType;
dType = CL_DEVICE_TYPE_GPU;
err = cl::Platform::get(&platforms);
CHECK_OPENCL_ERROR(err, "Platform::get() failed.");
std::vector<cl::Platform>::iterator i;
if(platforms.size() > 0)
{
i = platforms.begin() + 0;
}
cl_context_properties cps[3] =
{
CL_CONTEXT_PLATFORM,
(cl_context_properties)(*i)(),
0
};
context = cl::Context(dType, cps, NULL, NULL, &err);
CHECK_OPENCL_ERROR(err, "Context::Context() failed.");
devices = context.getInfo<CL_CONTEXT_DEVICES>(&err);
CHECK_OPENCL_ERROR(err, "Context::getInfo() failed.");
std::cout << "Platform :" << (*i).getInfo<CL_PLATFORM_VENDOR>().c_str() << "\n";
int deviceCount = (int)devices.size();
int j = 0;
for (std::vector<cl::Device>::iterator i = devices.begin(); i != devices.end();
++i, ++j)
{
std::cout << "Device " << j << " : ";
std::string deviceName = (*i).getInfo<CL_DEVICE_NAME>();
std::cout << deviceName.c_str() << "\n";
}
std::cout << "\n";
if (deviceCount == 0)
{
std::cout << "No device available\n";
return SDK_FAILURE;
}
commandQueue = cl::CommandQueue(context, devices[0], 0,
&err);
CHECK_OPENCL_ERROR(err, "CommandQueue::CommandQueue() failed.");
/*
* Create and initialize memory objects
*/
inputImage2D = cl::Buffer(context,
CL_MEM_READ_ONLY,
sizeof(short) * width * height * deep ,
NULL,
&err);
CHECK_OPENCL_ERROR(err, "Image2D::Image2D() failed. (inputImage2D)");
// Create memory objects for output Image
outputImage2D = cl::Buffer(context,
CL_MEM_WRITE_ONLY,
sizeof(short)* width * height * deep,
NULL,
&err);
CHECK_OPENCL_ERROR(err, "Image2D::Image2D() failed. (outputImage2D)");
device.push_back(devices[0]);
// create a CL program using the kernel source
appsdk::SDKFile kernelFile;
std::string kernelPath = getPath();
kernelPath.append("MeanFilter.cl");
if(!kernelFile.open(kernelPath.c_str()))
{
std::cout << "Failed to load kernel file : " << kernelPath << std::endl;
return SDK_FAILURE;
}
// create program source
cl::Program::Sources programSource(1,
std::make_pair(kernelFile.source().data(),
kernelFile.source().size()));
// Create program object
program = cl::Program(context, programSource, &err);
CHECK_OPENCL_ERROR(err, "Program::Program() failed.");
std::string flagsStr = std::string("");
err = program.build(device, flagsStr.c_str());
if(err != CL_SUCCESS)
{
if(err == CL_BUILD_PROGRAM_FAILURE)
{
std::string str = program.getBuildInfo<CL_PROGRAM_BUILD_LOG>(devices[0]);
std::cout << " \n\t\t\tBUILD LOG\n";
std::cout << " ************************************************\n";
std::cout << str << std::endl;
std::cout << " ************************************************\n";
}
}
CHECK_OPENCL_ERROR(err, "Program::build() failed.");
// Create kernel
kernel = cl::Kernel(program, "MeanFilter", &err);
CHECK_OPENCL_ERROR(err, "Kernel::Kernel() failed.");
// Check group size against group size returned by kernel
kernelWorkGroupSize = kernel.getWorkGroupInfo<CL_KERNEL_WORK_GROUP_SIZE>
(devices[0], &err);
CHECK_OPENCL_ERROR(err, "Kernel::getWorkGroupInfo() failed.");
if((blockSizeX * blockSizeY) > kernelWorkGroupSize)
{
std::cout << "Out of Resources!" << std::endl;
std::cout << "Group Size specified : "
<< blockSizeX * blockSizeY << std::endl;
std::cout << "Max Group Size supported on the kernel : "
<< kernelWorkGroupSize << std::endl;
std::cout << "Falling back to " << kernelWorkGroupSize << std::endl;
if(blockSizeX > kernelWorkGroupSize)
{
blockSizeX = kernelWorkGroupSize;
blockSizeY = 1;
}
}
cl_int status;
cl::size_t<3> originWriteImage;
originWriteImage[0] = 0;
originWriteImage[1] = 0;
originWriteImage[2] = 0;
cl::size_t<3> regionWriteImage;
regionWriteImage[0] = width;
regionWriteImage[1] = height;
regionWriteImage[2] = 1;
cl::Event writeEvt;
status = commandQueue.enqueueWriteBuffer(
inputImage2D,
CL_TRUE,
0,
sizeof(short)* width * height * deep,
pixelData,
NULL,
&writeEvt);
CHECK_OPENCL_ERROR(status,
"CommandQueue::enqueueWriteImage failed. (inputImage2D)");
status = commandQueue.flush();
CHECK_OPENCL_ERROR(status, "cl::CommandQueue.flush failed.");
cl_int eventStatus = CL_QUEUED;
while(eventStatus != CL_COMPLETE)
{
status = writeEvt.getInfo<cl_int>(
CL_EVENT_COMMAND_EXECUTION_STATUS,
&eventStatus);
CHECK_OPENCL_ERROR(status,
"cl:Event.getInfo(CL_EVENT_COMMAND_EXECUTION_STATUS) failed.");
}
// Set appropriate arguments to the kernel
// input buffer image
status = kernel.setArg(0, inputImage2D);
CHECK_OPENCL_ERROR(status, "Kernel::setArg() failed. (inputImageBuffer)");
// outBuffer imager
status = kernel.setArg(1, outputImage2D);
CHECK_OPENCL_ERROR(status, "Kernel::setArg() failed. (outputImageBuffer)");
cl_int radiusx = 2;
status = kernel.setArg(2, radiusx);
CHECK_OPENCL_ERROR(status, "Kernel::setArg() failed. (outputImageBuffer)");
cl_int radiusy = 2;
status = kernel.setArg(3, radiusy);
CHECK_OPENCL_ERROR(status, "Kernel::setArg() failed. (outputImageBuffer)");
cl_int radiusz = 2;
status = kernel.setArg(4, radiusz);
CHECK_OPENCL_ERROR(status, "Kernel::setArg() failed. (outputImageBuffer)");
status = kernel.setArg(5, width);
CHECK_OPENCL_ERROR(status, "Kernel::setArg() failed. (outputImageBuffer)");
status = kernel.setArg(6, height);
CHECK_OPENCL_ERROR(status, "Kernel::setArg() failed. (outputImageBuffer)");
status = kernel.setArg(7, deep);
CHECK_OPENCL_ERROR(status, "Kernel::setArg() failed. (outputImageBuffer)");
/*
* Enqueue a kernel run call.
*/
cl::NDRange offset(0,0,0);
//std::cout<<"Tamanho: "<< width<< " - " << height<<std::endl;
cl::NDRange globalThreads(width, height, deep);
cl::NDRange localThreads(blockSizeX, blockSizeY,blockSizeY);
cl::Event ndrEvt;
status = commandQueue.enqueueNDRangeKernel(
kernel,
offset,
globalThreads,
localThreads,
0,
&ndrEvt);
CHECK_OPENCL_ERROR(status, "CommandQueue::enqueueNDRangeKernel() failed.");
status = commandQueue.flush();
CHECK_OPENCL_ERROR(status, "cl::CommandQueue.flush failed.");
eventStatus = CL_QUEUED;
while(eventStatus != CL_COMPLETE)
{
status = ndrEvt.getInfo<cl_int>(
CL_EVENT_COMMAND_EXECUTION_STATUS,
&eventStatus);
CHECK_OPENCL_ERROR(status,
"cl:Event.getInfo(CL_EVENT_COMMAND_EXECUTION_STATUS) failed.");
}
// Enqueue Read Image
//originWriteImage[0] = 0;
//originWriteImage[1] = 0;
//originWriteImage[2] = 0;
//regionWriteImage[0] = width;
//regionWriteImage[1] = height;
//regionWriteImage[2] = 1;
// Enqueue readBuffer
cl::Event readEvt;
status = commandQueue.enqueueReadBuffer(
outputImage2D,
CL_FALSE,
0,
sizeof(short)* width * height * deep,
pixelDataOut,
NULL,
&readEvt);
CHECK_OPENCL_ERROR(status, "CommandQueue::enqueueReadImage failed.");
status = commandQueue.flush();
CHECK_OPENCL_ERROR(status, "cl::CommandQueue.flush failed.");
eventStatus = CL_QUEUED;
while(eventStatus != CL_COMPLETE)
{
status = readEvt.getInfo<cl_int>(
CL_EVENT_COMMAND_EXECUTION_STATUS,
&eventStatus);
CHECK_OPENCL_ERROR(status,
"cl:Event.getInfo(CL_EVENT_COMMAND_EXECUTION_STATUS) failed.");
}
//float valueMax =0;
//for(int j=0;j<100;j++){
//pixelDataOut[j]= 6800;
//std::cout<<"["<<j<<"]= "<<pixelDataOut[j] <<std::endl;
//if(valueMax<pixelDataOut[j]){
//valueMax = pixelDataOut[j];
//}
//}
//std::cout << "Máximo : " << valueMax << std::endl;
//-------
ImportFilterType::SizeType sizeImport;
sizeImport[0] = size[0]; // size along X
sizeImport[1] = size[1]; // size along Y
sizeImport[2] = size[2]; // size along Y
ImportFilterType::IndexType start;
start.Fill( 0 );
ImportFilterType::RegionType regionImport;
regionImport.SetIndex( start );
regionImport.SetSize( sizeImport );
importFilter->SetRegion( regionImport );
const itk::SpacePrecisionType origin[ 3 ] = { 0.0, 0.0, 0.0};
importFilter->SetOrigin( origin );
const itk::SpacePrecisionType spacing[ 3 ] = { 1.0, 1.0, 1.0};
importFilter->SetSpacing( spacing );
const bool importImageFilterWillOwnTheBuffer = true;
importFilter->SetImportPointer( pixelDataOut, sizePixel,
importImageFilterWillOwnTheBuffer );
importFilter->Update();
castFilter->SetInput(importFilter->GetOutput() );
castFilter->Update();
writer->SetFileName( argv[2] );
writer->SetInput( castFilter->GetOutput() );
try
{
writer->Update();
}
catch( itk::ExceptionObject & exp )
{
std::cerr << "Exception caught !" << std::endl;
std::cerr << exp << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
|
[
"alexfd7@gmail.com"
] |
alexfd7@gmail.com
|
467096c5adc5d0f21fd71954ceba5ea9d18967e7
|
7d3ac1d63722ffdfe45e5e935a631635faa3c55b
|
/bean/person.cpp
|
602cc7f3efd935fd2ca86994088fd9e9eee36723
|
[] |
no_license
|
iyustlop/valvulares
|
c630c1d6616bf3aae8e3ea65e9c5e546c2a06e2b
|
14e08afc9e2796a8d9167991ad78bfddec9765c5
|
refs/heads/master
| 2021-01-01T17:27:47.121733
| 2019-03-03T22:43:43
| 2019-03-03T22:43:43
| 78,307,571
| 0
| 0
| null | 2019-03-03T22:43:44
| 2017-01-07T22:33:54
|
C++
|
UTF-8
|
C++
| false
| false
| 652
|
cpp
|
#include "person.h"
Person::Person()
{
}
void Person::setNumeroHistoria(QString nHistoria){
numeroHistoria = nHistoria;
}
QString Person::getNumeroHistoria(){
return numeroHistoria;
}
void Person::setNombre(QString name){
nombre = name;
}
QString Person::getNombre(){
return nombre;
}
void Person::setApellidos(QString surname){
apellidos = surname;
}
QString Person::getApellidos(){
return apellidos;
}
void Person::setGenero(QString genre){
genero = genre;
}
QString Person::getGenero(){
return genero;
}
QString Person::getEdad()
{
return edad;
}
void Person::setEdad(QString age)
{
edad = age;
}
|
[
"iyustlop@gmail.com"
] |
iyustlop@gmail.com
|
102d94e9bee10aa80db4c7550c25b19cac1eb778
|
65a7e2219fc31f1f1892733a211de1d07d6ccfef
|
/Include/Material.h
|
5321dda7c0375c742b0fabc27826060f2acd8b94
|
[] |
no_license
|
PandarinDev/Luna
|
a5af813c3d73cf4aff3a758b88acb8b14675385d
|
9cfd649414a751356feb758c9e0a31e88bd74002
|
refs/heads/master
| 2020-08-05T06:28:29.517680
| 2019-11-26T20:34:48
| 2019-11-26T20:34:48
| 212,430,205
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 399
|
h
|
#pragma once
#include <glm/vec3.hpp>
namespace luna {
class Material {
public:
static Material DEFAULT;
glm::vec3 color;
float specularReflectivity;
float diffuseReflectivity;
float ambientReflectivity;
float shininess;
Material(
const glm::vec3& color,
float specularReflectivity,
float diffuseReflectivity,
float ambientReflectivity,
float shininess);
};
}
|
[
"sz.krisztian96@gmail.com"
] |
sz.krisztian96@gmail.com
|
f3419c5f45a4b5ad782b826f6d024f3140d86280
|
e216c1df4b156d7a0d7b3f62d6b81b27d562211d
|
/QBSELECT.cpp
|
5c36a270c0755399ddefb8f431e5bda320136f31
|
[] |
no_license
|
Bonayy/Competitive-Programming
|
0888b394c556c90559c66802e40d9ff6fd905780
|
03dc096da4978bc18d9e52704ebaf7bbc59ddca0
|
refs/heads/master
| 2022-12-19T20:58:40.693221
| 2020-09-30T04:22:19
| 2020-09-30T04:22:19
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,928
|
cpp
|
#include <iostream>
using namespace std;
long n;
long f[16+5][10000+10];
long arr[16+5];
long c[5][10000+10];
long getBit(long i, long j) {//get bit thu j cua i
return ((i>>(j-1)) & 1);
}
long max(long a, long b) {
if (a>=b) return a;
else return b;
}
bool check(long i) {
for (int j=2; j<=4; j++)
if ((getBit(i,j)==1) && (getBit(i,j-1)==1)) return false;
return true;
}
bool compatible(long i1, long i2) {
for (int j=1; j<=4; j++)
if (getBit(i1,j) ==1 && getBit(i2, j) == 1) return false;
return true;
}
long sumOfChosenBox(long i, long j) {//tong nhung o da chon cua arr[i] o cot j
long sum = 0;
for (int k=1; k<=4; k++)
if (getBit(i, k) == 1) sum+=c[k][j];
return sum;
}
int main() {
cin >> n;
long sum;
long totalSatisfy = 0;
for (int i=1; i<=4; i++) {
for (int j=1; j<=n; j++) cin >> c[i][j];
}
for (int i=0; i<=(1<<4)-1; i++) {//tinh ca truong hop 0000, tuc la k chon so nao trong cot
if (check(i)) {//neu i bieu dien duoi dang nhi phan khong co 2 so 1 nao dung canh nhau thi cho vao mang arr
totalSatisfy++;
arr[totalSatisfy] = i;
}
}
for (int i=1; i<=totalSatisfy; i++) {
for (int j=1; j<=n; j++) f[i][j] = -1000000000;
}
for (int i=1; i<=totalSatisfy; i++) {
sum = 0;
for (int j=1; j<=4; j++) {
if (getBit(arr[i], j) == 1) sum+=c[j][1];//i chi la index trong arr thoi
}
f[i][1] = sum;
}
for (int j=2; j<=n; j++) {//tu cot thu 2 tro di tinh theo cot truoc no
for (int i=1; i<=totalSatisfy; i++) {
sum = sumOfChosenBox(arr[i], j);
for (int k=1; k<=totalSatisfy; k++) {
if (compatible(arr[i], arr[k])) {//neu nhu arr[i] va arr[k] k co phan tu nao co canh chung
f[i][j] = max(f[i][j], f[k][j-1]+sum);
}
}
}
}
long res = -1000000000;
for (int i=1; i<=totalSatisfy; i++)
if (f[i][n] > res) res = f[i][n];
cout << res;
return 0;
}
|
[
"dle8@u.rochester.edu"
] |
dle8@u.rochester.edu
|
ebe8642570757287665e38c1a5423f16f3a4e31c
|
e356412d660fa521708c7465b7909868a55f035b
|
/Copper/makemove.cpp
|
17fcbbf00a734de8da0692b1f9be6f1043da82be
|
[] |
no_license
|
BimmerBass/CopperChess
|
b67f7da8e820d92ff3a7d64643a1d1e40c6d53e0
|
7672252174728d7c8977f68e8e2e4af8b0d8ebef
|
refs/heads/master
| 2023-02-22T16:31:12.386766
| 2021-01-25T20:59:30
| 2021-01-25T20:59:30
| 294,092,722
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 10,468
|
cpp
|
#include "defs.h"
/*
INCLUDES THE FUNCTIONS:
- makeMove()
- undoMove()
*/
inline bool InCheck(const S_BOARD* pos) {
assert(pos->position[WK] != 0 && pos->position[BK] != 0);
if (pos->whitesMove == WHITE) {
return sqAttacked(pos->kingPos[0], BLACK, pos);
}
else {
return sqAttacked(pos->kingPos[1], WHITE, pos);
}
return false;
}
void MoveGeneration::undoMove(S_BOARD &board){
if (board.history.moveCount > 0){
S_UNDO previousPos = board.history.history[board.history.moveCount - 1];
std::copy(previousPos.bitboards, previousPos.bitboards + 12, board.position);
//std::fill(board.pieceList, board.pieceList + 64, NO_PIECE);
for (int sq = 0; sq < 64; sq++) {
board.pieceList[sq] = NO_PIECE;
}
BitBoard pceBrd = 0;
int sq = NO_SQ;
for (int pce = 0; pce < 12; pce++) {
pceBrd = board.position[pce];
while (pceBrd != 0){
sq = PopBit(&pceBrd);
board.pieceList[sq] = pce;
}
}
board.whitesMove = previousPos.side;
board.inCheck = previousPos.inCheck;
board.castlePerms = previousPos.castlingPerms;
board.has_castled[0] = previousPos.has_castled[0];
board.has_castled[1] = previousPos.has_castled[1];
board.enPassantSquare = previousPos.enPassantSq;
board.fiftyMove = previousPos.fiftyMove;
assert(previousPos.bitboards[WK] != 0 && previousPos.bitboards[BK] != 0);
int whiteKingPos = bitScanForward(previousPos.bitboards[WK]);
int blackKingPos = bitScanForward(previousPos.bitboards[BK]);
board.kingPos[0] = whiteKingPos;
board.kingPos[1] = blackKingPos;
board.WHITE_PIECES = (board.position[WP] | board.position[WN] | board.position[WB] | board.position[WR] | board.position[WQ] | board.position[WK]);
board.BLACK_PIECES = (board.position[BP] | board.position[BN] | board.position[BB] | board.position[BR] | board.position[BQ] | board.position[BK]);
board.EMPTY_SQUARES = ~(board.WHITE_PIECES | board.BLACK_PIECES);
board.posKey = previousPos.key;
board.pawnKey = previousPos.pawnHash;
board.ply -= 1;
board.history.moveCount -= 1;
}
else {
return;
}
}
void MoveGeneration::makeMove(S_BOARD &board, int move){
S_UNDO positionDescriptors;
for (int i = 0; i < 12; i++){
positionDescriptors.bitboards[i] = board.position[i];
}
assert(board.position[WK] != 0 && board.position[BK] != 0);
positionDescriptors.side = board.whitesMove;
positionDescriptors.castlingPerms = board.castlePerms;
positionDescriptors.enPassantSq = board.enPassantSquare;
positionDescriptors.fiftyMove = board.fiftyMove;
positionDescriptors.key = board.posKey;
positionDescriptors.pawnHash = board.pawnKey;
positionDescriptors.inCheck = board.inCheck;
positionDescriptors.has_castled[0] = board.has_castled[0];
positionDescriptors.has_castled[1] = board.has_castled[1];
int destination = move >> 10;
int origin = (move >> 4) & 63;
int promotion = (move >> 2) & 3;
int spcFlags = move & 3;
int pieceMoved = board.pieceList[origin];
int pieceCaptured = board.pieceList[destination];
assert(pieceCaptured != WK && pieceCaptured != BK);
/*if (pieceCaptured == WK || pieceCaptured == BK) {
std::cout << pieceCaptured << std::endl;
BoardRep::displayBoardState(board);
std::cout << "\n" << printMove(move) << std::endl;
assert(pieceCaptured != WK && pieceCaptured != BK);
}*/
board.pieceList[origin] = NO_PIECE;
board.enPassantSquare = NO_SQ;
if (pieceMoved == WP || pieceMoved == BP) {
if (spcFlags == 0) { // Promotion
// Remove origin
board.position[pieceMoved] = CLRBIT(board.position[pieceMoved], origin);
if (board.whitesMove) {
board.position[promoPieces[promotion][0]] = SETBIT(board.position[promoPieces[promotion][0]], destination);
board.pieceList[destination] = promoPieces[promotion][0];
}
else {
board.position[promoPieces[promotion][1]] = SETBIT(board.position[promoPieces[promotion][1]], destination);
board.pieceList[destination] = promoPieces[promotion][1];
}
if (pieceCaptured != NO_PIECE) {
board.position[pieceCaptured] = CLRBIT(board.position[pieceCaptured], destination);
}
}
else if (spcFlags == 1) { // En-passant
// Remove origin and place at destination
board.position[pieceMoved] = SETBIT(CLRBIT(board.position[pieceMoved], origin), destination);
board.pieceList[destination] = pieceMoved;
// Remove captured pawn
if (board.whitesMove == WHITE) {
board.position[BP] = CLRBIT(board.position[BP], destination - 8);
board.pieceList[destination - 8] = NO_PIECE;
}
else {
board.position[WP] = CLRBIT(board.position[WP], destination + 8);
board.pieceList[destination + 8] = NO_PIECE;
}
}
else { // Regular pawn move
// Place on destination and remove from origin
board.position[pieceMoved] = SETBIT(CLRBIT(board.position[pieceMoved], origin), destination);
board.pieceList[destination] = pieceMoved;
if (abs(destination - origin) == 16) { // Two square move -> set en passant square
board.enPassantSquare = (pieceMoved == WP) ? (destination - 8) : (destination + 8);
}
if (pieceCaptured != NO_PIECE) {
board.position[pieceCaptured] = CLRBIT(board.position[pieceCaptured], destination);
}
}
}
else if (pieceMoved == WK || pieceMoved == BK) {
if (pieceMoved == WK) {
board.kingPos[0] = destination;
}
else {
board.kingPos[1] = destination;
}
if (spcFlags == 2) { // Castling move
// Place king on destination
board.position[pieceMoved] = CLRBIT(SETBIT(board.position[pieceMoved], destination), origin);
board.pieceList[destination] = pieceMoved;
if (pieceMoved == WK) {
board.has_castled[0] = true;
}
else {
board.has_castled[1] = true;
}
if (destination == origin + 2) { // King side
if (board.whitesMove == WHITE) {
board.position[WR] = SETBIT(CLRBIT(board.position[WR], 7), destination - 1);
board.pieceList[7] = NO_PIECE;
board.pieceList[destination - 1] = WR;
board.castlePerms = CLRBIT(board.castlePerms, WKCA);
board.castlePerms = CLRBIT(board.castlePerms, WQCA);
}
else {
board.position[BR] = SETBIT(CLRBIT(board.position[BR], 63), destination - 1);
board.pieceList[63] = NO_PIECE;
board.pieceList[destination - 1] = BR;
board.castlePerms = CLRBIT(board.castlePerms, BKCA);
board.castlePerms = CLRBIT(board.castlePerms, BQCA);
}
}
else { // Queen side
if (board.whitesMove) {
board.position[WR] = SETBIT(CLRBIT(board.position[WR], 0), destination + 1);
board.pieceList[0] = NO_PIECE;
board.pieceList[destination + 1] = WR;
board.castlePerms = CLRBIT(board.castlePerms, WKCA);
board.castlePerms = CLRBIT(board.castlePerms, WQCA);
}
else {
board.position[BR] = SETBIT(CLRBIT(board.position[BR], 56), destination + 1);
board.pieceList[56] = NO_PIECE;
board.pieceList[destination + 1] = BR;
board.castlePerms = CLRBIT(board.castlePerms, BKCA);
board.castlePerms = CLRBIT(board.castlePerms, BQCA);
}
}
}
else { // Regular king move
// Remove origin and place on destination
board.position[pieceMoved] = SETBIT(CLRBIT(board.position[pieceMoved], origin), destination);
board.pieceList[destination] = pieceMoved;
if (pieceCaptured != NO_PIECE) {
board.position[pieceCaptured] = CLRBIT(board.position[pieceCaptured], destination);
}
// Adjust castling rights
if (board.whitesMove == WHITE) {
board.castlePerms = CLRBIT(board.castlePerms, WKCA);
board.castlePerms = CLRBIT(board.castlePerms, WQCA);
}
else {
board.castlePerms = CLRBIT(board.castlePerms, BKCA);
board.castlePerms = CLRBIT(board.castlePerms, BQCA);
}
}
}
else {
// Change castling rights if rook-move.
if (pieceMoved == WR || pieceMoved == BR) {
// If a white rook is moved and wks OR wqs is true.
if (pieceMoved == WR && (((board.castlePerms >> WKCA) & 1) == 1 || ((board.castlePerms >> WQCA) & 1) == 1)) {
if (origin == 0 && ((board.castlePerms >> WQCA) & 1) == 1) {
board.castlePerms = CLRBIT(board.castlePerms, WQCA);
}
else if (origin == 7 && ((board.castlePerms >> WKCA) & 1) == 1) {
board.castlePerms = CLRBIT(board.castlePerms, WKCA);
}
}
else if (pieceMoved == BR && (((board.castlePerms >> BKCA) & 1) == 1 || ((board.castlePerms >> BQCA) & 1) == 1)) {
if (origin == 63 && ((board.castlePerms >> BKCA) & 1) == 1) {
board.castlePerms = CLRBIT(board.castlePerms, BKCA);
}
else if (origin == 56 && ((board.castlePerms >> BQCA) & 1) == 1) {
board.castlePerms = CLRBIT(board.castlePerms, BQCA);
}
}
}
// Remove piece from origin and place on destination
board.position[pieceMoved] = SETBIT(CLRBIT(board.position[pieceMoved], origin), destination);
if (pieceCaptured != NO_PIECE) { // If the destination is an enemy piece
board.position[pieceCaptured] = CLRBIT(board.position[pieceCaptured], destination);
}
board.pieceList[destination] = pieceMoved;
}
board.posKey = generatePosKey(&board);
// Only update the pawn hashkey if a pawn has been moved, or a pawn has been captured
if (pieceMoved == WP || pieceMoved == BP || pieceCaptured == WP || pieceCaptured == BP) {
board.pawnKey = generatePawnHash(&board);
}
if (pieceMoved == WP || pieceMoved == BP || pieceCaptured != NO_PIECE) {
board.fiftyMove = 0;
}
else {
board.fiftyMove += 1;
}
board.whitesMove = (board.whitesMove == WHITE) ? BLACK : WHITE;
board.WHITE_PIECES = (board.position[WP] | board.position[WN] | board.position[WB] | board.position[WR] | board.position[WQ] | board.position[WK]);
board.BLACK_PIECES = (board.position[BP] | board.position[BN] | board.position[BB] | board.position[BR] | board.position[BQ] | board.position[BK]);
board.EMPTY_SQUARES = ~(board.WHITE_PIECES | board.BLACK_PIECES);
board.ply += 1;
board.history.history[board.history.moveCount] = positionDescriptors;
board.history.moveCount++;
board.inCheck = InCheck(&board);
}
void makeNullMove(S_BOARD* pos) {
pos->whitesMove = (pos->whitesMove == WHITE) ? BLACK : WHITE;
pos->posKey ^= sideKey;
pos->ply++;
if (pos->enPassantSquare != NO_SQ) {
pos->posKey ^= pieceKeys[NO_PIECE][pos->enPassantSquare];
pos->enPassantSquare = NO_SQ;
}
}
void undoNullMove(S_BOARD* pos, int ep) {
pos->whitesMove = (pos->whitesMove == WHITE) ? BLACK : WHITE;
pos->posKey ^= sideKey;
pos->ply--;
if (ep != NO_SQ) {
pos->posKey ^= pieceKeys[NO_PIECE][ep];
pos->enPassantSquare = ep;
}
}
|
[
"abildskovniels@gmail.com"
] |
abildskovniels@gmail.com
|
fb1331ab025ebaec9a1e96de38ff2560f2ec0d17
|
7a818a43c21a86fd1c6bb443e8c401c47273e662
|
/Algirithms/Lab2/src/mainwindow.cpp
|
c7acd6746c7778be70d8d1cf8b4ff3bb3163ebe9
|
[] |
no_license
|
ierikhon/Study-4
|
2e46da31f48b5e17781fb14bdf255d96c0331986
|
dbc51c618b486ca92290653297be11e2993853ca
|
refs/heads/master
| 2020-03-17T18:26:49.680065
| 2018-08-16T08:09:37
| 2018-08-16T08:09:37
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 19,092
|
cpp
|
/*Основной файл программы, отвечающий за реализацию слотов интерфейса.*/
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFile>
#include <QFileDialog>
#include <QString>
#include <QTextStream>
#include <QMessageBox>
#include <QQueue>
#include <QStack>
#include "graphwidget.h"
#include "bintree.h"
#include "node.h"
#include <QWidget>
#include <cmath>
#include <algorithm>
//Глобальные переменные, без которых не обойтись
INCTR* tree= new INCTR; //Непосредственно массив структур (реализация списка инцидентности)
int peaks_i; //Переменная, хранящая число вершин графа
bool gravity = false; //Переменная, необходимая для включения/отключения функции гравитации на отрисовке графа
int** _Gamilton_Path; //Список всех гамильтоновых путей в графе
int _cycle = 0; //Количество гамильтоновых путей в графе
INCTR* tTree; //Переменная, хранящая стягивающее дерево
QString fileName; //Переменная, хранящая путь к файлу. Теперь она глобальная, так как перепроверять дерево нужно перед каждым действием с ним
//Созданный для удобства работы с пошаговой реализацией алгоритма класс, содержащий очередь.
class PTP
{
public:
QQueue<int> sequen;
};
QQueue<PTP> steps; //Очередь еще не отработавших шагов алгоритма
QStack<PTP> complete; //Стек отработавших шагов алгоритма
PTP current; //Текущее состояние алгоритма
//Рекурсивная функция факториала
int Factor (int size)
{
if (size==1)
return 1;
size = size*Factor(size-1);
return size;
}
//Главная функция - рекурсивный поиск гамильтоновых путей
int** MainWindow::FindGamilton (INCTR* grandparent, INCTR* parent, int peaks, int step, int cycle, int** gampath)
{
bool flag = false;
INCTR* temp = new INCTR;
temp = parent;
while (temp->next!=NULL)
{
temp = temp->next;
flag = false;
for (int i=0; i<peaks; i++)
{
if (step!=peaks)
{
if (temp->turn==tree[i].turn)
{
for (int k=0; k<step; k++)
{
if (gampath[cycle][k]==tree[i].turn)
{
if (temp->next==NULL)
{
gampath[0][peaks+1] = cycle;
gampath[0][peaks+2] = step-1;
return gampath;
}
else
{
flag = true;
}
}
}
if (!flag)
{
gampath[cycle][step] = temp->turn;
PTP vazn;
for (int z=0; z<=step; z++)
vazn.sequen.enqueue(gampath[cycle][z]);
steps.enqueue(vazn);
step++;
gampath = FindGamilton(grandparent, &tree[i], peaks, step, cycle, gampath);
step = gampath[0][peaks+2];
cycle = gampath[0][peaks+1];
}
}
}
else
{
if (temp->turn==grandparent->turn)
{
cycle++;
gampath[cycle] = new int [peaks+10];
for (int j=0; j<step-1; j++)
gampath[cycle][j] = gampath [cycle-1][j];
step--;
gampath[cycle-1][peaks]=-1;
gampath[0][peaks+1] = cycle;
gampath[0][peaks+2] = step;
return gampath;
}
else
{
while (temp->next!=NULL)
{
temp = temp->next;
if (temp->turn==grandparent->turn)
{
cycle++;
gampath[cycle] = new int[peaks+10];
for (int j=0; j<step-1; j++)
gampath[cycle][j]=gampath[cycle-1][j];
step--;
gampath[cycle-1][peaks] = -1;
gampath[0][peaks+1] = cycle;
gampath[0][peaks+2] = step;
return gampath;
}
}
step--;
gampath[0][peaks+1] = cycle;
gampath[0][peaks+2] = step;
return gampath;
}
}
}
}
gampath[0][peaks+2] = step-1;
return gampath;
}
//Функция-анализатор, которая изучает данные из файла и подсчитывает число вершин графа
int analyser(QString str, int k)
{
int peaks=0;
int com=0;
while(str[k]==' ' || str[k]=='\t' || str[k]=='\r' || str[k]=='\n')
k++;
if(str[k]!='\0')
peaks++;
while(str[k]!='\0' /*&& com<3*/)
{
if(str[k]==',')
com++;
if(str[k]=='\n')
{
while(str[k+1]==' ' || str[k+1]=='\t' || str[k+1]=='\r')
k++;
if(str[k+1]!='\0' && str[k+1]!='\r' && str[k+1]!='\n')
peaks++;
com=0;
}
k++;
}
if(k!=str.size())
return -1;
return peaks;
}
//Функция для удаления лишних пробелов и табуляций
QString corrector(QString str)
{
int k=0, i=0;
QString new_str;
bool flag=false;
if(str[k]!='\t' && str[k]!=' ' && str[k]!='\n' && str[k]!='\r')
flag=true;
if(flag==true)
{
new_str[i]=str[k];
i++;
}
for(k=1; k<str.size(); k++)
{
if(str[k-1]=='\n' || str[k-1]==',' || str[k]=='\n' || str[k]==',')
flag=false;
if(str[k]!='\t' && str[k]!=' ' && str[k]!='\n' && str[k]!='\r')
flag=true;
if(flag==true)
{
new_str[i]=str[k];
i++;
}
}
return new_str;
}
//Функция непосредственно преобразует текст из файла в массив структур типа INCTR
INCTR* Read(QString str, INCTR* peaks, int size)
{
int i=0, j=0, k=0;
while(str[k]!='\0')
{
while(str[k]!=',' && str[k]!='\r' && str[k]!='\0')
{
peaks[i].name[j]=str[k];
peaks[i].turn=i+1;
k++;
j++;
}
j=0;
if(str[k]!='\0' && str[k]!='\r')
{
k++;
INCTR* temp=new INCTR;
peaks[i].next=temp;
peaks[i].outdeg++;
temp->next=NULL;
temp->intdeg++;
temp->prev=&peaks[i];
while(str[k]!=',' && str[k]!='\r' && str[k]!='\0')
{
while(str[k]!=',' && str[k]!='\r' && str[k]!='\0')
{
temp->name[j]=str[k];
j++;
k++;
}
if(str[k]!='\0' && str[k]!='\r')
{
INCTR* temp2=new INCTR;
peaks[i].outdeg++;
temp->next=temp2;
temp2->next=NULL;
temp2->intdeg++;
temp2->prev=temp;
temp=temp2;
k++;
}
j=0;
}
}
i++;
k++;
}
for(i=0; i<size; i++)
{
for(j=0; j<size; j++)
{
if(peaks[j].next)
{
INCTR* temp=new INCTR;
temp=peaks[j].next;
if(peaks[i].name==temp->name)
{
peaks[i].intdeg+=temp->intdeg;
temp->turn=peaks[i].turn;
}
while(temp->next)
{
temp=temp->next;
if(peaks[i].name==temp->name)
{
peaks[i].intdeg+=temp->intdeg;
temp->turn=peaks[i].turn;
}
}
}
}
peaks[i].deg=peaks[i].intdeg+peaks[i].outdeg;
}
return peaks;
}
/*Итерпретатор полученных из файла данных. Запускает ряд вышеописанных функций для составления информации
о списке инцидентности и перевода его в удобную для дальнейшей работы форму*/
INCTR* ReadFile(QString fileName, QTextEdit* te){
QFile file1(fileName);
file1.open(QIODevice::ReadOnly);
if (!file1.isOpen()){
QMessageBox msg;
msg.setText("File isn't open!");
msg.setWindowTitle("ERROR");
msg.exec();
return NULL;
}
int i = 0;
QTextStream file1s(&file1);
QString temp = file1s.readAll();
te->setPlainText(temp);
peaks_i=analyser(temp, i);
if(peaks_i==-1)
return NULL;
temp=corrector(temp);
INCTR* peaks = new INCTR[peaks_i];
peaks=Read(temp, peaks, peaks_i);
return peaks;
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
globalWidget = nullptr;
// ui->graphicsView->setViewport(globalWidget);
tree = NULL;
}
MainWindow::~MainWindow()
{
delete ui;
}
//Функция чтения данных из файла
void MainWindow::on_action_5_triggered()
{
_cycle = 0;
fileName = QFileDialog::getOpenFileName(this, "Open file");
tree = ReadFile(fileName, ui->textEdit);
tTree = new INCTR[peaks_i];
}
/*Управление фукнцией гравитации при отрисовки графа. Активирутеся установкой флажка в соответствующем чекбоксе интерфейса.
может быть изменено в любой момент работы программы*/
void MainWindow::on_checkBox_clicked()
{
if (ui->checkBox->checkState()){
gravity = true;
}
else
gravity = false;
}
//Простой вывод графа без поиска и отрисовки в нем гамильтоновых путей
void MainWindow::on_pushButton_clicked()
{
if(tree==NULL)
{
ui->textEdit_3->setText("Error 404: no info for graph construction!");
return;
}
else
{
tree = ReadFile(fileName, ui->textEdit);
globalWidget = new GraphWidget(this, tree, &gravity, peaks_i, NULL);
ui->graphicsView->setViewport(globalWidget);
}
}
//Инициализация поиска гамильтоновых путей по нажатию соответствующей кнопки. Здесь также происходит очистка от предыдущей информации
void MainWindow::on_pushButton_3_clicked()
{
if (tree!=NULL)
{
ui->textEdit_4->clear();
int step = 1;
int cycle = 0;
int i;
steps.clear();
complete.clear();
int** Gamilton_Path = new int*[100];
for (i = 0; i < log(Factor(peaks_i))+1; i++)
{
Gamilton_Path[i] = NULL;
Gamilton_Path[i] = new int[100];
for (int o=0; o< log(Factor(peaks_i))+1; o++)
Gamilton_Path[i][o] = 0;
}
for (i = 0; i < peaks_i; i++)
{
Gamilton_Path[cycle][0] = tree[i].turn;
Gamilton_Path = FindGamilton (&tree[i], &tree[i], peaks_i, step, cycle, Gamilton_Path); //Непосредственный запуск поиска путей
while (Gamilton_Path[cycle] && Gamilton_Path[cycle][peaks_i]==-1)
cycle++;
}
Gamilton_Path[cycle] = NULL;
//Вывод результатов поиска
for (i = 0; i<cycle; i++)
{
ui->textEdit_4->append(QString::number(i+1)+')');
for (int j=0; j<peaks_i; j++)
for (int k=0; k<peaks_i; k++)
if (Gamilton_Path[i][j]==tree[k].turn)
{
ui->textEdit_4->insertPlainText(tree[k].name);
ui->textEdit_4->insertPlainText(" ");
}
ui->textEdit_4->append((QString)'\n');
}
_cycle = cycle;
_Gamilton_Path = Gamilton_Path;
}
else ui->textEdit_3->append("Error 404: No info for search");
}
//Отрисовка графа с выбранным гамильтоновым путем
void MainWindow::on_pushButton_4_clicked()
{
if (ui->textEdit_2->toPlainText()!="")
{
int chosenCycle = ui->textEdit_2->toPlainText().toInt();
if (chosenCycle<=_cycle)
{
globalWidget = new GraphWidget(this, tree, &gravity, peaks_i, _Gamilton_Path[chosenCycle-1]);
ui->graphicsView->setViewport(globalWidget);
}
else
{
ui->textEdit_3->append("Error 404: This cycle was not found");
return;
}
}
}
//Очистка окна вывода сообщений об ошибках
void MainWindow::on_pushButton_5_clicked()
{
ui->textEdit_3->clear();
}
//Отрисовка текущего шага алгоритма, хранящегося в переменной current, при нажатии соотв. кнопки
void MainWindow::on_pushButton_7_clicked()
{
if ((!steps.isEmpty())||(!complete.isEmpty()))
{
int i = 0;
int* tempor = new int;
while (!current.sequen.isEmpty())
tempor[i++] = current.sequen.dequeue();
GraphWidget* widget = new GraphWidget(this, tree, &gravity, peaks_i , tempor);
QMainWindow* temp = new QMainWindow;
temp->setCentralWidget(widget);
temp->setWindowTitle("Graph outputer 3000 pro");
temp->show();
}
else ui->textEdit_3->append("Error 404: Full search wasn't complete yet");
}
//Шаг вперед, осуществляющийся по нажатию соответствующей кнопки
void MainWindow::on_pushButton_6_clicked()
{
if (!steps.isEmpty())
{
current = steps.dequeue();
complete.push(current);
ui->textEdit_3->append("One more step right");
}
else ui->textEdit_3->append("Error 404: All steps proceeded or search wasn't started.");
}
//Шаг назад, осуществляющийся по нажатию соответствующей кнопки
void MainWindow::on_pushButton_2_clicked()
{
if (!complete.isEmpty())
{
current = complete.pop();
steps.enqueue(current);
ui->textEdit_3->append("One more step left");
}
else ui->textEdit_3->append("Error 404: No steps proceeded or search wasn't started.");
}
//Непосредственно реализация алгоритма поиска в глубину. Создание копии дерева необходимо для сохраниения информации о структуре графа,
//так как во время работы алгоритма переменная tree затрагивается
void dfst (int nodeTurn)
{
tree[nodeTurn].label = true;
INCTR* copy = new INCTR[peaks_i];
for (int i=0; i<peaks_i; i++)
copy[i] = tree[i];
INCTR* temp = copy[nodeTurn].next;
while (temp!=NULL)
{
if (tree[(temp->turn)-1].label == false)
{
INCTR* moreTemp = tTree[nodeTurn].next;
if (moreTemp==NULL)
{
tTree[nodeTurn].next = new INCTR;
tTree[nodeTurn].next->name = temp->name;
tTree[nodeTurn].next->turn = temp->turn;
tTree[nodeTurn].next->deg = 1;
}
else
{
while (moreTemp->deg != 1)
moreTemp = moreTemp->next;
moreTemp->deg = 0;
moreTemp->next = new INCTR;
moreTemp->next->name = temp->name;
moreTemp->next->turn = temp->turn;
moreTemp->next->deg = 1;
}
dfst((temp->turn)-1);
}
//восстановление исходного состояния гафа. Здесь stopName служит индикатором места, куда указывал temp
for (int i=0; i<peaks_i; i++)
copy[i] = tree[i];
QString stopName = temp->name;
temp = copy[nodeTurn].next;
while (temp->name!=stopName)
temp = temp->next;
temp = temp->next;
}
}
//Инициализация алгоритма, происодящая по нажатию кнопки Deep Search of Tightening Tree
//Здесь обновляется граф, чтобы исключить ошибки при повторном нажатии на кнопку и выделяется память на список инцидентности стягивающего дерева
void MainWindow::on_pushButton_8_clicked()
{
tree = ReadFile(fileName, ui->textEdit);
tTree = new INCTR[peaks_i];
for (int i=0; i<peaks_i; i++)
{
tTree[i] = tree[i];
tTree[i].deg = 0;
tTree[i].next = NULL;
}
if (tree!=NULL)
{
dfst(0);
globalWidget = new GraphWidget(this, tTree, &gravity, peaks_i, NULL);
ui->graphicsView->setViewport(globalWidget);
}
else ui->textEdit_3->append("Error 404: No info for search!");
}
|
[
"kinglordlear@gmail.com"
] |
kinglordlear@gmail.com
|
fd797fd928c8fcf72e0232b9c155a2822fa52f97
|
09a4962b93c196f2f8a70c2384757142793612fd
|
/Dripdoctors/build/Android/Preview/Dripdoctors/app/src/main/include/Fuse.Storage.StorageModule.h
|
d15ea20037c8f159e19cc129e0c9b42d38415756
|
[] |
no_license
|
JimmyRodriguez/apps-fuse
|
169779ff2827a6e35be91d9ff17e0c444ba7f8cd
|
14114328c3cea08c1fd766bf085bbf5a67f698ae
|
refs/heads/master
| 2020-12-03T09:25:26.566750
| 2016-09-24T14:24:49
| 2016-09-24T14:24:49
| 65,154,944
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,859
|
h
|
// This file was generated based on C:\ProgramData\Uno\Packages\Fuse.Storage\0.32.14\$.uno.
// WARNING: Changes might be lost if you edit this file directly.
#pragma once
#include <Fuse.Scripting.IModuleProvider.h>
#include <Fuse.Scripting.NativeModule.h>
#include <Uno.IDisposable.h>
namespace g{namespace Fuse{namespace Scripting{struct Context;}}}
namespace g{namespace Fuse{namespace Storage{struct StorageModule;}}}
namespace g{namespace Uno{namespace Threading{struct Future1;}}}
namespace g{
namespace Fuse{
namespace Storage{
// public sealed class StorageModule :134
// {
::g::Fuse::Scripting::NativeModule_type* StorageModule_typeof();
void StorageModule__ctor_2_fn(StorageModule* __this);
void StorageModule__Delete_fn(::g::Fuse::Scripting::Context* c, uArray* args, uObject** __retval);
void StorageModule__New2_fn(StorageModule** __retval);
void StorageModule__Read_fn(::g::Fuse::Scripting::Context* c, uArray* args, uObject** __retval);
void StorageModule__ReadAsync_fn(uArray* args, ::g::Uno::Threading::Future1** __retval);
void StorageModule__Write_fn(::g::Fuse::Scripting::Context* c, uArray* args, uObject** __retval);
void StorageModule__WriteAsync_fn(uArray* args, ::g::Uno::Threading::Future1** __retval);
struct StorageModule : ::g::Fuse::Scripting::NativeModule
{
static uSStrong<StorageModule*> _instance_;
static uSStrong<StorageModule*>& _instance() { return _instance_; }
void ctor_2();
static uObject* Delete(::g::Fuse::Scripting::Context* c, uArray* args);
static StorageModule* New2();
static uObject* Read(::g::Fuse::Scripting::Context* c, uArray* args);
static ::g::Uno::Threading::Future1* ReadAsync(uArray* args);
static uObject* Write(::g::Fuse::Scripting::Context* c, uArray* args);
static ::g::Uno::Threading::Future1* WriteAsync(uArray* args);
};
// }
}}} // ::g::Fuse::Storage
|
[
"jimmy_sidney@hotmail.es"
] |
jimmy_sidney@hotmail.es
|
b26c2122adb84eb649365f44bc0d55bb30573146
|
0f990ccb1ebdbc940c7fa46983f27bcdb6614d4f
|
/checkers3.0/checkers3.0/Transformer.h
|
c25e2e5cc5b5c417e7c52569a24069a4ddf34bcd
|
[] |
no_license
|
maistrenkod/mipt-cpp
|
5fbe81434c398d005a28b2cf9b426e8f4f5b1784
|
837d77cd70553516e429c2d87a158ce16565ab91
|
refs/heads/master
| 2023-05-05T23:02:26.920081
| 2021-05-19T14:19:56
| 2021-05-19T14:19:56
| 341,176,233
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 348
|
h
|
#pragma once
#include <iostream>
#include <map>
#include <array>
#include "Graph_of_the_game.h"
#include "Turn.h"
#include "Cell.h"
using pos = std::pair<size_t, size_t>;
namespace tf
{
extern std::array<std::array<gotg::VALUES_FOR_FIELD, turn::width_of_field>, turn::heigh_of_field> transformate_info(std::map<pos, Cell>&);
} // namespace tf
|
[
"fasfas201@gmail.com"
] |
fasfas201@gmail.com
|
1082fa6d38d420d80434574014523af73cdbe0a7
|
94c5513eba02ec20551250c3ff22353227f4ba01
|
/cppMatmult2.cpp
|
43df6e22d2e7878605d17fbd7c903aa157dcc8ef
|
[] |
no_license
|
axelornj/Cppexperiment
|
f383807f197ef469d7df6fd89f6c000cdfbbc4cc
|
e0e380a870fd68fdb9494c5df4d6f99eea32d40b
|
refs/heads/master
| 2016-08-12T02:31:40.602800
| 2015-06-05T10:59:19
| 2015-06-05T10:59:19
| 36,923,745
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 538
|
cpp
|
#include <Rcpp.h>
#include <RcppEigen.h>
using namespace Eigen;
using namespace Rcpp;
// Below is a simple example of exporting a C++ function to R. You can
// source this function into an R session using the Rcpp::sourceCpp
// function (or via the Source button on the editor toolbar)
// For more on using Rcpp click the Help button on the editor toolbar
// [[Rcpp::depends(RcppEigen)]]
// [[Rcpp::export]]
MatrixXd cppMatmult2(const Map<MatrixXd> m1, const Map<MatrixXd&> m2) {
const MatrixXd& outm = m1 * m2;
return outm;
}
|
[
"solviro@gmail.com"
] |
solviro@gmail.com
|
9128d9b3ae48f431f9ee3a8fed7f33da3f904a93
|
22f3d35f0670837f8bc624aa1bb8984bf6e103cb
|
/info.h
|
dcd5a78aa92ad974eba665d781c29d851c5b4800
|
[] |
no_license
|
Maden23/StockExchange
|
4a7c26e87d557c1d6b9b24a60a68c6111aaa6ee0
|
1a49f079cc38748935d16a57e5745c4609b26c48
|
refs/heads/master
| 2020-04-12T21:04:09.546385
| 2018-12-21T20:35:35
| 2018-12-21T20:35:35
| 162,754,212
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 863
|
h
|
#ifndef INFO_H
#define INFO_H
#include <fstream>
#include <string>
#include <QString>
using namespace std;
enum info_t {IS_COMPANY, IS_HOLDER, IS_HOLDERWANALYSIS};
class Info
{
public:
virtual ~Info();
void setName(QString name);
QString getName() const;
virtual info_t defineInfo() const = 0;
virtual void reset() = 0;
// Вызывает виртуальную функцию write определенную для каждого потомка
friend ofstream& operator<< (ofstream &out, Info &info);
// Вызывает виртуальную функцию read определенную для каждого потомка
friend ifstream& operator>> (ifstream &in, Info &info);
protected:
QString _name;
virtual void write(ofstream &out) = 0;
virtual void read(ifstream &in) = 0;
};
#endif // INFO_H
|
[
"maden98@gmail.com"
] |
maden98@gmail.com
|
ed038aa0f3db85e36bc9577d03669b2ec3193c92
|
eca2965b6f3c9b887acf4842b7c4a5437ebbef6e
|
/1.6/wallFilmRegion/Uf
|
1f2c4a8ae6370616a97c0d0e6cf875b7481eb448
|
[] |
no_license
|
canesin/CasoSuperficiePlana
|
9c2fa7a7c73bffa2b18d9647618178c38d85ea03
|
bbfa4013c702ae7f2e895867297b096c9015b4d5
|
refs/heads/master
| 2016-09-05T23:07:15.957094
| 2012-06-27T21:37:21
| 2012-06-27T21:37:21
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 86,990
|
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.1.x |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "1.6";
object Uf;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField nonuniform List<vector>
2828
(
(-0.1596888319 0 -0.6158292821)
(-0.0800303447 0 -0.6101950662)
(0.08020192961 0 -0.5577156039)
(0.3541120431 0 -0.5382511716)
(0.6737223034 0 -0.5166149322)
(-0.9497358423 0 -0.4099233416)
(-1.006903037 0 -0.3551160448)
(-0.6579458772 0 -0.2638113257)
(-0.275199775 0 -0.5869592566)
(-0.1388771674 0 -0.6804540245)
(-0.04919915201 0 -0.6374358386)
(0.1086705666 0 -0.5605653318)
(0.4220224012 0 -0.4705387154)
(1.027996393 0 -0.6603470144)
(1.87974048 0 -1.837983314)
(1.935382737 0 -1.913382029)
(2.452409605 0 -1.624849174)
(-0.5872111901 0 -0.3709778233)
(-0.7731284553 0 -0.4358240006)
(-0.9798734947 0 -0.4743348971)
(-0.9776931318 0 -0.4135294765)
(-0.7842171895 0 -0.3218791085)
(-0.129453968 0 -0.5946587888)
(-0.002927947495 0 -0.7277074453)
(0.05999676797 0 -0.7381967075)
(0.2191910887 0 -0.7533719832)
(0.7962199131 0 -0.8809311877)
(1.833092762 0 -1.490884148)
(2.134360907 0 -1.756694694)
(2.280563404 0 -1.747639973)
(2.278237956 0 -1.543571017)
(1.680815146 0 -1.661843664)
(0.8136317905 0 -1.761528634)
(-0.4254642972 0 -0.2947329796)
(-0.6199908206 0 -0.4312941943)
(-0.8097435151 0 -0.513352954)
(-0.9156833685 0 -0.5298118141)
(-1.080044222 0 -0.5139178368)
(-1.063613432 0 -0.4659733208)
(0.08875987294 0 -0.6608775507)
(0.2250636982 0 -0.815313138)
(0.3250253631 0 -0.8358992973)
(0.5054930193 0 -0.8649377143)
(1.040644364 0 -1.040592247)
(1.95092853 0 -1.521855162)
(2.209979937 0 -1.669004519)
(2.259114282 0 -1.559827896)
(2.067324766 0 -1.298114703)
(1.315586676 0 -1.145661892)
(0.3993276713 0 -0.7916935758)
(-0.3537390693 0 0.2878352526)
(0.1563861958 0 0.4180922774)
(-0.3741871923 0 -0.3102148755)
(-0.5124089372 0 -0.4268944767)
(-0.680976807 0 -0.5635571436)
(-0.8128165538 0 -0.6312451405)
(-0.832931221 0 -0.5746959452)
(-1.22783858 0 -0.6590815894)
(-1.269392642 0 -0.5913695602)
(0.2230869206 0 -0.7120237168)
(0.4343268705 0 -0.865433183)
(0.4966165845 0 -0.9236775098)
(0.6014323074 0 -1.027303559)
(0.9112195642 0 -1.06363404)
(1.548896636 0 -1.205958186)
(2.078468621 0 -1.44325552)
(2.193815557 0 -1.365995463)
(1.893914998 0 -1.033997131)
(0.9722307173 0 -0.6523611895)
(0.1740840439 0 -0.03897061919)
(0.2196292049 0 0.3900019152)
(-0.3434767701 0 0.3638146862)
(-0.8050824712 0 0.4197682296)
(-0.3434918255 0 -0.3453900049)
(-0.4461304118 0 -0.4516164637)
(-0.6123629604 0 -0.6618884819)
(-0.7291011842 0 -0.7787614978)
(-0.7542542056 0 -0.7641866288)
(-0.8231282201 0 -0.7052523781)
(-1.341097726 0 -0.8394831255)
(-1.048616413 0 -0.7911124995)
(0.3411218909 0 -0.950568518)
(0.4536302464 0 -0.9303317232)
(0.2910987583 0 -0.9169930666)
(0.806950403 0 -1.093074888)
(1.107293813 0 -1.071490891)
(1.401367893 0 -1.036571066)
(1.715565047 0 -1.035191168)
(1.940061607 0 -1.014884746)
(1.711655622 0 -0.8663951812)
(0.05851684148 0 0.4690256586)
(0.3290683584 0 0.344236592)
(0.2665566185 0 0.4107245909)
(-0.652003473 0 0.3698068965)
(-0.8570640669 0 0.1868580804)
(-0.726900491 0 0.1576985607)
(-0.3190028165 0 -0.384057539)
(-0.4011410811 0 -0.4974152087)
(-0.5828202694 0 -0.8234138461)
(-0.6918550615 0 -1.007372045)
(-0.7208541136 0 -1.02572508)
(-0.7030623921 0 -0.9329624365)
(-0.8445195036 0 -0.9571993284)
(-1.351761304 0 -1.07054221)
(-2.341599995 0 -1.06762468)
(-1.33534912 0 -0.5962212837)
(-1.131943104 0 0.105848909)
(-0.05700038435 0 -0.8458111889)
(0.7910504277 0 -1.316378772)
(1.292565781 0 -0.8203287261)
(1.179086792 0 -0.777539736)
(1.521172732 0 -0.7919757829)
(1.66851233 0 -0.5854168396)
(1.538345012 0 -0.388070859)
(0.9546434238 0 0.03690786806)
(0.6706516199 0 0.4386867045)
(-0.6253496265 0 0.1153391734)
(-0.7524278034 0 0.1191457971)
(-0.6976752013 0 0.0527196829)
(-0.5831714335 0 0.1225718832)
(-0.3002691435 0 -0.3954381288)
(-0.3244373807 0 -0.431626742)
(-0.5191878409 0 -0.8506236198)
(-0.6502479166 0 -1.156523514)
(-0.6744102944 0 -1.225615475)
(-0.6431784615 0 -1.128967016)
(-0.7130163036 0 -1.139227938)
(-0.9146356507 0 -1.24586283)
(-1.330066746 0 -1.387702427)
(-2.457623542 0 -1.457297615)
(-1.114768674 0 -0.03755933684)
(-1.406669002 0 0.1297613479)
(-1.854759625 0 1.228491098)
(-1.712247031 0 1.605379456)
(-1.566297629 0 1.499954755)
(1.337411597 0 -0.885292388)
(1.31328142 0 -0.6709198168)
(1.382841663 0 -0.3638110004)
(1.274420657 0 -0.03021320573)
(0.7615317641 0 0.2068244667)
(0.1110626623 0 0.4521457796)
(-0.7591873816 0 -0.006119804042)
(-0.5963752461 0 -0.08927792927)
(-0.4540840582 0 -0.004966008319)
(-0.3934071016 0 0.0878655772)
(-0.3351064493 0 0.1285778865)
(-0.2759907865 0 -0.3877946362)
(-0.3124520276 0 -0.4670524836)
(-0.496088761 0 -0.865803567)
(-0.5891502172 0 -1.084566227)
(-0.5699197028 0 -1.11698144)
(-0.5777354302 0 -1.167585197)
(-0.7016411472 0 -1.330598676)
(-0.9299140559 0 -1.496165852)
(-1.247189317 0 -1.489737717)
(-1.621595916 0 -1.662431304)
(-1.60828292 0 0.1163101256)
(-0.8800848561 0 0.2256496874)
(-0.5605356223 0 0.2842224063)
(-0.4977044835 0 0.3179436049)
(-0.7026440912 0 0.5266107224)
(-0.9183875694 0 0.8549508169)
(1.091390058 0 -0.5679252041)
(1.219651346 0 -0.3765038763)
(1.059540088 0 0.4058046438)
(-0.1224174202 0 1.089076427)
(-1.026432104 0 -0.1904813939)
(-0.4988581406 0 -0.1418871144)
(-0.2314585009 0 -0.1752373767)
(-0.04558104085 0 -0.1189390903)
(0.2153711077 0 0.09413109492)
(2.162776535 0 -0.5175741683)
(4.124704378 0 -1.256044258)
(-0.2640322143 0 -0.3872828985)
(-0.2410728066 0 -0.3647425947)
(-0.2596018276 0 -0.3540446507)
(-0.3770540533 0 -0.5423366196)
(-0.4797904219 0 -0.7338210784)
(-0.4917617489 0 -0.8019207147)
(-0.5112479489 0 -0.9438578355)
(-0.6217690641 0 -1.308587629)
(-0.7593456368 0 -1.588559025)
(-0.8415274132 0 -1.240982221)
(-0.2892117024 0 0.03853827772)
(-0.8070428218 0 0.08236095177)
(-1.246438595 0 0.4598065632)
(-0.6404092927 0 0.3916290851)
(-0.5635673458 0 0.3847823718)
(-1.265794362 0 1.145189233)
(-1.135432165 0 1.482278594)
(-0.910470114 0 1.536844719)
(-0.8963738641 0 1.4073684)
(-1.088962737 0 1.382054218)
(-0.9021911985 0 0.8897141709)
(-0.430037728 0 -0.5119317377)
(0.03440014196 0 -0.5051030508)
(1.240542002 0 -1.832391357)
(2.332327882 0 -3.113837003)
(2.594568578 0 -3.395747206)
(2.827443022 0 -3.633920933)
(3.026682073 0 -4.048250744)
(-0.2830298695 0 -0.3525976541)
(-0.3214340262 0 -0.3573079689)
(-0.395147575 0 -0.3557626476)
(-0.3829559741 0 -0.3774626325)
(-0.3911001299 0 -0.5344463493)
(-0.4314690565 0 -0.6186255491)
(-0.4933998206 0 -0.6931208068)
(-0.6115985522 0 -0.8233860021)
(-0.7801829088 0 -0.9843411886)
(-0.4099298926 0 -0.1063007195)
(-0.4306545286 0 -0.03067465404)
(-3.234878968 0 0.4697607314)
(-1.174890455 0 0.6379557911)
(-0.6981806704 0 0.4598641243)
(-0.6482662085 0 0.4592191806)
(-2.189489964 0 2.480269463)
(-1.172555751 0 2.482171296)
(-0.9503625034 0 2.677982309)
(-0.8841176412 0 2.027300119)
(-0.959200042 0 1.352246697)
(-0.6759495746 0 -0.6100691847)
(0.3249383115 0 -0.99716275)
(1.434478285 0 -2.302243204)
(2.235081779 0 -3.306791926)
(2.495152556 0 -3.620964013)
(2.679979921 0 -3.823194134)
(2.872768503 0 -4.010970078)
(3.043549156 0 -4.178544518)
(-0.3326332181 0 -0.3131117534)
(-0.423156124 0 -0.3737041604)
(-0.4994763522 0 -0.3818988766)
(-0.4628846617 0 -0.3054778936)
(-0.3131985141 0 -0.3058689344)
(-0.3205941369 0 -0.4163378926)
(-0.3759145168 0 -0.5034298604)
(-0.4932408866 0 -0.6874035831)
(-0.8080908181 0 -1.121525818)
(-0.6956337871 0 -0.395648594)
(-0.6842444831 0 -0.1151967392)
(-4.486759854 0 1.141722378)
(-1.096556411 0 0.6728761132)
(-0.7764977583 0 0.5307629516)
(-0.7556167075 0 0.5407392208)
(-1.778197248 0 2.566691083)
(-0.8829175997 0 3.30681984)
(-0.6332931587 0 3.312540516)
(-0.794099949 0 2.480408977)
(-0.9192920027 0 1.433013712)
(0.04072456259 0 -1.319001394)
(0.9495593026 0 -1.770426422)
(1.997625418 0 -3.022223775)
(2.392050467 0 -3.504964244)
(2.581042236 0 -3.665631376)
(2.764796759 0 -3.794104751)
(2.938304509 0 -3.896322236)
(3.068288932 0 -3.973481488)
(-0.4992200874 0 0.2816208855)
(-0.351093117 0 -0.3073190631)
(-0.4232211911 0 -0.3678084379)
(-0.5142791834 0 -0.4133157706)
(-0.4975273338 0 -0.3004690295)
(-0.3011093218 0 -0.1767561604)
(-0.3036966584 0 -0.07843439165)
(-0.4328888706 0 0.06480702877)
(-0.3519732171 0 -0.04511116298)
(-0.3915291102 0 -0.5077785707)
(-1.126098085 0 -1.253979078)
(-0.9093351786 0 -0.363703147)
(-1.211912772 0 0.3814552383)
(-1.046053233 0 0.6499668029)
(-0.9108351263 0 0.6585050931)
(-1.157478525 0 0.7292267068)
(-0.509384605 0 0.6091596309)
(0.9156548151 0 2.063184177)
(-0.4289320097 0 1.037153122)
(-0.9333049456 0 0.8386042825)
(-1.03416737 0 0.9656258989)
(0.4160964963 0 -1.488694335)
(1.157843648 0 -1.992380478)
(2.092257951 0 -3.063534919)
(2.47598737 0 -3.494350534)
(2.622076035 0 -3.580196494)
(2.764828889 0 -3.665265527)
(2.880338039 0 -3.742331489)
(2.930150942 0 -3.781762796)
(-0.004827165859 0 -0.4032903841)
(-0.2531327339 0 -0.2258654107)
(-0.3258319434 0 -0.3022967677)
(-0.3464188637 0 -0.3752868119)
(-0.4522727911 0 -0.4651636454)
(-0.5463484042 0 -0.3439555375)
(-0.3225248976 0 -0.02725628532)
(-0.6981652763 0 0.3209805047)
(-0.8184105672 0 0.4372191062)
(-0.7028814599 0 0.4240505262)
(-0.4237384047 0 0.1089245321)
(-0.5694876506 0 -0.7052832957)
(-0.9810851008 0 -0.6273143723)
(-1.178990195 0 0.678440148)
(-1.194184594 0 0.8346326498)
(-1.105468007 0 0.9371160478)
(-0.416283358 0 0.5175180122)
(-0.5665087654 0 0.6028955407)
(-0.6994870483 0 0.7070466034)
(-0.8912313419 0 0.7517406132)
(-1.014161895 0 0.8373332226)
(-1.165805885 0 1.198198705)
(0.6264705396 0 -1.58719398)
(1.121559421 0 -1.815886354)
(1.731129955 0 -2.579311542)
(2.342102454 0 -3.262222862)
(2.540811314 0 -3.398864855)
(2.601070468 0 -3.41139216)
(2.490959779 0 -3.251544666)
(1.599780527 0 -2.120156402)
(0.3839011036 0 -0.4707311516)
(-0.2350208725 0 -0.2020014887)
(-0.2492553291 0 -0.2799895137)
(-0.2127988936 0 -0.433899565)
(-0.3235072943 0 -0.5792443193)
(-0.6436301734 0 -0.5533955277)
(-0.6163975963 0 0.3619763243)
(-0.9314102735 0 0.4927605557)
(-1.028639654 0 0.6400764198)
(-0.9753902657 0 0.6413693638)
(-0.7526890328 0 0.5242472257)
(-0.4576182396 0 0.2034912778)
(-0.5260858245 0 -0.03948545621)
(-0.7250302485 0 0.5250096674)
(0.9479504563 0 2.332846197)
(-0.1591141612 0 2.983339837)
(-0.6025920204 0 0.7075261385)
(-0.6762476236 0 0.6872610598)
(-0.8288307543 0 0.7583241427)
(-0.9747282072 0 0.8127935898)
(-1.063808815 0 0.8716572664)
(-1.099541642 0 1.038872855)
(0.88867907 0 -1.135049094)
(0.879892433 0 -1.263494045)
(1.32236795 0 -1.803336642)
(1.704404936 0 -2.331909001)
(2.004618876 0 -2.668349318)
(2.005932982 0 -2.602376694)
(1.629639046 0 -2.044831612)
(0.7935810953 0 -0.6764650703)
(0.4683147085 0 -0.4158263788)
(-0.1941064502 0 -0.1304010448)
(-0.1862282349 0 -0.1823705873)
(-0.1914660945 0 -0.2774752531)
(-0.08259687461 0 -0.8267482511)
(-0.221405899 0 -0.486837486)
(-0.7643897254 0 0.5078403322)
(-1.053665847 0 0.7432941479)
(-1.210790083 0 0.9361330921)
(-1.190211956 0 0.8950438944)
(-0.9560552721 0 0.7560073339)
(-0.7710549018 0 0.6847806858)
(-0.1766166064 0 0.2772399788)
(0.6671091226 0 0.2454917253)
(0.6245602977 0 0.6349845743)
(0.5576006732 0 1.11506118)
(-0.6433876955 0 0.8451751343)
(-0.8293912231 0 0.810334952)
(-0.9770427734 0 0.8758513809)
(-1.10852493 0 0.8916387464)
(-1.157034186 0 0.9033139921)
(-1.122649416 0 0.9265444574)
(-1.264140472 0 1.124796874)
(0.7823528776 0 -1.08860663)
(1.092722027 0 -1.078568996)
(1.288710352 0 -1.389255268)
(1.373353554 0 -1.551504934)
(1.295940671 0 -1.433713678)
(0.98843102 0 -0.9454886348)
(-0.4447705883 0 0.07856153165)
(-0.3483531705 0 0.1616084432)
(-0.21603143 0 -0.0317109916)
(-0.1543814558 0 -0.05251887493)
(-0.08190051789 0 -0.06809141724)
(0.2250677858 0 -0.3968240642)
(-0.3376375707 0 0.1229551508)
(-0.9552431941 0 0.8745545189)
(-1.370589033 0 1.27984757)
(-1.571674835 0 1.471013176)
(-1.477752601 0 1.310979457)
(-1.182795199 0 1.052430945)
(-0.8968774663 0 0.9230565801)
(-0.7240666049 0 0.7817812995)
(-0.08665059469 0 0.3322708308)
(-0.1635427726 0 0.3327695265)
(0.720272974 0 0.9933408392)
(-0.6989889543 0 0.6362902245)
(-0.9449723723 0 0.9630743762)
(-1.116576413 0 0.9948464879)
(-1.241282011 0 0.9466282017)
(-1.24388526 0 0.9055445035)
(-1.156152419 0 0.8781621778)
(-1.008931156 0 0.8310651874)
(-0.9252195079 0 0.3754175909)
(0.1062697675 0 -0.5303604333)
(1.028340082 0 -1.00870761)
(1.075227026 0 -0.9735205298)
(0.9458220257 0 -0.8490410642)
(0.3533895598 0 -0.3799011415)
(-0.3031860189 0 0.1107012987)
(-0.2718265472 0 0.1296874986)
(-0.1685394753 0 0.0376065888)
(-0.1700420635 0 0.1171508099)
(-0.01378427123 0 0.02727636102)
(0.02476446161 0 -0.04132088691)
(-0.5232064935 0 0.6036213155)
(-1.484421416 0 1.5307973)
(-2.007404106 0 1.99644799)
(-2.166673759 0 2.124898708)
(-1.951773958 0 1.872691101)
(-1.402292295 0 1.338711756)
(-0.9682531635 0 1.082166395)
(-0.7189288725 0 0.9273329159)
(-0.454346098 0 0.6486530878)
(-0.270957572 0 0.3401239039)
(-0.6002686239 0 0.3016214207)
(-0.7524816491 0 0.7815110853)
(-0.9897168064 0 0.9527528232)
(-1.236803021 0 0.9742983541)
(-1.315060638 0 0.9230357251)
(-1.258551933 0 0.8754424611)
(-1.115872322 0 0.8363300431)
(-0.8970879603 0 0.6815595431)
(-0.5951871998 0 0.04422254121)
(-0.5474872718 0 -0.3823740409)
(-0.5645500158 0 -0.3572010125)
(0.1403275939 0 -0.4932158379)
(-0.0808253433 0 -0.1869153496)
(-0.2988130614 0 0.06809019328)
(-0.2837985422 0 0.09816479246)
(-0.2405944056 0 0.1484490167)
(-0.1047045657 0 0.2233354704)
(-0.1385083097 0 0.2490510312)
(-0.1725084717 0 0.3560369853)
(-1.29268069 0 1.435385897)
(-2.201636248 0 2.238551714)
(-2.519687228 0 2.48612578)
(-2.544794633 0 2.472966955)
(-2.355554491 0 2.255931534)
(-1.680865748 0 1.561876339)
(-1.011092466 0 1.106716365)
(-0.6811528695 0 0.9486666639)
(-0.5123465108 0 0.7435155907)
(-0.6142905118 0 0.5650004808)
(-0.9145951276 0 -1.283517343)
(-0.9821245834 0 2.66541745)
(-1.334389591 0 1.013902733)
(-1.399923121 0 0.9544582628)
(-1.329049351 0 0.8818144579)
(-1.205620039 0 0.8466618672)
(-1.028782618 0 0.8331559805)
(-0.7887647196 0 0.4250923487)
(-0.4227421873 0 -0.3017252748)
(-0.5615490088 0 -0.5690191238)
(-0.504148531 0 -0.5217936783)
(-0.4012273079 0 -0.4075886076)
(-0.2978622703 0 -0.2060551246)
(-0.3312756677 0 0.02885918511)
(-0.2888138649 0 0.1344487284)
(-0.2184575629 0 0.1920334297)
(-0.00500525313 0 0.3713635854)
(0.002810256679 0 0.3879106118)
(-0.6540088281 0 0.9967227728)
(-2.295499948 0 2.403783537)
(-2.79578336 0 2.79355496)
(-2.838251192 0 2.782340745)
(-2.700379505 0 2.612217058)
(-2.406641311 0 2.288701253)
(-1.79109686 0 1.603979787)
(-0.9719163452 0 0.9339624815)
(-0.5330151978 0 0.7229221533)
(-0.4463294538 0 0.5077288776)
(-0.8900083806 0 0.6885517323)
(-1.251733802 0 0.8997689648)
(-1.446998488 0 0.9941054297)
(-1.497912453 0 1.015750363)
(-1.419545912 0 0.9549685335)
(-1.261279755 0 0.8359851038)
(-1.08641996 0 0.8253949334)
(-0.9056357315 0 0.8782222729)
(-0.6153301488 0 0.1433300162)
(-0.5411701118 0 -0.5641252797)
(-0.5953847241 0 -0.6622211177)
(-0.5917415924 0 -0.6595020824)
(-0.536304843 0 -0.592269577)
(-0.4008589225 0 -0.4334782422)
(-0.3016920556 0 -0.04688693323)
(-0.2393052236 0 0.2034376289)
(-0.09288345736 0 0.2976568068)
(0.1247284536 0 0.2041957102)
(0.1764305257 0 0.3398654582)
(-2.379909737 0 2.55244004)
(-3.113788874 0 3.14394243)
(-3.132883334 0 3.099513488)
(-2.983794964 0 2.908375729)
(-2.723480746 0 2.612427091)
(-2.264445143 0 2.115914673)
(-1.57571793 0 1.35971699)
(-0.8145779885 0 0.6668449761)
(-0.4578804598 0 0.4468001196)
(-0.8244035163 0 0.6058112162)
(-1.255625698 0 0.8752062118)
(-1.49209676 0 1.021109614)
(-1.561104317 0 1.049974634)
(-1.529814158 0 1.030630898)
(-1.378893479 0 0.9776380851)
(-1.125011316 0 0.8099506975)
(-0.8525165949 0 0.803383272)
(-0.7037587669 0 0.9540182355)
(-0.4675063885 0 0.1505639458)
(-0.5245051975 0 -0.6122156293)
(-0.6158423862 0 -0.7011731929)
(-0.6817542039 0 -0.7706542225)
(-0.692029018 0 -0.7714859791)
(-0.6251715368 0 -0.6893023759)
(-0.3826616301 0 -0.4138079146)
(0.1015987208 0 0.2167594684)
(0.07757061881 0 0.425770199)
(-3.397902059 0 3.492488597)
(-3.407304934 0 3.414551554)
(-3.239742239 0 3.185164418)
(-2.983818702 0 2.87211633)
(-2.582536464 0 2.423706977)
(-1.874447655 0 1.681025971)
(-1.198223803 0 0.9588535891)
(-0.9304454689 0 0.6906600594)
(-1.005505228 0 0.7096627318)
(-1.27742061 0 0.8886121088)
(-1.511387785 0 1.043816006)
(-1.614874999 0 1.110479555)
(-1.595813918 0 1.063235383)
(-1.46943655 0 1.022594365)
(-1.256718275 0 1.05347694)
(-0.9125809154 0 0.8054806626)
(-0.5262195122 0 0.7333524124)
(-0.4262217356 0 0.8820733056)
(-0.3732689486 0 0.5797987314)
(-0.4328362441 0 -0.5009279619)
(-0.5768352917 0 -0.6647979845)
(-0.7285708017 0 -0.8360135081)
(-0.8046819036 0 -0.9091337211)
(-0.8287198278 0 -0.921346648)
(-0.728194917 0 -0.7896431018)
(0.0644188487 0 0.0099273016)
(0.2952144662 0 0.4872659178)
(-3.676861363 0 3.764865204)
(-3.473176679 0 3.449069635)
(-3.196539747 0 3.063860252)
(-2.781092669 0 2.565095664)
(-2.077052079 0 1.852567571)
(-1.261899752 0 1.075301802)
(-1.051225118 0 0.8637487749)
(-1.056848002 0 0.8676800645)
(-1.188183426 0 0.9399061529)
(-1.436888308 0 1.063463471)
(-1.624759348 0 1.151327908)
(-1.673704533 0 1.16477694)
(-1.581100287 0 1.060084423)
(-1.242622255 0 0.9921005304)
(-0.9757322045 0 1.09346385)
(-0.709720619 0 0.6930423361)
(-0.3748693303 0 0.5137529959)
(-0.3035379087 0 0.423628362)
(-0.2446212033 0 0.2160560477)
(-0.2891092669 0 -0.2188143136)
(-0.4212194378 0 -0.4769479887)
(-0.7037773293 0 -0.8212608112)
(-0.8531678467 0 -0.9832136686)
(-0.9495508548 0 -1.074954926)
(-0.9976956365 0 -1.093927357)
(-3.630098677 0 3.711477598)
(-3.338505361 0 3.020719085)
(-2.719137211 0 2.26755378)
(-1.880883934 0 1.518720161)
(-1.189442269 0 1.076209892)
(-1.172944075 0 1.09975562)
(-1.197526082 0 1.121851004)
(-1.209576669 0 1.113648081)
(-1.361376489 0 1.141540302)
(-1.599536722 0 1.204348747)
(-1.729329958 0 1.232129013)
(-1.703075181 0 1.189308713)
(-1.520127287 0 1.047594632)
(-0.9241126651 0 0.8487182308)
(-0.6704761163 0 0.7599457381)
(-0.5627495608 0 0.4411733959)
(-0.4718519672 0 0.234670994)
(-0.4177429702 0 0.2496686333)
(-0.3506272757 0 0.2739222148)
(-0.3578070341 0 0.4646773228)
(-0.2585973669 0 0.5903277611)
(-0.5025889113 0 -0.577038577)
(-0.8007209935 0 -0.9436196682)
(-0.9822786032 0 -1.153012782)
(-1.066553695 0 -1.211274161)
(-3.512413124 0 1.611279719)
(-2.281612399 0 1.348836276)
(-1.488945873 0 1.149207907)
(-1.11502692 0 1.033078159)
(-1.27168739 0 1.315505947)
(-1.405699779 0 1.403693138)
(-1.38988454 0 1.385894982)
(-1.398703224 0 1.330276622)
(-1.587552009 0 1.306072347)
(-1.777217536 0 1.309382168)
(-1.809549611 0 1.277248892)
(-1.677340019 0 1.167550765)
(-1.368740143 0 0.9441312981)
(-0.8582013395 0 0.4724211409)
(-0.5782933556 0 0.227742146)
(-0.5064465772 0 0.1743584351)
(-0.5035176626 0 0.2305173865)
(-0.5091557597 0 0.3168486417)
(-0.524838851 0 0.4065933993)
(-0.4421787209 0 0.4620811593)
(0.1766692351 0 1.226435687)
(0.2003184548 0 1.601103619)
(0.1271286916 0 1.505335707)
(0.09677233876 0 1.269461257)
(-1.434015621 0 1.241358526)
(-1.314653954 0 1.184395399)
(-0.7843359012 0 1.246299658)
(-1.568274475 0 1.628856832)
(-1.621182677 0 1.647498924)
(-1.561504344 0 1.589370202)
(-1.630761193 0 1.471587695)
(-1.846898465 0 1.400067727)
(-1.920977206 0 1.361306316)
(-1.826374888 0 1.272537563)
(-1.553823764 0 1.073929363)
(-1.071972737 0 0.7213385718)
(-0.6206086502 0 0.1661333837)
(-0.4841644578 0 0.139964631)
(-0.4939856423 0 0.1608797826)
(-0.5436199477 0 0.2447833565)
(-0.5738334073 0 0.3697928375)
(-0.6018821809 0 0.4808649452)
(-0.5691222442 0 0.548055967)
(0.2274929327 0 0.7250819369)
(1.715636225 0 1.722050984)
(1.957370467 0 2.385809442)
(-0.3068819359 0 -0.05360939146)
(-0.6618700287 0 1.664184029)
(-1.82960907 0 1.855495455)
(-1.804210022 0 1.844758816)
(-1.734188849 0 1.713150061)
(-1.944339292 0 1.490507028)
(-2.044051877 0 1.429525473)
(-1.973948028 0 1.368679916)
(-1.737657721 0 1.202127895)
(-1.264366951 0 0.8585592285)
(-0.7077234529 0 0.4228444772)
(-0.4856468249 0 0.07405923271)
(-0.4539835403 0 0.120331426)
(-0.4965207633 0 0.1297363263)
(-0.5604218226 0 0.2498981524)
(-0.6090203068 0 0.4108896114)
(-0.6467126288 0 0.5300715578)
(-0.6465278396 0 0.6140228425)
(0.03525452334 0 0.7639570704)
(0.366657315 0 1.043417098)
(-2.130125711 0 2.123455707)
(-1.990610506 0 2.017587768)
(-2.053613304 0 1.568479581)
(-2.161330613 0 1.466818462)
(-2.102277376 0 1.446802674)
(-1.931783536 0 1.339880641)
(-1.452565868 0 0.9923676189)
(-0.7835719181 0 0.4891393079)
(-0.5094767682 0 0.2659062368)
(-0.4116412214 0 0.08692028601)
(-0.4425667393 0 0.11831055)
(-0.4951945654 0 0.1037588734)
(-0.5216887396 0 0.2430933671)
(-0.5848795416 0 0.4068527809)
(-0.6538621276 0 0.5336928131)
(-0.6698055781 0 0.6072577237)
(-0.6465644736 0 0.651102371)
(0.01049212187 0 0.6405714858)
(-2.232053924 0 1.503382158)
(-2.198473493 0 1.499042445)
(-2.084954056 0 1.449186196)
(-1.748951488 0 1.218679175)
(-0.7859759121 0 0.4751190629)
(-0.5033638983 0 0.2702284834)
(-0.4694147991 0 0.2653600919)
(-0.3805272005 0 0.1252125499)
(-0.4322898321 0 0.1345428924)
(-0.4868199094 0 0.1330988097)
(-0.5039798827 0 0.2214457076)
(-0.5588206497 0 0.3719603928)
(-0.6369461613 0 0.4998779221)
(0.4298257476 0 0.5341129237)
(0.2022944736 0 -0.2000696402)
(-0.5279791856 0 0.2742154865)
(-0.4827257084 0 0.2645110854)
(-0.4652966617 0 0.2695281598)
(-0.4024287811 0 0.1590806822)
(-0.413528577 0 0.146826249)
(-0.4749007549 0 0.156136517)
(-0.5000986543 0 0.2044802622)
(-0.8684083051 0 -0.2464210835)
(-0.6610221029 0 -0.2404273726)
(-0.4054833176 0 -0.428387199)
(-0.2343495314 0 -0.5970638439)
(-0.1170744711 0 -0.6594325594)
(-0.1347218092 0 -0.6398245146)
(-0.1360903202 0 -0.6504575366)
(-0.08932667488 0 -0.6344714862)
(-0.1230649668 0 -0.6309127936)
(-0.04290435246 0 -0.6139619199)
(0.02552375421 0 -0.5798352072)
(-0.01098048389 0 -0.5871896657)
(0.1149426505 0 -0.5392768182)
(0.2306555336 0 -0.502985388)
(0.20052741 0 -0.5430793933)
(0.3797248234 0 -0.4605794744)
(0.5529269811 0 -0.4588041636)
(0.5441659478 0 -0.5746707283)
(0.7215301645 0 -0.2700810768)
(0.0928358553 0 0.1335729884)
(-0.203704529 0 -0.2182624437)
(-0.3126905455 0 -0.5968928485)
(-0.3242657223 0 -1.493815408)
(-0.7748802722 0 -0.4277428097)
(-0.8547742448 0 -0.423895307)
(-0.9433350915 0 -0.4174321935)
(-1.015978635 0 -0.4337326392)
(-1.025803897 0 -0.402768396)
(-0.968762478 0 -0.3822634651)
(-0.9126325444 0 -0.318004116)
(-0.8937808566 0 -0.2699452041)
(2.239239842 0 -1.827103521)
(2.448704701 0 -1.738233554)
(2.447122707 0 -1.791973668)
(2.383685809 0 -1.610126669)
(2.250401813 0 -1.587336239)
(2.418248945 0 -1.690404216)
(1.813552537 0 -1.861839596)
(1.919876625 0 -2.110355513)
(-0.494829405 0 -0.3226588178)
(-0.5943168681 0 -0.3878128976)
(-0.6980640066 0 -0.4417426298)
(-0.6664241332 0 -0.4109664264)
(0.6484863591 0 -1.310354764)
(0.9487260649 0 -1.497625884)
(0.9781478479 0 -2.046635644)
(-0.3195051481 0 0.4060869675)
(-0.3729420912 0 -0.2978658624)
(-0.3956754412 0 -0.2968373371)
(-0.3923009415 0 -0.278386167)
(-0.4637297897 0 -0.3475999994)
(-0.5562800921 0 -0.4236161673)
(-0.5100414933 0 -0.3498380128)
(0.1572324079 0 0.3709360629)
(0.2305112576 0 0.3401907013)
(0.02812140883 0 0.2359091363)
(0.1077228222 0 0.4295451488)
(-0.3350517868 0 0.4426520519)
(-0.3488063973 0 -0.3370030572)
(-0.3583818649 0 -0.3274568297)
(-0.3606203796 0 -0.3180134914)
(-0.8875834667 0 0.2915672921)
(-0.8831362723 0 0.1992105393)
(-0.3266322264 0 -0.3734415822)
(-0.3284624365 0 -0.3633712084)
(-0.3358819051 0 -0.3551261917)
(-0.6730613807 0 0.1409219157)
(-0.6015833005 0 0.173985684)
(-0.3086092512 0 -0.3853701938)
(-0.3144797812 0 -0.3842229768)
(-0.366825348 0 -0.4784680883)
(-0.3385468521 0 -0.3939344777)
(-0.500135767 0 0.1017190799)
(-0.4770651608 0 0.1451431654)
(-0.5436227751 0 0.1595507624)
(-0.4193043223 0 0.1687139999)
(-0.2903964331 0 -0.3985705339)
(-0.2912464803 0 -0.3892435683)
(-0.2966286496 0 -0.3873726976)
(-0.3176754358 0 0.253063243)
(-0.1900038442 0 0.3328574313)
(-0.1517096744 0 0.1877463744)
(-0.2631547648 0 -0.397894941)
(-0.2795054652 0 -0.3996095777)
(3.796309838 0 -1.210275912)
(-0.2679866555 0 -0.3737680642)
(-0.2565612139 0 -0.3633396572)
(-0.2514152227 0 -0.3822846233)
(3.014673992 0 -4.178328479)
(3.07410724 0 -4.299561422)
(3.137519644 0 -4.374363743)
(-0.3022678588 0 -0.3128839639)
(-0.3041129444 0 -0.3245667661)
(-0.3400141646 0 -0.3477175517)
(-0.2933873859 0 -0.3508241773)
(3.08754801 0 -4.059824929)
(3.161419565 0 -4.050637015)
(3.096356333 0 -4.199139716)
(-0.09804839579 0 1.221432097)
(-0.3024411701 0 -0.2788315583)
(-0.3050182915 0 -0.2953916906)
(-0.2005059787 0 0.07348614504)
(-0.2492156606 0 -0.2264626431)
(-0.2986364098 0 -0.2644502908)
(-0.2996499384 0 -0.262090502)
(0.1395005883 0 -0.6832801164)
(0.1901771242 0 -0.6504599198)
(-0.2496366294 0 -0.2170236251)
(-0.2815657159 0 -0.2675515662)
(-0.2976137447 0 -0.2711463588)
(0.5732197964 0 -0.412613943)
(0.6197890523 0 -0.4623580622)
(0.458694237 0 -0.465207179)
(-0.2169028862 0 -0.1711376594)
(-0.2200720905 0 -0.2190298386)
(-0.2506309427 0 -0.2536914067)
(-0.3633730293 0 0.1240439654)
(0.4770396772 0 -0.3344330875)
(0.6858898798 0 -0.5154062499)
(-0.2061101093 0 -0.07542961341)
(-0.1818956472 0 -0.0768126301)
(-0.1838080621 0 -0.1591287988)
(-0.2958211833 0 0.1397619263)
(-0.2856970267 0 0.1483376666)
(-0.2908916497 0 0.1408113392)
(-0.1899640836 0 0.008389735641)
(-0.1975167903 0 0.0725364959)
(-0.2042731733 0 0.005025732303)
(-0.2549529142 0 0.1316523312)
(-0.2422428837 0 0.1417571357)
(-0.2573643923 0 0.1413275462)
(-0.1568816075 0 0.1661854132)
(-0.1960226251 0 0.1235584124)
(-0.2310005019 0 0.1680865574)
(-0.2337166533 0 0.1493715186)
(-0.0691162285 0 0.3180023086)
(-0.09831822085 0 0.2246830815)
(-0.1961171535 0 0.2251659903)
(-0.01091932828 0 0.3763468265)
(0.05689644241 0 0.31240132)
(0.04780985829 0 0.314051794)
(-0.01256692676 0 0.3587098746)
(0.03167266079 0 0.3035563806)
(0.08377149058 0 0.3245198695)
(-0.1149042107 0 0.2892427221)
(0.1140010061 0 0.1195412919)
(0.08454107395 0 0.2386421813)
(0.1184012642 0 0.2822626913)
(-0.02017391457 0 0.120003106)
(0.08100455401 0 0.1438729279)
(0.09352381896 0 0.2385571163)
(0.2310198337 0 0.5750260617)
(0.07368498238 0 0.4263674263)
(-0.04779371401 0 0.07127870927)
(0.1972600275 0 -0.903329109)
(-3.834662416 0 3.99089381)
(-3.768099288 0 3.898931695)
(-1.055392703 0 -1.165832975)
(-0.8209341945 0 0.5180130088)
(-0.6187343845 0 0.4110897349)
(-3.802158178 0 4.078229703)
(-3.405520993 0 1.608880971)
(-3.315016508 0 1.576227418)
(-3.513341939 0 3.35974945)
(0.06079931613 0 0.8775963258)
(0.4210089851 0 0.8222812795)
(-1.029556974 0 -1.201815383)
(-0.1144673578 0 -0.6868122968)
(-3.390107697 0 1.608672086)
(1.269386809 0 2.181571832)
(0.09009733739 0 1.21694535)
(0.01104948459 0 -0.1626800207)
(-1.381659748 0 1.239437202)
(1.66453426 0 1.969477283)
(1.847328917 0 2.40188712)
(-0.7071595589 0 1.878120898)
(-0.7151308628 0 1.760599305)
(-0.6926736373 0 1.765161471)
(-1.942586081 0 1.921062412)
(-1.708967956 0 1.804047576)
(-0.6004739135 0 0.6629515058)
(-0.5378348037 0 0.675085417)
(0.368933772 0 0.9721254331)
(-0.4836351154 0 0.6389745022)
(0.30708702 0 1.085777086)
(-2.215268381 0 2.097233851)
(0.6612403079 0 0.419908835)
(-0.2705983087 0 -0.1509808991)
(-2.0661558 0 2.083286916)
(-0.6726349366 0 0.5970512808)
(-0.6683687952 0 0.6163421404)
(-0.6649418706 0 0.6349036173)
(-0.1328911053 0 0.1875482601)
(-2.234325668 0 1.52537743)
(-2.218842916 0 1.511116553)
(-2.212635969 0 1.4982208)
(-2.196642806 0 1.508977053)
(-2.140027332 0 1.494357848)
(-2.153997884 0 1.490134027)
(-0.5017987148 0 0.2149297973)
(-0.5210040938 0 0.2804822632)
(-0.5271613033 0 0.2992711642)
(-0.5510587129 0 0.3538956106)
(-0.5983902119 0 0.4292482377)
(-0.6097452537 0 0.4496187881)
(-0.6617496773 0 0.5449890257)
(0.5691959837 0 1.278495023)
(0.1903640913 0 0.4923221655)
(-0.5602800528 0 0.2712794553)
(-0.5573866442 0 0.2548852814)
(-0.5328109744 0 0.2866561551)
(-0.5042404126 0 0.2766017433)
(-0.501970583 0 0.2717589226)
(-0.4841163073 0 0.2655999202)
(-0.4715316686 0 0.2604757117)
(-0.4710435194 0 0.2609581311)
(-0.464918781 0 0.2681660888)
(-0.4628649135 0 0.2487759992)
(-0.4622913516 0 0.2450666698)
(-0.4110877508 0 0.1622627932)
(-0.3700962137 0 0.1287167924)
(-0.3701354029 0 0.125395135)
(-0.4131120634 0 0.1567294024)
(-0.4497942876 0 0.152754728)
(-0.4778731982 0 0.1422076785)
(-0.6900689262 0 -0.2746166481)
(-0.3532747258 0 -0.4214339359)
(-0.4100827678 0 -0.4306434796)
(-0.2152251031 0 -0.5702810529)
(-0.1295846499 0 -0.670825224)
(-0.1830725624 0 -0.6756180379)
(-0.07877548806 0 -0.7002730511)
(-0.04981657219 0 -0.6874019997)
(-0.09866483634 0 -0.6567318769)
(-0.01250418357 0 -0.6824329933)
(0.03779194575 0 -0.6744206199)
(0.01291049736 0 -0.6040851071)
(0.1274936119 0 -0.6573864447)
(0.2892182824 0 -0.6419192198)
(0.2447819296 0 -0.5152691335)
(0.5555853504 0 -0.6590177582)
(0.9762960978 0 -0.8263871009)
(0.6371979125 0 -0.4954346705)
(1.540996475 0 -1.232760705)
(1.962215968 0 -1.709320772)
(1.71007582 0 -1.625888219)
(2.064799917 0 -1.792215478)
(2.130679845 0 -1.818633765)
(1.874628399 0 -1.870866319)
(-0.798877114 0 -0.4683147198)
(-0.8961345788 0 -0.4956789245)
(-0.8814750455 0 -0.4569257416)
(-0.9600946729 0 -0.5088472518)
(-0.9457747526 0 -0.4721366279)
(-0.9872240326 0 -0.4575396746)
(-1.017948274 0 -0.4578197469)
(-1.129564707 0 -0.4449942913)
(-1.001766324 0 -0.3734861155)
(-0.9258557924 0 -0.3934953045)
(-0.2667319833 0 -0.503182512)
(-0.2999560675 0 -0.4545381975)
(-0.01191482307 0 -0.6428871736)
(0.06434223164 0 -0.74101068)
(-0.05593865242 0 -0.6873440959)
(0.1131880089 0 -0.7907596587)
(0.1404114911 0 -0.7965836038)
(0.02436192849 0 -0.7305225042)
(0.1761982383 0 -0.7956031117)
(0.242240915 0 -0.8013281896)
(0.1161874799 0 -0.7477427254)
(0.3608349916 0 -0.8153352602)
(0.5864959517 0 -0.8668983181)
(0.4236024592 0 -0.7801671048)
(0.9848156862 0 -1.005636736)
(1.531711299 0 -1.278430512)
(1.343903761 0 -1.143349107)
(1.957842269 0 -1.56203891)
(2.12392561 0 -1.696401514)
(2.063676215 0 -1.712587514)
(2.178065616 0 -1.716410077)
(2.225242359 0 -1.702502026)
(2.196690014 0 -1.766598872)
(2.276645342 0 -1.656484364)
(2.302010039 0 -1.555379463)
(2.377622743 0 -1.657879433)
(2.170793456 0 -1.432876601)
(1.930905026 0 -1.346190949)
(2.08978224 0 -1.493194025)
(1.505548774 0 -1.415323876)
(1.389867865 0 -1.468714564)
(1.697976242 0 -1.772944112)
(-0.6512147568 0 -0.4904036946)
(-0.7363336059 0 -0.5343473569)
(-0.7153905659 0 -0.4810271738)
(-0.8164609556 0 -0.5673299362)
(-0.8699634238 0 -0.5812622145)
(-0.8927715552 0 -0.5398680809)
(-0.8659702137 0 -0.5465139651)
(-0.9350994742 0 -0.535667798)
(-0.9282479686 0 -0.4963408585)
(-1.153536002 0 -0.5814511148)
(-1.387063169 0 -0.5954500795)
(-1.265995686 0 -0.5211322849)
(-1.165825665 0 -0.5339735208)
(-0.2646464053 0 -0.596300779)
(-0.265495107 0 -0.5422084882)
(0.1608955118 0 -0.7009823645)
(0.2520735433 0 -0.7845906184)
(0.1680380182 0 -0.7568623058)
(0.3072982534 0 -0.8288393382)
(0.35687981 0 -0.8429421011)
(0.2727475227 0 -0.833750663)
(0.4076189315 0 -0.8551860871)
(0.4611623315 0 -0.8869135252)
(0.3969530623 0 -0.8435314883)
(0.5318436022 0 -0.9331324653)
(0.6803250932 0 -0.9868320999)
(0.6992081452 0 -0.9208231172)
(0.9536999849 0 -1.056431486)
(1.354106293 0 -1.183395167)
(1.523458306 0 -1.264332409)
(1.781012746 0 -1.382645783)
(2.068789028 0 -1.546677974)
(2.147371854 0 -1.654440005)
(2.196336136 0 -1.595693639)
(2.240633329 0 -1.557967815)
(2.241822131 0 -1.632815974)
(2.236479041 0 -1.465780864)
(2.168604074 0 -1.326400472)
(2.231058674 0 -1.440339128)
(1.97441168 0 -1.159911806)
(1.645004966 0 -0.9888963349)
(1.7791233 0 -1.169167899)
(1.138044659 0 -0.8812504961)
(0.8813948497 0 -0.8065548884)
(1.101678066 0 -1.134052582)
(0.3085793052 0 -0.3698832157)
(0.369149659 0 -0.4032365663)
(0.462393871 0 -0.832950841)
(-0.3992530278 0 -0.3554767691)
(-0.475633538 0 -0.4346352796)
(-0.427212271 0 -0.3477545665)
(-0.5646110417 0 -0.5308747023)
(-0.6410661734 0 -0.6053328805)
(-0.6019326784 0 -0.5063923055)
(-0.7068412293 0 -0.6577527035)
(-0.7638890316 0 -0.6945470082)
(-0.752741643 0 -0.6045049624)
(-0.7926983062 0 -0.6989703959)
(-0.7816358408 0 -0.6538402456)
(-0.8292370249 0 -0.6171192073)
(-0.8217486561 0 -0.6260978616)
(-0.9862460695 0 -0.6613272071)
(-0.9570471718 0 -0.590236075)
(-1.29318815 0 -0.7452189984)
(-1.599670471 0 -0.7599366688)
(-1.493976094 0 -0.6714070967)
(-1.282348032 0 -0.6631130168)
(-0.238737326 0 -0.6660211249)
(-0.2716636793 0 -0.6189494766)
(0.1685518532 0 -0.7105621165)
(0.2578527215 0 -0.7910300594)
(0.3567624643 0 -0.8068579841)
(0.329391771 0 -0.877924081)
(0.4201251769 0 -0.9525785364)
(0.477572328 0 -0.8919651295)
(0.5172808576 0 -0.996885147)
(0.624406783 0 -1.019074484)
(0.5296589632 0 -0.9811692882)
(0.689382167 0 -1.059012815)
(0.8073290917 0 -1.0782654)
(0.7091963828 0 -1.047127934)
(0.9542316437 0 -1.063854461)
(1.170645393 0 -1.065851981)
(1.203920563 0 -1.105194323)
(1.428362981 0 -1.094284007)
(1.671034078 0 -1.155708424)
(1.863943281 0 -1.346054953)
(1.885017889 0 -1.22526314)
(2.04062978 0 -1.259574197)
(2.183717081 0 -1.447031283)
(2.097286496 0 -1.223654096)
(2.031220203 0 -1.102894931)
(2.109100878 0 -1.219747542)
(1.814550594 0 -0.9164393943)
(1.374361228 0 -0.6946745055)
(1.53295793 0 -0.8278436984)
(-0.9953284956 0 -0.3595717074)
(0.5932464305 0 -0.2751011675)
(0.7151306866 0 -0.5029124385)
(0.1635669345 0 0.1444951432)
(0.3509111929 0 0.1366967794)
(0.3748351705 0 -0.1436475125)
(0.3363324285 0 0.4372355209)
(-0.1768331008 0 0.378666679)
(0.2095432116 0 0.4496081678)
(-0.5824844104 0 0.3411595187)
(-0.7319017774 0 0.368539056)
(-0.6055981947 0 0.4646762531)
(-0.3588126103 0 -0.3870300399)
(-0.4238820558 0 -0.4783347739)
(-0.3776722413 0 -0.3702186169)
(-0.5143568111 0 -0.616299586)
(-0.5939693885 0 -0.7370551577)
(-0.5348157264 0 -0.565683114)
(-0.6559050298 0 -0.8243315271)
(-0.7063080727 0 -0.8850528333)
(-0.6755081362 0 -0.7304648037)
(-0.7389916584 0 -0.9145120344)
(-0.7365397758 0 -0.8927957633)
(-0.7616856865 0 -0.7975095769)
(-0.7174954038 0 -0.8373015653)
(-0.74118597 0 -0.8092954609)
(-0.7502167923 0 -0.7134059951)
(-0.8300273609 0 -0.8165481234)
(-1.018689692 0 -0.857713688)
(-1.010809184 0 -0.749444804)
(-1.367088101 0 -0.9468972875)
(-1.882201729 0 -1.038869356)
(-1.716554607 0 -0.8752399419)
(-2.229108893 0 -0.9398372819)
(-2.279005594 0 -0.7345860272)
(0.03921690543 0 -0.8845115078)
(-0.7121185079 0 -0.6563527993)
(0.07868284874 0 -0.8398972429)
(0.4473369472 0 -0.9651728826)
(0.3029136124 0 -0.9813696924)
(0.3769751239 0 -1.051085575)
(0.3606214856 0 -0.9022145774)
(0.6252452358 0 -0.9074481374)
(0.547411761 0 -0.6767566889)
(0.5091767198 0 -1.033321443)
(0.1646047424 0 -0.7886230693)
(0.5743597486 0 -1.032208752)
(0.9798863142 0 -1.084345778)
(0.7531784584 0 -1.086686075)
(1.087431291 0 -1.076225714)
(1.243637364 0 -1.036692267)
(1.384385338 0 -1.027355033)
(1.500965459 0 -0.9649487227)
(1.56646917 0 -1.043075112)
(1.602222611 0 -0.892551328)
(1.707660812 0 -0.8269300088)
(1.856926134 0 -1.03280821)
(1.785701598 0 -0.7846074811)
(1.778215882 0 -0.7199620819)
(1.911363052 0 -0.9393372245)
(1.624216555 0 -0.6035166731)
(1.312948944 0 -0.623860619)
(1.207652808 0 -2.034740662)
(2.191722231 0 0.0253999703)
(0.5990027839 0 0.1384622706)
(0.4412019596 0 1.663735518)
(0.5112596044 0 0.3432328553)
(0.5423108228 0 0.4327398782)
(0.424138637 0 0.4005575723)
(-0.2874617302 0 0.2521238066)
(-0.5554571945 0 0.2617562463)
(-0.5157791372 0 0.2327268361)
(-0.6982158647 0 0.2963650869)
(-0.7968524775 0 0.1495903684)
(-0.7941458959 0 0.2980192182)
(-0.8047426242 0 0.09662541256)
(-0.7344700512 0 0.1074918215)
(-0.8413950766 0 0.1386211065)
(-0.4688654131 0 -0.6833239309)
(-0.564651831 0 -0.8800304345)
(-0.4980024645 0 -0.6697441082)
(-0.6320741911 0 -1.023104461)
(-0.6779569839 0 -1.117602982)
(-0.6450328916 0 -0.9335889289)
(-0.7030966953 0 -1.161693006)
(-0.7008677693 0 -1.145819045)
(-0.7212847083 0 -1.042840836)
(-0.6805552022 0 -1.08820605)
(-0.6764088364 0 -1.044487025)
(-0.700008283 0 -0.9698443392)
(-0.7056664912 0 -1.037973274)
(-0.7695041719 0 -1.060716619)
(-0.748685247 0 -0.9321004222)
(-0.8755235201 0 -1.107290026)
(-1.039510663 0 -1.167451939)
(-1.017010898 0 -0.9984543508)
(-1.309696951 0 -1.223672107)
(-2.011370558 0 -1.401978554)
(-1.975823865 0 -1.208690213)
(-2.427058011 0 -1.231754848)
(-2.419365463 0 -0.8179174583)
(-2.390430126 0 -0.7928147752)
(-1.105153338 0 -0.3673968906)
(-2.108553179 0 -0.6383376987)
(-2.010033779 0 -0.5186539291)
(-1.329788883 0 0.1141837667)
(-1.280723861 0 0.208270953)
(-0.8414756873 0 0.2207963075)
(-2.259092774 0 1.130390406)
(-2.209664464 0 1.634830376)
(0.4892604946 0 -1.477609941)
(-1.240880174 0 1.818163456)
(-1.328599914 0 1.976509176)
(1.082066581 0 -0.7717617159)
(0.7054255575 0 -0.1326361792)
(1.010866008 0 -0.5601741385)
(1.2890756 0 -0.6017750809)
(1.202123895 0 -0.907297875)
(1.36856135 0 -0.675056808)
(1.445546591 0 -0.8946669981)
(1.412337842 0 -0.7262606567)
(1.51695201 0 -0.5797694895)
(1.61272369 0 -0.6735821725)
(1.584208949 0 -0.455487688)
(1.597233372 0 -0.334645478)
(1.671914358 0 -0.5077620736)
(1.488306032 0 -0.1979773289)
(1.268498407 0 0.009555662806)
(1.280242389 0 -0.1997616573)
(0.8850332641 0 0.1417138019)
(0.7630113583 0 0.2908954243)
(0.7044923164 0 0.1555360887)
(0.6169019468 0 0.3237040556)
(-0.468437047 0 0.2075986859)
(0.3328702724 0 0.2883276546)
(-0.6455245651 0 0.1830720233)
(-0.7310780195 0 0.08546099444)
(-0.6546723492 0 0.2963108153)
(-0.722943007 0 -0.04708934176)
(-0.6386770808 0 -0.03852730276)
(-0.752400411 0 0.00671759306)
(-0.5771601956 0 0.03181110606)
(-0.5209535675 0 0.05367254345)
(-0.632854375 0 0.08734341201)
(-0.33126322 0 -0.4774599348)
(-0.4317963525 0 -0.701730758)
(-0.4123272342 0 -0.6172362897)
(-0.5273160747 0 -0.91819923)
(-0.5937143062 0 -1.074655657)
(-0.5983076913 0 -1.03163522)
(-0.6326891282 0 -1.176451948)
(-0.640875871 0 -1.218092714)
(-0.6768844856 0 -1.224775369)
(-0.6221028078 0 -1.200392984)
(-0.6033897629 0 -1.16589022)
(-0.6528853399 0 -1.17498664)
(-0.6111462724 0 -1.16060715)
(-0.6487368338 0 -1.187888036)
(-0.6632523157 0 -1.118940672)
(-0.7139309834 0 -1.237396425)
(-0.8087157882 0 -1.302082279)
(-0.7943726283 0 -1.182796836)
(-0.938035123 0 -1.373949133)
(-1.108970862 0 -1.439543595)
(-1.084692234 0 -1.319435037)
(-1.339960474 0 -1.489771351)
(-1.714278583 0 -1.751002835)
(-1.948324316 0 -1.607881376)
(-2.291393599 0 -1.7197939)
(-2.513284003 0 -0.9430017553)
(-2.493794323 0 -0.8439903723)
(-1.336027136 0 0.0880772739)
(-0.8597841051 0 -0.3324695165)
(-1.836478957 0 -0.684727375)
(-0.8160325274 0 0.1763538636)
(-0.6443344636 0 0.202934964)
(-1.519673064 0 0.2598348081)
(-0.6929518027 0 0.8941685132)
(-0.5486919546 0 0.5180025979)
(-1.701138716 0 1.533057447)
(-0.4856975085 0 0.3194925514)
(-0.5346548552 0 0.3492970598)
(-1.644171317 0 1.582959892)
(-0.6313238224 0 0.4526964053)
(-0.7743476205 0 0.6318569831)
(-1.380298533 0 1.221939735)
(1.041075389 0 -0.6128020189)
(1.224308679 0 -0.7454470305)
(1.342609341 0 -0.675501047)
(1.323944909 0 -0.7526687512)
(1.289351141 0 -0.5192987649)
(1.326892942 0 -0.4915069559)
(1.280818478 0 -0.3430325355)
(1.289096631 0 -0.1121587094)
(1.436127812 0 -0.1969655474)
(1.175810401 0 0.06029703705)
(0.9978808294 0 0.3345882229)
(1.009558453 0 0.1197090971)
(0.750074829 0 0.6353310409)
(0.2960589394 0 0.8293945568)
(0.6850909552 0 0.3728387044)
(-0.7203048222 0 0.3425631302)
(-0.8472556362 0 -0.2103801587)
(-0.7576255732 0 0.0447272636)
(-0.6747659475 0 -0.1057191548)
(-0.5499175176 0 -0.1038589984)
(-0.6937707518 0 -0.05797617348)
(-0.4429068442 0 -0.1210156383)
(-0.3751367575 0 -0.1052187826)
(-0.5028328808 0 -0.0630993113)
(-0.3385306396 0 -0.05309808701)
(-0.2930361573 0 -0.04225024019)
(-0.4029370642 0 0.005589202473)
(-0.3115347575 0 0.09594774827)
(-0.3066780074 0 0.1467242769)
(-0.3530855499 0 0.1300734874)
(-0.254684003 0 -0.3757894012)
(-0.2503031777 0 -0.3640166199)
(-0.2734296172 0 -0.3815520705)
(-0.2744264631 0 -0.402629502)
(-0.3520405816 0 -0.5508952568)
(-0.4081209322 0 -0.674594568)
(-0.4371272538 0 -0.7164955639)
(-0.4997768443 0 -0.8390384631)
(-0.5569303531 0 -1.000188323)
(-0.5346071734 0 -0.9183134118)
(-0.5394251134 0 -0.9587512778)
(-0.5898313863 0 -1.118759681)
(-0.5261042925 0 -0.9803387418)
(-0.5208507513 0 -1.023292345)
(-0.5592453587 0 -1.123757207)
(-0.5417445444 0 -1.112993523)
(-0.5930348529 0 -1.244224209)
(-0.6261800468 0 -1.241468723)
(-0.6717676628 0 -1.392200456)
(-0.7700272047 0 -1.522282491)
(-0.8029186259 0 -1.421187836)
(-0.8803119368 0 -1.601871145)
(-0.9964416331 0 -1.589049525)
(-1.082633912 0 -1.531201207)
(-1.068818479 0 -1.347572501)
(-0.5689834554 0 -0.1444670288)
(-1.142804504 0 -1.371371128)
(-0.4186405328 0 -0.2325168191)
(-0.7406928862 0 -0.7937445917)
(-2.017153296 0 -1.089898263)
(-0.4770538423 0 0.05928716312)
(-1.043555524 0 0.1938719789)
(-0.7861481629 0 0.1180964378)
(-1.086802564 0 0.3302334465)
(-0.7552603264 0 0.341009033)
(-0.6910597025 0 0.2619578352)
(-0.6031485217 0 0.3421783163)
(-0.5414440251 0 0.3417664243)
(-0.5119273507 0 0.302007418)
(-0.5272478645 0 0.3509551898)
(-0.6673095259 0 0.4526825342)
(-0.5721004141 0 0.3816433918)
(-0.899466021 0 0.7273532813)
(-1.007520846 0 0.9624500785)
(-0.8050658693 0 0.6905020027)
(-1.010478325 0 1.109094953)
(-0.991894415 0 1.199230887)
(0.5283345045 0 -0.1849734086)
(-0.8254596212 0 1.13970858)
(0.3826329771 0 0.1901665747)
(1.18001811 0 -0.4868262877)
(0.6674792933 0 0.06888275183)
(0.5836617552 0 0.4505341911)
(1.255182288 0 -0.001969161034)
(-0.6615257006 0 1.216512871)
(-1.127870012 0 1.452386712)
(0.6064900868 0 0.7647487914)
(-1.062765779 0 1.3321958)
(-1.070857075 0 0.189139203)
(-0.8152083855 0 0.8117026137)
(-0.7963347738 0 -0.4600325701)
(-0.4217701734 0 -0.2587175356)
(-0.6776616466 0 -0.2839894013)
(-0.2920462441 0 -0.214523775)
(-0.1843781403 0 -0.1531336878)
(-0.3639874248 0 -0.1570334719)
(-0.07646137357 0 -0.1187456747)
(0.001869179176 0 -0.105737805)
(-0.1308888785 0 -0.1703367835)
(0.09704847859 0 -0.04117765187)
(0.078499911 0 0.02925260795)
(0.02357334179 0 -0.138135753)
(0.2395890892 0 0.1344084311)
(1.23715515 0 -0.1679079366)
(0.5481417933 0 0.008410794021)
(2.724460885 0 -0.6982176874)
(3.517805929 0 -1.077721866)
(3.685363719 0 -1.20515777)
(-0.2585189074 0 -0.354899603)
(-0.2820317617 0 -0.3458596868)
(-0.2401537933 0 -0.348334531)
(-0.3121156554 0 -0.3465081662)
(-0.3354943493 0 -0.3706014216)
(-0.3087633364 0 -0.4219328122)
(-0.3602507535 0 -0.43973121)
(-0.3967269157 0 -0.5337940319)
(-0.4389001304 0 -0.6558440888)
(-0.4329789688 0 -0.6058545673)
(-0.4538897643 0 -0.6389690675)
(-0.4942088474 0 -0.7753904654)
(-0.463626451 0 -0.6511489774)
(-0.476612806 0 -0.6613666989)
(-0.4927048663 0 -0.8481706075)
(-0.4997104819 0 -0.6818173988)
(-0.5341376217 0 -0.7148390029)
(-0.5544334207 0 -1.103121811)
(-0.5704572348 0 -0.7498546172)
(-0.5744320357 0 -0.7643771478)
(-0.697734177 0 -1.493470304)
(-0.4680665652 0 -0.7695462321)
(-0.2293010886 0 -0.8530547648)
(-0.8030573765 0 -1.559178199)
(-0.08800194637 0 -0.9875470361)
(-0.3265549805 0 -0.03467041847)
(-0.7314349335 0 -0.2224687336)
(-0.3257116858 0 0.02058244248)
(-0.6126245085 0 0.01571250517)
(-0.3601945127 0 0.04523903088)
(-1.768731595 0 0.2098746867)
(-2.560963607 0 0.6594230649)
(-1.715643587 0 0.3692781697)
(-1.264715605 0 0.5783268818)
(-0.8105012883 0 0.4745210507)
(-0.794996046 0 0.4177526727)
(-0.6697015824 0 0.4290797157)
(-0.6007075064 0 0.4050119533)
(-0.5718447479 0 0.375470245)
(-0.6042845957 0 0.4208184743)
(-1.075484492 0 0.7399170892)
(-0.834373958 0 0.5698310378)
(-1.782532531 0 1.82436236)
(-1.451989326 0 1.929270586)
(-1.274828347 0 1.399954909)
(-1.172370987 0 1.954934115)
(-1.026260698 0 2.031804553)
(-1.006969305 0 1.528405978)
(-0.9334151411 0 2.074497734)
(-0.8702038791 0 1.952254682)
(-0.8625017075 0 1.488328435)
(-0.868628091 0 1.662808972)
(-0.9299759545 0 1.393637681)
(-1.004493204 0 1.359578135)
(-0.9848734658 0 1.330470804)
(-0.9100223656 0 1.355341096)
(-1.053995611 0 1.47524137)
(-0.8282784293 0 0.1060510803)
(-0.6021669499 0 -0.7014275095)
(-0.9365395325 0 -0.3363279976)
(-0.0847860532 0 -0.5947150592)
(0.2668051735 0 -0.8872887986)
(-0.2098754774 0 -0.3219903027)
(0.8237479532 0 -1.492663493)
(1.460996393 0 -2.251282227)
(0.5481198773 0 -1.022420105)
(2.008278124 0 -2.92369915)
(2.302751923 0 -3.283623874)
(1.965022159 0 -2.683321854)
(2.448988599 0 -3.467087218)
(2.548005921 0 -3.590925831)
(2.491422871 0 -3.292147956)
(2.638513716 0 -3.70032895)
(2.73294464 0 -3.8105354)
(2.705100949 0 -3.504845811)
(2.832172626 0 -3.925232301)
(2.930256831 0 -4.048661651)
(2.939242265 0 -3.818199341)
(-0.3847031682 0 -0.3678115713)
(-0.4298952174 0 -0.3771939466)
(-0.3638147622 0 -0.3604807743)
(-0.4605255669 0 -0.3682384271)
(-0.4621108102 0 -0.34386621)
(-0.4004391117 0 -0.3512188581)
(-0.4228944409 0 -0.3251511479)
(-0.3655223075 0 -0.3513725279)
(-0.374352724 0 -0.4530045673)
(-0.3442651975 0 -0.4232204497)
(-0.3607618801 0 -0.4842580968)
(-0.4129306167 0 -0.5828051446)
(-0.3809271074 0 -0.5448293952)
(-0.4133200027 0 -0.5995335227)
(-0.4573406172 0 -0.6520493258)
(-0.454092594 0 -0.6537287138)
(-0.5096628783 0 -0.7267112713)
(-0.5441998227 0 -0.7502145516)
(-0.5916142095 0 -0.8309954556)
(-0.7022303863 0 -0.9624113296)
(-0.6904892742 0 -0.9034194163)
(-0.8268699472 0 -1.096134812)
(-0.9513288076 0 -1.196232584)
(-0.8761004969 0 -1.040102716)
(-0.5076967643 0 -0.1717334847)
(-0.5377162178 0 -0.1878159852)
(-0.3987821807 0 -0.07765494819)
(-0.5501379521 0 -0.07354756866)
(-1.740078533 0 -0.01758581521)
(-1.18496293 0 -0.01149341838)
(-4.460977686 0 0.7784920116)
(-3.604347693 0 1.524092034)
(-3.258587347 0 1.03984479)
(-1.118788413 0 0.6568407201)
(-0.8401225476 0 0.5371157175)
(-0.8198143732 0 0.5097826093)
(-0.7327383483 0 0.4916904499)
(-0.6703506379 0 0.4691654249)
(-0.6322929543 0 0.4347174561)
(-0.6925321329 0 0.498020026)
(-1.620435633 0 1.181383335)
(-1.360548613 0 0.9535237145)
(-2.24387065 0 2.815990884)
(-1.454514831 0 2.991138651)
(-1.501956461 0 2.550880074)
(-1.099962332 0 2.89470236)
(-0.9287291708 0 2.980439011)
(-1.027231318 0 2.573481368)
(-0.860278103 0 3.152347673)
(-0.8364590113 0 2.957137448)
(-0.8932515328 0 2.504317683)
(-0.8589684228 0 2.361519033)
(-0.9164214531 0 1.728061498)
(-0.928295249 0 1.531721804)
(-0.9337806464 0 1.429421225)
(-0.6859626825 0 0.1748159199)
(-0.8108082845 0 1.002311496)
(-0.3471435976 0 -1.061330526)
(0.2836784418 0 -1.130422556)
(-0.1358844582 0 -0.9334644161)
(0.6822115813 0 -1.450166209)
(1.243444479 0 -2.098386377)
(0.8248106136 0 -1.590064229)
(1.79928716 0 -2.784518774)
(2.148803823 0 -3.237983065)
(1.940804979 0 -2.940905867)
(2.329869543 0 -3.452666918)
(2.444326387 0 -3.575939399)
(2.39051378 0 -3.495924485)
(2.540747373 0 -3.671358333)
(2.634670461 0 -3.755889783)
(2.587468673 0 -3.725403936)
(2.730185286 0 -3.833568293)
(2.82704538 0 -3.904514917)
(2.775721929 0 -3.918263367)
(2.922300081 0 -3.967399685)
(3.010929795 0 -4.019911482)
(2.965164854 0 -4.100338835)
(-0.3468303241 0 -0.308313131)
(-0.3923580561 0 -0.3467256882)
(-0.3763420155 0 -0.3484660855)
(-0.4346324815 0 -0.3723403908)
(-0.475634161 0 -0.3918271101)
(-0.4658501738 0 -0.3874619572)
(-0.5164008681 0 -0.3961931429)
(-0.5320371569 0 -0.3636878062)
(-0.5063808057 0 -0.3509231194)
(-0.4880333357 0 -0.3015964589)
(-0.3920666514 0 -0.245325514)
(-0.3778501985 0 -0.2798751994)
(-0.3019279105 0 -0.2217328074)
(-0.2870812778 0 -0.2289706016)
(-0.3143828908 0 -0.3548721409)
(-0.2753450458 0 -0.2475079745)
(-0.3032670289 0 -0.2339694409)
(-0.3449835528 0 -0.4654795054)
(-0.3244295965 0 -0.2256546522)
(-0.334118464 0 -0.2648244647)
(-0.4177135099 0 -0.5665848288)
(-0.3645595018 0 -0.3601566234)
(-0.4560644738 0 -0.5988540437)
(-0.6360150487 0 -0.9049687506)
(-0.6583305505 0 -0.9635382936)
(-0.9353784679 0 -1.330101284)
(-0.9711955481 0 -1.27898326)
(-1.053492488 0 -0.7822780924)
(-1.147416527 0 -0.9513646575)
(-0.7456487148 0 -0.3987793484)
(-0.7498635083 0 -0.2137828427)
(-1.348846317 0 0.09335795462)
(-2.159408872 0 -0.01952530595)
(-1.796260523 0 0.6430554101)
(-0.9021715579 0 0.3833402181)
(-3.215507742 0 1.955719445)
(-1.029628231 0 0.6329462957)
(-0.9141308394 0 0.606067992)
(-0.8724361688 0 0.5682460678)
(-0.8331094453 0 0.5828135745)
(-0.7774760852 0 0.5707694312)
(-0.7175867984 0 0.5126736584)
(-0.9399611711 0 0.6228877741)
(-1.44857873 0 0.7760319977)
(-1.70586683 0 1.296331528)
(-0.8547058188 0 1.329581514)
(-0.3823845192 0 3.884643219)
(-1.23667549 0 3.347117363)
(-0.3013418167 0 3.965918438)
(-0.22161878 0 3.284138957)
(-0.6708716381 0 3.28175129)
(-0.4334022688 0 2.47740066)
(-0.6282591382 0 2.344067662)
(-0.7031825325 0 3.076744706)
(-0.7575764037 0 2.036802578)
(-0.8775894708 0 1.646412893)
(-0.8877259478 0 1.850926506)
(-0.948458435 0 1.284839428)
(-0.1709667456 0 -1.035977107)
(-0.4466460962 0 -0.6259590575)
(0.3093865823 0 -1.436339053)
(0.6845990904 0 -1.478802142)
(0.528393007 0 -1.329491394)
(1.103852054 0 -1.942223042)
(1.62869165 0 -2.525635525)
(1.505201498 0 -2.400952978)
(2.09457634 0 -3.105360727)
(2.331729082 0 -3.406749135)
(2.260163027 0 -3.363443569)
(2.441527802 0 -3.512935231)
(2.52583954 0 -3.574446132)
(2.48936026 0 -3.591887163)
(2.609402405 0 -3.630396714)
(2.69391 0 -3.684187574)
(2.672877704 0 -3.732944282)
(2.776801315 0 -3.734269804)
(2.854685647 0 -3.779974041)
(2.854559311 0 -3.848603161)
(2.923719037 0 -3.821933063)
(2.980173829 0 -3.861179128)
(3.01104174 0 -3.937791266)
(3.022054606 0 -3.89614518)
(3.052669578 0 -3.905438105)
(3.114772484 0 -3.982942504)
(-0.3453324609 0 -0.3060060123)
(-0.3686745754 0 -0.336927904)
(-0.3889231192 0 -0.3432347378)
(-0.3930071147 0 -0.3662884889)
(-0.4343052565 0 -0.4069730637)
(-0.4640760236 0 -0.3958088214)
(-0.4930710585 0 -0.4358523653)
(-0.5277504824 0 -0.3917597069)
(-0.5389874889 0 -0.3772340984)
(-0.5065163614 0 -0.3059734398)
(-0.4109190952 0 -0.2134385571)
(-0.3993332978 0 -0.2273646287)
(-0.3004573074 0 -0.1310340379)
(-0.3439381688 0 0.0008067813312)
(-0.2894317007 0 -0.1359006194)
(-0.4731412385 0 0.1305369292)
(-0.6214527689 0 0.2384783966)
(-0.4103730841 0 0.02510434043)
(-0.6389855192 0 0.2861849831)
(-0.5928496273 0 0.2748055164)
(-0.3977484456 0 0.0324754348)
(-0.4981005099 0 0.2122311883)
(-0.4037307955 0 0.0825829694)
(-0.3382642759 0 -0.2069814447)
(-0.3702818588 0 -0.1909604256)
(-0.4884308321 0 -0.5174065549)
(-0.5106394031 0 -0.9768645508)
(-0.9932026152 0 -1.251514627)
(-1.509312813 0 -1.581770068)
(-1.452581966 0 -1.381623132)
(-1.005755024 0 -0.536635261)
(-1.456427539 0 0.08488799012)
(-1.470870204 0 0.09550230276)
(-1.262804831 0 0.5373792166)
(-0.9247123916 0 0.3280623046)
(-0.8421481985 0 0.3823687548)
(-1.124870318 0 0.7175819521)
(-1.074907999 0 0.7650709105)
(-0.9815395282 0 0.6679259634)
(-1.011671159 0 0.7709053447)
(-0.9489534215 0 0.7645019967)
(-0.8542176401 0 0.6492550199)
(-0.5846980692 0 0.5733968158)
(-0.4446157194 0 0.523789067)
(-0.7035083291 0 0.8204804331)
(-0.519301221 0 0.5744586477)
(0.1978863416 0 1.236894135)
(0.6617912469 0 1.682499135)
(-0.1143324253 0 1.100230209)
(-0.5280847013 0 0.8807241662)
(0.1944078706 0 1.474441893)
(-0.7715652838 0 0.7928627253)
(-0.9121750289 0 0.7850642221)
(-0.7750926633 0 0.8618634394)
(-0.9978161961 0 0.8257321469)
(-1.057013567 0 0.9634671391)
(-1.017058777 0 0.9694678381)
(-1.153339214 0 1.093253663)
(0.3124625064 0 -1.146188425)
(0.06824732873 0 -1.193599194)
(0.5165165003 0 -1.522731158)
(0.8048443124 0 -1.529031429)
(0.7638221008 0 -1.556749182)
(1.147795934 0 -1.939994593)
(1.526590032 0 -2.375700992)
(1.627735196 0 -2.507746563)
(1.963636941 0 -2.886289294)
(2.301272184 0 -3.277585072)
(2.361994363 0 -3.389110755)
(2.467084241 0 -3.435099129)
(2.548325412 0 -3.484343469)
(2.550252683 0 -3.539451704)
(2.609586055 0 -3.513699765)
(2.666302928 0 -3.543722378)
(2.694785784 0 -3.622942191)
(2.716179153 0 -3.572451509)
(2.751143229 0 -3.591997136)
(2.828022557 0 -3.705371107)
(2.755306824 0 -3.585482087)
(2.685262977 0 -3.5024662)
(2.917364955 0 -3.772905476)
(2.387631229 0 -3.164724844)
(1.383404931 0 -2.037428081)
(2.86475702 0 -3.684740589)
(-0.2925733519 0 -0.2938085519)
(-0.2867813989 0 -0.3312152115)
(-0.3337352716 0 -0.3326181927)
(-0.284347087 0 -0.3998369688)
(-0.3261670707 0 -0.4809356562)
(-0.3884233374 0 -0.4333991075)
(-0.3941417407 0 -0.5057675077)
(-0.5044377211 0 -0.4943527691)
(-0.512451431 0 -0.4227631764)
(-0.6150929257 0 -0.4323991098)
(-0.5677339332 0 -0.2510128613)
(-0.4606461984 0 -0.2158307819)
(-0.4685757642 0 0.2268124498)
(-0.7010724372 0 0.3689336161)
(-0.5233778077 0 0.2396305468)
(-0.8472054411 0 0.4191177388)
(-0.922836015 0 0.4898836217)
(-0.8030026534 0 0.3890246859)
(-0.9407982334 0 0.5400201448)
(-0.9188034345 0 0.5613466635)
(-0.7841085811 0 0.450337933)
(-0.8618945716 0 0.5494843065)
(-0.7677798057 0 0.5036447631)
(-0.584986854 0 0.3445673739)
(-0.5987189433 0 0.3539833512)
(-0.4358848214 0 0.06441395949)
(-0.3928649137 0 -0.2215484149)
(-0.3584898175 0 -0.0814018435)
(-1.060594743 0 -1.582245644)
(-1.374291717 0 -1.637849446)
(-0.921507265 0 -0.527656859)
(-0.8060472635 0 -0.03524202029)
(-1.097121065 0 0.02691974956)
(-0.9307179277 0 0.6705991073)
(-0.6392900278 0 0.9413954515)
(-1.018004836 0 0.3012316123)
(-0.5472346999 0 1.155767559)
(-0.6498521719 0 1.133428568)
(-1.155569754 0 0.9008374446)
(-0.6251836287 0 1.49940715)
(-0.4845174066 0 1.361781076)
(-1.033779989 0 0.9464096533)
(-0.508388073 0 0.6461073095)
(-0.5567592784 0 0.6135844038)
(-0.4917507315 0 0.5594778218)
(-0.6155917424 0 0.6496494924)
(-0.6775428665 0 0.6897353626)
(-0.6351705152 0 0.6585124108)
(-0.772266148 0 0.7208841206)
(-0.8629651441 0 0.7477773939)
(-0.7981907319 0 0.7252436564)
(-0.9328920132 0 0.7799719386)
(-0.9887895988 0 0.81398383)
(-0.9597845638 0 0.7899757517)
(-1.033358633 0 0.8534754316)
(-1.067089931 0 0.9115309024)
(-1.060452498 0 0.9294087838)
(-1.123974991 0 1.155532607)
(-0.416632992 0 0.002848244924)
(0.154531207 0 -0.8107568688)
(0.7996864839 0 -1.432337049)
(0.7556247517 0 -1.412107139)
(0.8401058434 0 -1.474015602)
(1.082578417 0 -1.634549024)
(1.271291665 0 -1.905807994)
(1.381308589 0 -2.165549441)
(1.488825918 0 -2.190200941)
(1.773878806 0 -2.560817564)
(2.088682745 0 -3.003084726)
(2.049484934 0 -2.877801791)
(2.245644834 0 -3.069588742)
(2.47315449 0 -3.364471491)
(2.349028323 0 -3.146768681)
(2.38739572 0 -3.154858018)
(2.581859115 0 -3.413034558)
(2.373967286 0 -3.110646102)
(2.293846878 0 -2.990160762)
(2.583815552 0 -3.37439949)
(2.098777757 0 -2.723110053)
(1.69538398 0 -2.172795479)
(2.226347595 0 -2.917441894)
(1.019589903 0 -1.232776139)
(0.5424664948 0 -0.4045894248)
(0.6723609217 0 -0.93230644)
(-0.2135476808 0 -0.2490231001)
(-0.2060600474 0 -0.2882460091)
(-0.2364141923 0 -0.3262251352)
(-0.169378985 0 -0.4213640851)
(-0.1446404343 0 -0.5983172074)
(-0.2434146174 0 -0.547928778)
(-0.2206702395 0 -0.7052053489)
(-0.3777780579 0 -0.7993682477)
(-0.4789450303 0 -0.6185706976)
(-0.5311331418 0 -0.6220945423)
(-0.5319737682 0 0.09872311991)
(-0.6288333388 0 -0.2373563498)
(-0.7017456045 0 0.418441072)
(-0.8737941598 0 0.4885634213)
(-0.8059709785 0 0.4214766535)
(-0.9883803629 0 0.5918750199)
(-1.066336641 0 0.7021984452)
(-1.001103484 0 0.5842976172)
(-1.110212356 0 0.7654333769)
(-1.114168599 0 0.7780765192)
(-1.018515554 0 0.6591425892)
(-1.078524966 0 0.7511569199)
(-0.989716748 0 0.6883460172)
(-0.8892051546 0 0.5925675409)
(-0.8511314398 0 0.6369961557)
(-0.7545841851 0 0.5772739322)
(-0.6037786899 0 0.3565565114)
(-0.6290673638 0 0.4792164505)
(0.2560377328 0 -0.1044206564)
(-0.3904038388 0 -0.8834163616)
(0.644990129 0 -0.3098860555)
(0.6985109336 0 -0.2380160083)
(-0.7965642174 0 -0.05847542385)
(0.7245422999 0 0.2722229163)
(0.5156739837 0 0.338223134)
(0.2863531121 0 1.018242231)
(1.153767698 0 1.14373958)
(1.457291956 0 1.447879204)
(0.889298319 0 3.087478721)
(0.9001991631 0 2.22547106)
(-0.6167041308 0 0.6952494795)
(-0.4965010214 0 0.981765909)
(-0.6844346692 0 0.6790599782)
(-0.7149602486 0 0.6953626812)
(-0.6333930866 0 0.6625068245)
(-0.7526174678 0 0.7369047407)
(-0.8169910549 0 0.7778108709)
(-0.7463438851 0 0.7246997361)
(-0.8955983018 0 0.8095253928)
(-0.9704334023 0 0.8318401967)
(-0.9076747304 0 0.7850470924)
(-1.03442448 0 0.8509321443)
(-1.081742641 0 0.8689275531)
(-1.027687689 0 0.8403785206)
(-1.107022294 0 0.8898059785)
(-1.111302845 0 0.9154462505)
(-1.083067139 0 0.9120725233)
(-1.103984437 0 0.9474646713)
(-1.175722436 0 1.166637904)
(-1.290882564 0 1.151301883)
(-0.7085223929 0 0.4956701644)
(1.100989928 0 -1.330237669)
(0.9090735286 0 -1.368062048)
(1.074857925 0 -1.179962505)
(0.9955017297 0 -1.162253367)
(1.170659997 0 -1.612163597)
(1.186394963 0 -1.426281454)
(1.32900182 0 -1.607703173)
(1.503559643 0 -2.054927802)
(1.449776007 0 -1.800918715)
(1.558721515 0 -1.969052966)
(1.886108442 0 -2.549710264)
(1.634894536 0 -2.070370416)
(1.652590957 0 -2.076408298)
(2.044425366 0 -2.683512971)
(1.596789412 0 -1.974577532)
(1.459663431 0 -1.753653638)
(1.877707699 0 -2.406585104)
(1.236552472 0 -1.398576686)
(0.9391269914 0 -0.9070060994)
(1.237758817 0 -1.461216465)
(0.4338407848 0 -0.3184333344)
(-0.5040456344 0 0.08464668339)
(-0.2361293758 0 0.09042119006)
(-0.1601060241 0 -0.1123771359)
(-0.147354815 0 -0.08760492551)
(-0.1956971368 0 -0.18448696)
(-0.1476722172 0 -0.1200985906)
(-0.009134686437 0 -0.2850504817)
(-0.09636807767 0 -0.516361585)
(0.1614892919 0 -0.4317555954)
(0.2715002257 0 -0.4570469618)
(-0.09734641395 0 -0.9832391014)
(0.07186933574 0 -0.2184668921)
(-0.6167700823 0 0.4376550899)
(-0.5631355775 0 0.3405073343)
(-0.835198331 0 0.6558889054)
(-1.02113945 0 0.8148114661)
(-0.9323779755 0 0.6130531161)
(-1.167207315 0 0.9684061094)
(-1.283512258 0 1.099927242)
(-1.149231441 0 0.8668842785)
(-1.356175764 0 1.169212573)
(-1.367650946 0 1.155060949)
(-1.225211046 0 0.9389622584)
(-1.319017547 0 1.08016556)
(-1.219072846 0 0.9851581807)
(-1.101447917 0 0.8241264279)
(-1.075654031 0 0.901458937)
(-0.9336225849 0 0.8446953456)
(-0.8470198501 0 0.7250049218)
(-0.843822439 0 0.7974302915)
(-0.7486916273 0 0.7435399189)
(-0.6625623435 0 0.6068700197)
(-0.6087695002 0 0.6385936382)
(0.0712218702 0 0.1752822136)
(0.6680927463 0 -0.214493667)
(0.66430354 0 0.2326341976)
(0.6220237638 0 0.4491548493)
(0.4892066682 0 0.3412875998)
(0.9311826824 0 0.6549501944)
(1.493985086 0 1.805926362)
(0.6644188164 0 1.345050596)
(0.9136725587 0 2.45819608)
(0.3797282968 0 2.134776203)
(-0.4805688413 0 0.9455513576)
(-0.1953964802 0 1.51611628)
(-0.6806861732 0 1.021481737)
(-0.7615569479 0 0.7815944809)
(-0.8840332305 0 0.9145715695)
(-0.9754351842 0 0.9352936764)
(-0.899283194 0 0.8509990281)
(-1.056387462 0 0.9456030121)
(-1.129057965 0 0.9396887818)
(-1.049608396 0 0.886938446)
(-1.182767242 0 0.9270168053)
(-1.208685167 0 0.9155118075)
(-1.14576524 0 0.8956680552)
(-1.20577011 0 0.9091142734)
(-1.181255478 0 0.9065827215)
(-1.146419121 0 0.9148709578)
(-1.144146011 0 0.9048252718)
(-1.098783641 0 0.9015716235)
(-1.098408183 0 0.9406423268)
(-1.047910119 0 0.8856371262)
(-1.177379817 0 0.8525814689)
(-0.9906718878 0 0.9365342553)
(-1.117434167 0 0.7038091608)
(0.315052183 0 -0.655756129)
(1.071110833 0 -1.175369189)
(0.9886401532 0 -1.141700259)
(1.152815689 0 -1.055222159)
(1.200012895 0 -1.246814113)
(1.19884742 0 -1.107256568)
(1.220453664 0 -1.165941034)
(1.345935223 0 -1.493847715)
(1.21634858 0 -1.190086644)
(1.183046076 0 -1.163015068)
(1.361057814 0 -1.537092713)
(1.11013447 0 -1.070820702)
(0.9897557512 0 -0.9111626227)
(1.173762737 0 -1.236692007)
(0.794446919 0 -0.6734029745)
(0.1264658284 0 -0.2036882862)
(0.7214255648 0 -0.5486793035)
(-0.3541457196 0 0.09281278407)
(-0.3142868698 0 0.1323995474)
(-0.3665422158 0 0.1176746367)
(-0.1616990088 0 0.01928819179)
(-0.0663759283 0 -0.02993692835)
(-0.1055420048 0 -0.03976486654)
(0.007910120718 0 -0.1027324267)
(-0.06526352703 0 -0.1233008767)
(0.0508110293 0 -0.2531846065)
(-0.03647834123 0 -0.2690227607)
(-0.05496151521 0 -0.241410809)
(0.06934704031 0 -0.2292826604)
(-0.4234057715 0 0.3337085096)
(-0.7970602857 0 0.7906131797)
(-0.6669088433 0 0.5709564885)
(-1.169804528 0 1.174870916)
(-1.465803438 0 1.457393289)
(-1.190806503 0 1.102705017)
(-1.673269999 0 1.649170657)
(-1.804554531 0 1.769212161)
(-1.501027367 0 1.410783256)
(-1.861835234 0 1.814566456)
(-1.826141532 0 1.755370639)
(-1.562764092 0 1.432217389)
(-1.688766903 0 1.583945037)
(-1.492521772 0 1.371310449)
(-1.343821045 0 1.168105892)
(-1.285654951 0 1.199432359)
(-1.096894672 0 1.088420592)
(-1.024683973 0 0.9754766549)
(-0.9448347166 0 1.011377832)
(-0.8305801469 0 0.9446128039)
(-0.8026300838 0 0.8655217597)
(-0.7146984683 0 0.8573328859)
(-0.5209484481 0 0.5522891867)
(-0.5128751116 0 0.5867816722)
(-0.2501765661 0 0.2130636682)
(-0.1468064317 0 0.3254079529)
(-0.2096621379 0 0.2042448184)
(-0.17586793 0 0.2589396139)
(0.5929431203 0 0.5917564274)
(1.67221013 0 1.196079349)
(-0.3144001907 0 0.2200803652)
(-0.6722647854 0 0.3700631688)
(-0.08810995721 0 0.6469288601)
(-0.7015438957 0 0.6841551009)
(-0.8112976061 0 0.8985123094)
(-0.8695878248 0 0.8488156307)
(-0.9399768786 0 0.9852202889)
(-1.061134494 0 1.010199759)
(-1.02904362 0 0.9983977206)
(-1.165927476 0 1.001255353)
(-1.242496317 0 0.9747033914)
(-1.191835527 0 0.9732691119)
(-1.282951576 0 0.9435005949)
(-1.287653924 0 0.9157448228)
(-1.25794384 0 0.9232467021)
(-1.261995039 0 0.8928107209)
(-1.212977615 0 0.872033804)
(-1.207330365 0 0.8911060087)
(-1.146492983 0 0.8532150821)
(-1.062988574 0 0.8391112696)
(-1.092663118 0 0.8681704035)
(-0.9564918785 0 0.7689950981)
(-0.8655938947 0 0.4908968475)
(-0.9253295038 0 0.6342704568)
(-0.7246548566 0 0.1993974181)
(-0.540083579 0 -0.08291242775)
(-0.8718153725 0 0.1973375655)
(-0.6680175911 0 -0.2304874497)
(-0.5242706035 0 -0.3442665316)
(0.8030216539 0 -0.9700193446)
(0.3826671446 0 -0.7236109256)
(0.734285716 0 -0.8362708179)
(1.082780362 0 -0.9874487717)
(0.8309251375 0 -0.8270287954)
(0.8119924813 0 -0.7660849065)
(1.031962713 0 -0.932196454)
(0.6975497622 0 -0.6656873908)
(0.3293951772 0 -0.3922060112)
(0.7962141045 0 -0.7029732818)
(-0.317513966 0 0.06784052298)
(-0.2967754592 0 0.09139662743)
(-0.3381882149 0 0.08182146911)
(-0.2862342473 0 0.1013300901)
(-0.2724759907 0 0.1144357613)
(-0.2879337549 0 0.1200418503)
(-0.1505532598 0 0.1779078432)
(-0.1510341022 0 0.1929655532)
(-0.1124523102 0 0.1199097032)
(-0.1322297176 0 0.2115606836)
(-0.0698096483 0 0.2295178241)
(0.003312353756 0 -0.02132991769)
(0.003078399232 0 0.2302236951)
(-0.2672017972 0 0.4510187881)
(-0.1090044975 0 0.1705171326)
(-0.8428963551 0 0.982499433)
(-1.419405736 0 1.51385649)
(-1.04431141 0 1.115914793)
(-1.846827623 0 1.896164753)
(-2.126459204 0 2.136355466)
(-1.801700419 0 1.817490714)
(-2.292937511 0 2.271420787)
(-2.377046461 0 2.332837942)
(-2.124525293 0 2.094724376)
(-2.397932195 0 2.339410494)
(-2.353346937 0 2.284455121)
(-2.120578696 0 2.06508946)
(-2.200743717 0 2.114952115)
(-1.900631885 0 1.798051785)
(-1.682672826 0 1.587673448)
(-1.54078442 0 1.463621459)
(-1.229353708 0 1.243769462)
(-1.158944592 0 1.180050777)
(-0.9907664378 0 1.121201981)
(-0.8211028406 0 1.042925743)
(-0.8236149026 0 1.010634267)
(-0.7113391914 0 0.9715449265)
(-0.6309317116 0 0.8840687578)
(-0.6390363699 0 0.818061205)
(-0.5471973979 0 0.760895859)
(-0.4240878316 0 0.5812564165)
(-0.2167417142 0 0.4435165235)
(-0.4513465627 0 0.5257439423)
(-0.5686264389 0 0.6011076822)
(-0.2710139824 0 0.2707292819)
(-0.7919007076 0 0.3238114158)
(-2.614645254 0 0.6930319891)
(-1.300260098 0 0.5661282947)
(-1.062606551 0 1.084946375)
(-0.9835709334 0 0.9558965108)
(-0.8369819169 0 0.8867037402)
(-1.123755972 0 0.9542812988)
(-1.253261016 0 0.9636283737)
(-1.129933446 0 0.9790546514)
(-1.329493375 0 0.9539875028)
(-1.349965126 0 0.929538733)
(-1.297534853 0 0.9514685121)
(-1.333733639 0 0.9006605593)
(-1.295703747 0 0.8763340793)
(-1.299752919 0 0.8970904198)
(-1.239107977 0 0.8594549429)
(-1.164805419 0 0.8452705883)
(-1.195886921 0 0.8553894678)
(-1.075511744 0 0.8292154413)
(-0.9657565578 0 0.7928858891)
(-1.016495487 0 0.8156917911)
(-0.8423810423 0 0.5634299704)
(-0.7171574466 0 0.185653288)
(-0.8032953237 0 0.3406480904)
(-0.468930539 0 -0.1344476423)
(-0.4972245559 0 -0.3645043314)
(-0.4578072645 0 -0.237120674)
(-0.551452238 0 -0.4863933352)
(-0.5317750902 0 -0.4792108484)
(-0.5795280014 0 -0.4013056084)
(-0.4942279696 0 -0.442468738)
(-0.4451619417 0 -0.3864275027)
(-0.3556381845 0 -0.3588613897)
(-0.3893084374 0 -0.3121493772)
(-0.3383206977 0 -0.2192177317)
(0.2333143407 0 -0.4489013539)
(-0.2951453859 0 -0.09756725025)
(-0.3070790545 0 0.02412988577)
(-0.3083366056 0 0.0420268325)
(-0.3113992644 0 0.05298978144)
(-0.3079672858 0 0.07653547563)
(-0.2944455972 0 0.08285514943)
(-0.2874706403 0 0.1114480476)
(-0.2591302508 0 0.1445146297)
(-0.2646485946 0 0.1230465117)
(-0.06844181862 0 0.3102931226)
(-0.07911323206 0 0.3048447226)
(-0.1199222184 0 0.2336849761)
(-0.09338150521 0 0.3240120069)
(-0.07492014093 0 0.3516086198)
(-0.1449910564 0 0.2892402738)
(-0.2687112933 0 0.5565550936)
(-1.040196594 0 1.265053256)
(-0.6118137621 0 0.7968721262)
(-1.777424792 0 1.917917281)
(-2.25532721 0 2.326044433)
(-1.842840123 0 1.929859905)
(-2.5224803 0 2.54176913)
(-2.65398574 0 2.636142071)
(-2.411742009 0 2.408663639)
(-2.700600995 0 2.655716075)
(-2.691163724 0 2.626191028)
(-2.557724934 0 2.501667766)
(-2.640050242 0 2.559783516)
(-2.550950157 0 2.458135595)
(-2.485772263 0 2.402419652)
(-2.411986214 0 2.303028349)
(-2.172079668 0 2.031584726)
(-2.08374841 0 1.958792399)
(-1.777651566 0 1.616912251)
(-1.346722457 0 1.24514961)
(-1.299474462 0 1.264580782)
(-1.008460999 0 1.03918191)
(-0.7764707725 0 0.9321394852)
(-0.8114734384 0 1.018486717)
(-0.6274991957 0 0.8541584279)
(-0.5267082708 0 0.7650896049)
(-0.5909413756 0 0.8665874087)
(-0.4634189759 0 0.6293572997)
(-0.5346600776 0 0.5365548369)
(-0.4775459653 0 0.5788676221)
(-0.7436409165 0 0.6173392987)
(-0.9451145044 0 0.7417437853)
(-0.8200623286 0 0.5820653939)
(-1.108234442 0 0.8327726866)
(0.908312012 0 0.8744248662)
(-0.6864786305 0 0.7436854348)
(-0.978040143 0 0.9540383508)
(-1.377270783 0 0.9783133605)
(-1.204301132 0 1.407552613)
(-1.445345136 0 0.9941366322)
(-1.45134168 0 0.9883148826)
(-1.391150779 0 0.9772090072)
(-1.420578081 0 0.9540403294)
(-1.366338955 0 0.9048345711)
(-1.373525994 0 0.9186608365)
(-1.303169466 0 0.8589578529)
(-1.234726014 0 0.8328676671)
(-1.273953869 0 0.8562292081)
(-1.156462972 0 0.8354597617)
(-1.068425159 0 0.8505912774)
(-1.123049814 0 0.843452409)
(-0.9737829676 0 0.8495749739)
(-0.863714129 0 0.7437362646)
(-0.9146646971 0 0.7675670197)
(-0.7202428443 0 0.2848715615)
(-0.4470400063 0 -0.1892411934)
(-0.5853961202 0 0.004818829342)
(-0.4790205008 0 -0.4408341213)
(-0.5771820402 0 -0.6052844889)
(-0.5485791469 0 -0.5048175849)
(-0.576883041 0 -0.6242153904)
(-0.566130928 0 -0.6162126333)
(-0.5406062916 0 -0.5524558917)
(-0.5423406926 0 -0.5938777542)
(-0.5067629808 0 -0.5550135857)
(-0.4562585651 0 -0.4731272056)
(-0.4581284322 0 -0.4991612843)
(-0.3943186254 0 -0.4233856972)
(-0.3447889627 0 -0.3250234102)
(-0.3238557883 0 -0.3258413376)
(-0.3115264729 0 -0.1540053921)
(-0.3174032546 0 -0.03934655647)
(-0.3298348391 0 0.01959133871)
(-0.325274256 0 0.1029255249)
(-0.3186332248 0 0.08796892652)
(-0.2846033376 0 0.1609683096)
(-0.2302975467 0 0.2064523394)
(-0.2520310247 0 0.1701646781)
(0.115691905 0 0.3540878956)
(-0.1830268163 0 0.6350792297)
(0.01550074828 0 0.4119353468)
(-1.428193466 0 1.705602848)
(-2.341983135 0 2.484019376)
(-1.637690741 0 1.846717295)
(-2.774655351 0 2.83717231)
(-2.950259889 0 2.963172771)
(-2.639091065 0 2.681147666)
(-3.001227927 0 2.980237041)
(-2.986519197 0 2.940529945)
(-2.847994536 0 2.814797512)
(-2.931502288 0 2.865751581)
(-2.84570373 0 2.763202189)
(-2.786680754 0 2.713164868)
(-2.72862526 0 2.630856578)
(-2.570928679 0 2.457988711)
(-2.577155483 0 2.475522402)
(-2.358457322 0 2.227790111)
(-2.080454567 0 1.920898806)
(-2.162134495 0 2.013008773)
(-1.716720718 0 1.514633608)
(-1.283297941 0 1.083831797)
(-1.346009562 0 1.185926494)
(-0.9004415038 0 0.8030531795)
(-0.623830936 0 0.6609852101)
(-0.7079676563 0 0.8086016114)
(-0.4365871906 0 0.5625101545)
(-0.397990018 0 0.474257101)
(-0.4253226151 0 0.6144915476)
(-0.5749717933 0 0.5022919225)
(-0.8338105661 0 0.6372497236)
(-0.650324981 0 0.5547294906)
(-1.066076269 0 0.7770477323)
(-1.248564502 0 0.8857671015)
(-1.090565741 0 0.8086861771)
(-1.380333512 0 0.961570133)
(-1.469864929 0 1.010654493)
(-1.362136253 0 0.9611216798)
(-1.513401125 0 1.028051231)
(-1.529650265 0 1.028144124)
(-1.486751929 0 1.011254049)
(-1.522370716 0 1.026513679)
(-1.482095753 0 1.012379144)
(-1.475748838 0 1.001608738)
(-1.405385209 0 0.9604086226)
(-1.307273101 0 0.8861472161)
(-1.343143894 0 0.8922949222)
(-1.202594693 0 0.8178389271)
(-1.095138671 0 0.7844868729)
(-1.176724279 0 0.8079536547)
(-0.9874485602 0 0.8152582019)
(-0.8932494602 0 0.8858488281)
(-0.9946789543 0 0.8661995362)
(-0.8180346814 0 0.916220222)
(-0.7430284042 0 0.7636820125)
(-0.8092949661 0 0.7355705868)
(-0.5203283026 0 0.07622178516)
(-0.4191521702 0 -0.4461002114)
(-0.3792751786 0 -0.3571424218)
(-0.5507483612 0 -0.6188688683)
(-0.5800268564 0 -0.6585201449)
(-0.583309688 0 -0.6503445983)
(-0.6102255669 0 -0.6881772932)
(-0.6321049406 0 -0.7126772237)
(-0.5997543761 0 -0.6688859367)
(-0.6404136885 0 -0.7192639662)
(-0.6361669034 0 -0.7101545282)
(-0.5714818312 0 -0.6343653885)
(-0.617309035 0 -0.6850184037)
(-0.5775861611 0 -0.6377408778)
(-0.4805552488 0 -0.5275462665)
(-0.5086538691 0 -0.5586773037)
(-0.4017184856 0 -0.4353805096)
(-0.3132984066 0 -0.3025357641)
(-0.2670862618 0 -0.2401288304)
(-0.166387557 0 0.09407385848)
(-0.320739016 0 0.1143044104)
(0.1288086528 0 0.2880600768)
(-2.245764692 0 2.459501546)
(-1.0409804 0 1.386919497)
(-3.063725695 0 3.175527202)
(-3.271619916 0 3.326411836)
(-2.927669684 0 3.010566183)
(-3.30605878 0 3.320842761)
(-3.273691957 0 3.257457806)
(-3.156418775 0 3.150385867)
(-3.206406118 0 3.164052073)
(-3.114799291 0 3.048690757)
(-3.071833215 0 3.016091129)
(-3.000942739 0 2.91217268)
(-2.860391779 0 2.749917225)
(-2.87003432 0 2.776394645)
(-2.679664773 0 2.549003842)
(-2.434900856 0 2.285234952)
(-2.527620283 0 2.399060377)
(-2.109354027 0 1.938491949)
(-1.737679831 0 1.539756314)
(-1.939723985 0 1.763455618)
(-1.390891444 0 1.160412254)
(-1.077003418 0 0.8365904218)
(-1.177396108 0 0.9516472521)
(-0.7961820017 0 0.6206093906)
(-0.6530930581 0 0.5399524111)
(-0.550901592 0 0.5231762406)
(-0.708643075 0 0.5519123519)
(-0.8814928862 0 0.6360948088)
(-0.589296225 0 0.4787518479)
(-1.085721246 0 0.7580113379)
(-1.270772276 0 0.8762699534)
(-1.060198125 0 0.7530000581)
(-1.413689319 0 0.9689908801)
(-1.511399943 0 1.033834579)
(-1.399069602 0 0.9640051089)
(-1.568306798 0 1.071362745)
(-1.594243404 0 1.087253857)
(-1.545852395 0 1.053677731)
(-1.586458175 0 1.060863829)
(-1.557960035 0 1.028359862)
(-1.554236137 0 1.033453602)
(-1.514740137 0 1.029084589)
(-1.441908455 0 1.045252269)
(-1.473421269 0 1.026276306)
(-1.333265213 0 1.009816904)
(-1.193497137 0 0.9139896553)
(-1.258701731 0 0.8929369664)
(-1.02668308 0 0.8109292515)
(-0.847162811 0 0.753221278)
(-0.985078535 0 0.7668067903)
(-0.6867413617 0 0.7826107309)
(-0.5916253547 0 0.8817467918)
(-0.7566766816 0 0.898495522)
(-0.5641485312 0 0.9598993229)
(-0.5565730339 0 0.8866751662)
(-0.6584029876 0 0.825920322)
(-0.4287164036 0 0.3571998047)
(-0.4363650281 0 -0.4177327915)
(-0.4537492219 0 -0.4652781842)
(-0.4839148216 0 -0.5716903534)
(-0.5397275644 0 -0.6221979451)
(-0.5671187446 0 -0.6492506634)
(-0.6069465872 0 -0.6963153653)
(-0.670104941 0 -0.7672940654)
(-0.6569563099 0 -0.7465942361)
(-0.7120615066 0 -0.8106359407)
(-0.7396232707 0 -0.8355793151)
(-0.6935032369 0 -0.7783628592)
(-0.7554646039 0 -0.8471642511)
(-0.7561757651 0 -0.8421276614)
(-0.6721391699 0 -0.7449887999)
(-0.735091073 0 -0.8132433708)
(-0.6777150384 0 -0.744292537)
(-0.5357242797 0 -0.5870159712)
(-0.548997299 0 -0.5953411797)
(0.1921895566 0 0.06610716707)
(0.09727174724 0 0.09823923743)
(0.2315479018 0 0.5777849833)
(-3.470063777 0 3.625229614)
(-3.01342982 0 3.191865934)
(-3.580495095 0 3.6673963)
(-3.538357031 0 3.577968229)
(-3.444198346 0 3.489194918)
(-3.459550983 0 3.457769023)
(-3.359551331 0 3.318565892)
(-3.3350614 0 3.310229454)
(-3.239484872 0 3.159928854)
(-3.095915647 0 2.978798882)
(-3.123616881 0 3.040070356)
(-2.921641605 0 2.770079972)
(-2.70023541 0 2.521281141)
(-2.810626592 0 2.673049567)
(-2.399994518 0 2.205666923)
(-1.998682185 0 1.800121176)
(-2.269820258 0 2.094466646)
(-1.562714387 0 1.357835831)
(-1.235201978 0 1.016555151)
(-1.482891416 0 1.265846579)
(-1.069334769 0 0.8389636093)
(-1.010333713 0 0.7740816591)
(-1.025891666 0 0.7787302305)
(-1.003542202 0 0.7625677195)
(-1.038820548 0 0.7823578122)
(-0.9278085175 0 0.6721744269)
(-1.118956581 0 0.8323762148)
(-1.235900846 0 0.9056955671)
(-1.133219653 0 0.7907544633)
(-1.366001931 0 0.9842026724)
(-1.483039887 0 1.052107461)
(-1.408981625 0 0.9768361161)
(-1.57134465 0 1.101804068)
(-1.625910085 0 1.132532293)
(-1.579783228 0 1.089005503)
(-1.647396951 0 1.140972199)
(-1.638800131 0 1.128611219)
(-1.622187696 0 1.11153875)
(-1.593624658 0 1.06155236)
(-1.501920598 0 1.000492315)
(-1.541356886 0 1.015841637)
(-1.381774372 0 1.011366872)
(-1.254837826 0 1.085999428)
(-1.374601935 0 1.067911314)
(-1.137213731 0 1.09302245)
(-0.9989503738 0 0.9549094959)
(-1.106901884 0 0.9409578176)
(-0.8001916387 0 0.7695637281)
(-0.5809414157 0 0.6604668846)
(-0.6997729567 0 0.7260161552)
(-0.4253466981 0 0.6406476967)
(-0.354850356 0 0.6589545737)
(-0.4392703391 0 0.8037762421)
(-0.3349720183 0 0.6913664375)
(-0.337134496 0 0.7261313319)
(-0.4432367255 0 0.8805052179)
(-0.3038969556 0 0.6466560479)
(-0.3197448089 0 0.07290343312)
(-0.3903856388 0 -0.2112091783)
(-0.3702726593 0 -0.3953041095)
(-0.4269094326 0 -0.4889267197)
(-0.4933842606 0 -0.5703814842)
(-0.516756678 0 -0.5937759028)
(-0.6435327045 0 -0.7448536169)
(-0.6675217438 0 -0.7696682738)
(-0.7279002663 0 -0.8423098399)
(-0.7886749402 0 -0.9059211316)
(-0.7720981088 0 -0.8791017148)
(-0.8378608684 0 -0.9553435158)
(-0.8756300409 0 -0.9900902929)
(-0.824830293 0 -0.9245655188)
(-0.9008358203 0 -1.008941322)
(-0.9100130862 0 -1.008009995)
(-0.8067934882 0 -0.888777488)
(-0.8904448248 0 -0.9706115758)
(-0.5614157468 0 0.1963209267)
(-0.2431526762 0 -0.04468879081)
(-3.685440189 0 3.787895476)
(-3.572213929 0 3.575249977)
(-3.580399303 0 3.612849982)
(-3.443661398 0 3.35204766)
(-3.281215211 0 3.106279854)
(-3.347723107 0 3.2679784)
(-3.071893927 0 2.829698327)
(-2.806641493 0 2.518722686)
(-3.011238914 0 2.831514104)
(-2.479771997 0 2.1751051)
(-2.067002766 0 1.788255284)
(-2.48149672 0 2.247882961)
(-1.590432689 0 1.380934373)
(-1.250594246 0 1.099402019)
(-1.611970651 0 1.412791904)
(-1.130637094 0 0.9969748095)
(-1.109819777 0 0.978366209)
(-1.101239234 0 0.9139546064)
(-1.109197436 0 0.9796707122)
(-1.111226406 0 0.9832186136)
(-1.042748763 0 0.8571150762)
(-1.126313769 0 0.9901996158)
(-1.174625792 0 1.00837291)
(-1.101822269 0 0.8939390504)
(-1.267125728 0 1.043055181)
(-1.390279543 0 1.089729953)
(-1.308600254 0 1.000800415)
(-1.514362591 0 1.136835666)
(-1.61423395 0 1.173932084)
(-1.546984558 0 1.11580927)
(-1.678041528 0 1.195123175)
(-1.7036047 0 1.198502639)
(-1.666449304 0 1.16874556)
(-1.69329349 0 1.181521278)
(-1.646604192 0 1.144110238)
(-1.647314274 0 1.139748479)
(-1.557622544 0 1.058713681)
(-1.343496614 0 0.9693443751)
(-1.435653787 0 0.9863461782)
(-1.069311765 0 0.9479443042)
(-0.8798324069 0 0.9944456807)
(-1.076972902 0 1.076206016)
(-0.8022873846 0 0.9982430676)
(-0.748692022 0 0.8471597009)
(-0.8772466724 0 0.9328926877)
(-0.6458005783 0 0.5982830201)
(-0.522634329 0 0.4215258932)
(-0.5098486608 0 0.5502087669)
(-0.4442408349 0 0.3386542306)
(-0.4060242774 0 0.2826323735)
(-0.3177485766 0 0.4887647806)
(-0.3735965288 0 0.2392097755)
(-0.3271863309 0 0.2122672021)
(-0.2936840484 0 0.320506354)
(-0.2603031246 0 0.1920595886)
(-0.2374877609 0 0.2332714359)
(-0.2129816862 0 0.1797006906)
(-0.2924879531 0 0.3453539551)
(-0.255168945 0 0.07706223987)
(-0.3413622915 0 -0.3754713525)
(-0.2876661416 0 -0.3582929702)
(-0.4858618646 0 -0.5140347613)
(-0.5882879649 0 -0.6742224057)
(-0.6418311988 0 -0.7540159963)
(-0.7535142533 0 -0.8809779186)
(-0.7856095039 0 -0.9107575047)
(-0.8463274176 0 -0.986566103)
(-0.9201619172 0 -1.066705835)
(-0.9076016732 0 -1.037824709)
(-0.9763710128 0 -1.122039902)
(-1.018654363 0 -1.155543247)
(-0.9797924774 0 -1.095032615)
(-2.801742317 0 1.449515669)
(-2.222640309 0 1.3063619)
(-3.071788231 0 2.656564593)
(-1.795934215 0 1.189441227)
(-1.498059362 0 1.097589743)
(-2.308540074 0 1.876266945)
(-1.258260991 0 1.017835285)
(-1.105970801 0 1.030266032)
(-1.453327597 0 1.220271926)
(-1.14985499 0 1.137569452)
(-1.233283638 0 1.216493815)
(-1.147589199 0 1.072695287)
(-1.283175354 0 1.2545908)
(-1.299674643 0 1.26612916)
(-1.193162811 0 1.117526963)
(-1.294527953 0 1.26043807)
(-1.28595081 0 1.244860549)
(-1.195756786 0 1.117629118)
(-1.300835138 0 1.228861164)
(-1.36255685 0 1.222804558)
(-1.26271118 0 1.120001786)
(-1.468389085 0 1.230832486)
(-1.588065792 0 1.247448749)
(-1.484405296 0 1.173194648)
(-1.688769796 0 1.262883847)
(-1.752530295 0 1.268913321)
(-1.684071509 0 1.225815613)
(-1.774719287 0 1.260186045)
(-1.756366325 0 1.233235806)
(-1.7348492 0 1.22064742)
(-1.699271315 0 1.185547428)
(-1.602800519 0 1.116620788)
(-1.633443284 0 1.138150367)
(-1.460925051 0 1.011017539)
(-1.166853746 0 0.8465453664)
(-1.243202449 0 0.9295867215)
(-0.8570279679 0 0.684656785)
(-0.6930275344 0 0.5573579516)
(-0.7440954709 0 0.8101582858)
(-0.6105496077 0 0.4109830964)
(-0.5505146734 0 0.2677799681)
(-0.6233830714 0 0.6344377768)
(-0.5185594036 0 0.2001206911)
(-0.507498632 0 0.1976591347)
(-0.5052831145 0 0.2884891934)
(-0.493450768 0 0.2237192968)
(-0.477596792 0 0.2562978617)
(-0.4468011485 0 0.236447442)
(-0.4667065381 0 0.2864995038)
(-0.4600838115 0 0.3170766683)
(-0.3860172644 0 0.262695622)
(-0.4578299368 0 0.3531898835)
(-0.4422960766 0 0.4010689302)
(-0.321393331 0 0.3204988637)
(-0.3945810764 0 0.4863388221)
(-0.3863437825 0 0.7371796452)
(-0.4091848224 0 0.608240306)
(-0.4104890227 0 0.9208382544)
(-0.3607602313 0 0.8353557925)
(-0.3293176526 0 -0.265136704)
(-0.2950473776 0 0.6574582701)
(-0.2257377724 0 0.5265715102)
(-0.661549201 0 -0.7755439467)
(-0.1954325353 0 0.4581363634)
(-0.09804817442 0 0.550247506)
(-0.9083926554 0 -1.069978934)
(-1.43318198 0 1.193697883)
(-1.372986354 0 1.185008484)
(-1.74334485 0 1.225927679)
(-1.30576175 0 1.144807586)
(-1.175826844 0 1.107241627)
(-1.305347365 0 1.08830034)
(-0.9718830603 0 1.086169353)
(-1.223713444 0 1.366812988)
(-1.112679665 0 1.165006335)
(-1.424271957 0 1.488005258)
(-1.501593143 0 1.526758827)
(-1.367877015 0 1.381372664)
(-1.519898279 0 1.534124567)
(-1.505724731 0 1.522726429)
(-1.407116857 0 1.402693987)
(-1.478782392 0 1.495659856)
(-1.467130703 0 1.455978322)
(-1.376677008 0 1.358734704)
(-1.506289015 0 1.413186804)
(-1.602094049 0 1.38073202)
(-1.474796502 0 1.311407297)
(-1.716538568 0 1.363142173)
(-1.807818201 0 1.353559553)
(-1.698016889 0 1.308495708)
(-1.857587631 0 1.342084659)
(-1.863882603 0 1.320386968)
(-1.814567402 0 1.300880513)
(-1.828512091 0 1.281773211)
(-1.751610538 0 1.22050493)
(-1.763683503 0 1.234008168)
(-1.631362995 0 1.13203958)
(-1.464310999 0 1.013169498)
(-1.548625767 0 1.075534161)
(-1.237738278 0 0.8485889398)
(-0.9469527125 0 0.5781995365)
(-1.108205535 0 0.7264667788)
(-0.721285864 0 0.2914210957)
(-0.589035316 0 0.1894129295)
(-0.6883463676 0 0.3194295804)
(-0.5174403065 0 0.1619182687)
(-0.4864936249 0 0.1565248665)
(-0.5218547776 0 0.1797038297)
(-0.4949853588 0 0.1657615262)
(-0.5115750396 0 0.192284468)
(-0.5046500171 0 0.1936859552)
(-0.5229396265 0 0.2378895385)
(-0.5324446712 0 0.2911283781)
(-0.5041683433 0 0.2739162249)
(-0.5439817908 0 0.3442682019)
(-0.5564705555 0 0.3965990075)
(-0.5161196841 0 0.3596988169)
(-0.5686672859 0 0.4488702302)
(-0.5714214258 0 0.4618755175)
(-0.5183755503 0 0.4507280025)
(-0.43567571 0 0.4446550282)
(0.7700494992 0 -0.6605653678)
(-0.2836940912 0 0.6021387435)
(1.380026038 0 0.7727214603)
(1.631927692 0 1.550418005)
(0.3283113939 0 1.598298455)
(1.704960105 0 2.020601945)
(1.695280767 0 2.283542064)
(0.1452497943 0 1.569456543)
(1.625560954 0 2.400200672)
(1.4355774 0 2.326976042)
(0.1125619625 0 1.400226415)
(-0.2221238001 0 -0.1793535304)
(-0.6295721412 0 1.559567209)
(-1.078685984 0 1.187975435)
(-0.6063913671 0 1.520144037)
(-1.542739686 0 1.695898329)
(-1.387764162 0 1.558592223)
(-1.698261312 0 1.745464885)
(-1.728829865 0 1.758842772)
(-1.620697108 0 1.649637605)
(-1.713793585 0 1.749597478)
(-1.674662677 0 1.720842238)
(-1.593824003 0 1.627773602)
(-1.643056011 0 1.665194334)
(-1.671905462 0 1.581192871)
(-1.561750395 0 1.532846879)
(-1.779425231 0 1.497938048)
(-1.893574111 0 1.446445182)
(-1.744888393 0 1.426111783)
(-1.962045745 0 1.419544762)
(-1.981300091 0 1.398218575)
(-1.906449717 0 1.38240734)
(-1.960364027 0 1.369313955)
(-1.901146352 0 1.322387959)
(-1.894186442 0 1.327368573)
(-1.798240156 0 1.247598247)
(-1.644082719 0 1.136567083)
(-1.714234023 0 1.189689931)
(-1.435171936 0 0.9859336629)
(-1.17766404 0 0.8017600685)
(-1.342707118 0 0.9240151798)
(-0.8847397803 0 0.5713031836)
(-0.6436879486 0 0.2627610258)
(-0.7817593135 0 0.408274447)
(-0.5406042704 0 0.09690752691)
(-0.4813072386 0 0.1175917164)
(-0.5263166924 0 0.1390199845)
(-0.4646910392 0 0.1275183393)
(-0.4633683778 0 0.1461356287)
(-0.4703617834 0 0.1510477786)
(-0.4952769063 0 0.150144971)
(-0.5331129973 0 0.1831458448)
(-0.5232545478 0 0.1904906996)
(-0.5599820299 0 0.2492754659)
(-0.5799787984 0 0.3237562322)
(-0.5588789759 0 0.3080269688)
(-0.5980979782 0 0.3934126861)
(-0.6148944664 0 0.4559906858)
(-0.5885605194 0 0.4280381004)
(-0.6278820997 0 0.5088859349)
(-0.6342355443 0 0.549046935)
(-0.6100570035 0 0.5232624692)
(-0.6278705717 0 0.5939824573)
(-0.5888690702 0 0.6075532086)
(-0.4561132755 0 0.4940670685)
(0.5219939968 0 0.9404145588)
(1.250674864 0 1.305504825)
(1.100145078 0 1.181816461)
(1.591403044 0 1.625287383)
(1.640488821 0 1.851713428)
(1.963962688 0 2.141719797)
(-1.978158652 0 1.972298477)
(-1.948357445 0 1.968903337)
(-1.835335685 0 1.863398484)
(-1.897273479 0 1.934278093)
(-1.826754279 0 1.872248304)
(-1.752177805 0 1.803178752)
(-1.859939622 0 1.698650643)
(-1.992372119 0 1.532950018)
(-1.815042288 0 1.584636294)
(-2.084558529 0 1.469744282)
(-2.105787247 0 1.453011175)
(-2.0226443 0 1.450033123)
(-2.087560541 0 1.437998186)
(-2.041099358 0 1.409604425)
(-2.025327603 0 1.406136345)
(-1.964090017 0 1.35992621)
(-1.834575817 0 1.270465321)
(-1.882538294 0 1.304883275)
(-1.631550738 0 1.124801176)
(-1.353703443 0 0.921030783)
(-1.529782386 0 1.05203595)
(-1.037179429 0 0.6861966896)
(-0.7576546246 0 0.4787235823)
(-0.9727909426 0 0.6466188925)
(-0.5790483914 0 0.3147348753)
(-0.4925026784 0 0.1377379182)
(-0.5506035061 0 0.1705908958)
(-0.44408316 0 0.07579704531)
(-0.4276341912 0 0.1024282435)
(-0.4525478332 0 0.1080036158)
(-0.4471195772 0 0.1167873837)
(-0.4772432592 0 0.1254133823)
(-0.4658222165 0 0.1366826645)
(-0.4967147101 0 0.1080912963)
(-0.516783634 0 0.1523702715)
(-0.5320233355 0 0.1682064895)
(-0.5423271184 0 0.2481736372)
(-0.5703818068 0 0.3379121469)
(-0.5851328607 0 0.3350714942)
(-0.6016343945 0 0.4156980969)
(-0.633936223 0 0.4846575657)
(-0.631447568 0 0.4768768981)
(-0.655203161 0 0.5386142506)
(-0.6656261642 0 0.5801053405)
(-0.6532034627 0 0.5706057247)
(-0.6623077871 0 0.611880643)
(-0.6641916989 0 0.6351459805)
(-0.6427672202 0 0.5980952556)
(-0.5780082458 0 0.2491191686)
(-0.5666296973 0 0.05588108129)
(-1.885441694 0 1.916180873)
(-2.203937309 0 1.475149088)
(-2.196686166 0 1.477101197)
(-2.137739423 0 1.477205152)
(-2.189441542 0 1.482316728)
(-2.154483213 0 1.478823344)
(-2.143198853 0 1.464085795)
(-2.100091542 0 1.452353783)
(-2.012309095 0 1.396791811)
(-2.035746716 0 1.407996262)
(-1.869546925 0 1.299888605)
(-1.570404698 0 1.079101983)
(-1.743746433 0 1.206275286)
(-1.160846789 0 0.7701376189)
(-0.7969696753 0 0.4925750436)
(-1.099347584 0 0.7279531626)
(-0.5878637951 0 0.334194456)
(-0.5063057588 0 0.2794309334)
(-0.5906021451 0 0.3450828998)
(-0.4798818561 0 0.2588477223)
(-0.4463434287 0 0.1761359942)
(-0.459307359 0 0.1468295635)
(-0.3887694851 0 0.1039003904)
(-0.386593634 0 0.1093260418)
(-0.4048636321 0 0.1028128248)
(-0.4383690623 0 0.1253458048)
(-0.4891357063 0 0.1289122422)
(-0.4886204416 0 0.1220573719)
(-0.4920308425 0 0.116314543)
(-0.4863595737 0 0.1371452566)
(-0.4983035581 0 0.1426827794)
(-0.5090551672 0 0.2323265208)
(-0.5356479855 0 0.3167368694)
(-0.5500581519 0 0.3310272887)
(-0.5698346633 0 0.3903727407)
(-0.6168769742 0 0.4645330068)
(-0.6263835047 0 0.4784483886)
(-0.6462309603 0 0.5192311846)
(-0.6697377306 0 0.566260782)
(-0.670391531 0 0.577150203)
(-2.043799209 0 1.428285468)
(-1.842156473 0 1.288421459)
(-1.962052958 0 1.366304975)
(-1.4648337 0 1.023009471)
(-0.726420014 0 0.4059926139)
(-1.224300083 0 0.8124696558)
(-0.5582825106 0 0.2921249908)
(-0.5080752442 0 0.2688022763)
(-0.5769199492 0 0.3184224628)
(-0.4840575976 0 0.2616718318)
(-0.4717579646 0 0.2610255348)
(-0.4784350366 0 0.2624300951)
(-0.4662755234 0 0.2697495951)
(-0.4568336432 0 0.2328800926)
(-0.4485283417 0 0.2086610613)
(-0.3883027327 0 0.1457205083)
(-0.3697863279 0 0.1234487991)
(-0.3750316466 0 0.1178118315)
(-0.4236380871 0 0.141565892)
(-0.4651132487 0 0.1491438634)
(-0.4794004683 0 0.1398720278)
(-0.4803124522 0 0.1473888331)
(-0.4779294999 0 0.1386460891)
(-0.4808176912 0 0.1361380954)
)
;
boundaryField
{
dominio_ascii
{
type zeroGradient;
}
wallFilmFaces_top
{
type fixedValue;
value uniform (0 0 0);
}
region0_to_wallFilmRegion_wallFilmFaces
{
type slip;
}
}
// ************************************************************************* //
|
[
"fabio.canesin@gmail.com"
] |
fabio.canesin@gmail.com
|
|
beb6da4add3097dc882426b463032a49239e39c2
|
ceed8ee18ab314b40b3e5b170dceb9adedc39b1e
|
/android/external/pdfium/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
|
1eae578b9756fca877ba0ca0b063cd2e838add1e
|
[
"BSD-3-Clause"
] |
permissive
|
BPI-SINOVOIP/BPI-H3-New-Android7
|
c9906db06010ed6b86df53afb6e25f506ad3917c
|
111cb59a0770d080de7b30eb8b6398a545497080
|
refs/heads/master
| 2023-02-28T20:15:21.191551
| 2018-10-08T06:51:44
| 2018-10-08T06:51:44
| 132,708,249
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 10,120
|
cpp
|
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "pageint.h"
#include "core/include/fpdfapi/fpdf_page.h"
namespace {
const int kSingleCoordinatePair = 1;
const int kTensorCoordinatePairs = 16;
const int kCoonsCoordinatePairs = 12;
const int kSingleColorPerPatch = 1;
const int kQuadColorsPerPatch = 4;
ShadingType ToShadingType(int type) {
return (type > static_cast<int>(kInvalidShading) &&
type < static_cast<int>(kMaxShading))
? static_cast<ShadingType>(type)
: kInvalidShading;
}
} // namespace
CPDF_Pattern::CPDF_Pattern(PatternType type,
CPDF_Document* pDoc,
CPDF_Object* pObj,
const CFX_Matrix* pParentMatrix)
: m_PatternType(type),
m_pDocument(pDoc),
m_pPatternObj(pObj),
m_bForceClear(FALSE) {
if (pParentMatrix)
m_ParentMatrix = *pParentMatrix;
}
CPDF_Pattern::~CPDF_Pattern() {}
CPDF_TilingPattern::CPDF_TilingPattern(CPDF_Document* pDoc,
CPDF_Object* pPatternObj,
const CFX_Matrix* parentMatrix)
: CPDF_Pattern(TILING, pDoc, pPatternObj, parentMatrix) {
CPDF_Dictionary* pDict = m_pPatternObj->GetDict();
m_Pattern2Form = pDict->GetMatrix("Matrix");
m_bColored = pDict->GetInteger("PaintType") == 1;
if (parentMatrix) {
m_Pattern2Form.Concat(*parentMatrix);
}
m_pForm = NULL;
}
CPDF_TilingPattern::~CPDF_TilingPattern() {
delete m_pForm;
m_pForm = NULL;
}
FX_BOOL CPDF_TilingPattern::Load() {
if (m_pForm)
return TRUE;
CPDF_Dictionary* pDict = m_pPatternObj->GetDict();
if (!pDict)
return FALSE;
m_bColored = pDict->GetInteger("PaintType") == 1;
m_XStep = (FX_FLOAT)FXSYS_fabs(pDict->GetNumber("XStep"));
m_YStep = (FX_FLOAT)FXSYS_fabs(pDict->GetNumber("YStep"));
CPDF_Stream* pStream = m_pPatternObj->AsStream();
if (!pStream)
return FALSE;
m_pForm = new CPDF_Form(m_pDocument, NULL, pStream);
m_pForm->ParseContent(NULL, &m_ParentMatrix, NULL, NULL);
m_BBox = pDict->GetRect("BBox");
return TRUE;
}
CPDF_ShadingPattern::CPDF_ShadingPattern(CPDF_Document* pDoc,
CPDF_Object* pPatternObj,
FX_BOOL bShading,
const CFX_Matrix* parentMatrix)
: CPDF_Pattern(SHADING,
pDoc,
bShading ? nullptr : pPatternObj,
parentMatrix),
m_ShadingType(kInvalidShading),
m_bShadingObj(bShading),
m_pShadingObj(pPatternObj),
m_pCS(nullptr),
m_pCountedCS(nullptr),
m_nFuncs(0) {
if (!bShading) {
CPDF_Dictionary* pDict = m_pPatternObj->GetDict();
m_Pattern2Form = pDict->GetMatrix("Matrix");
m_pShadingObj = pDict->GetElementValue("Shading");
if (parentMatrix)
m_Pattern2Form.Concat(*parentMatrix);
}
for (int i = 0; i < FX_ArraySize(m_pFunctions); ++i)
m_pFunctions[i] = nullptr;
}
CPDF_ShadingPattern::~CPDF_ShadingPattern() {
for (int i = 0; i < m_nFuncs; ++i)
delete m_pFunctions[i];
CPDF_ColorSpace* pCS = m_pCountedCS ? m_pCountedCS->get() : NULL;
if (pCS && m_pDocument)
m_pDocument->GetPageData()->ReleaseColorSpace(pCS->GetArray());
}
FX_BOOL CPDF_ShadingPattern::Load() {
if (m_ShadingType != kInvalidShading)
return TRUE;
CPDF_Dictionary* pShadingDict =
m_pShadingObj ? m_pShadingObj->GetDict() : NULL;
if (!pShadingDict) {
return FALSE;
}
if (m_nFuncs) {
for (int i = 0; i < m_nFuncs; i++)
delete m_pFunctions[i];
m_nFuncs = 0;
}
CPDF_Object* pFunc = pShadingDict->GetElementValue("Function");
if (pFunc) {
if (CPDF_Array* pArray = pFunc->AsArray()) {
m_nFuncs = std::min<int>(pArray->GetCount(), 4);
for (int i = 0; i < m_nFuncs; i++) {
m_pFunctions[i] = CPDF_Function::Load(pArray->GetElementValue(i));
}
} else {
m_pFunctions[0] = CPDF_Function::Load(pFunc);
m_nFuncs = 1;
}
}
CPDF_Object* pCSObj = pShadingDict->GetElementValue("ColorSpace");
if (!pCSObj) {
return FALSE;
}
CPDF_DocPageData* pDocPageData = m_pDocument->GetPageData();
m_pCS = pDocPageData->GetColorSpace(pCSObj, NULL);
if (m_pCS) {
m_pCountedCS = pDocPageData->FindColorSpacePtr(m_pCS->GetArray());
}
m_ShadingType = ToShadingType(pShadingDict->GetInteger("ShadingType"));
// We expect to have a stream if our shading type is a mesh.
if (IsMeshShading() && !ToStream(m_pShadingObj))
return FALSE;
return TRUE;
}
FX_BOOL CPDF_MeshStream::Load(CPDF_Stream* pShadingStream,
CPDF_Function** pFuncs,
int nFuncs,
CPDF_ColorSpace* pCS) {
m_Stream.LoadAllData(pShadingStream);
m_BitStream.Init(m_Stream.GetData(), m_Stream.GetSize());
m_pFuncs = pFuncs;
m_nFuncs = nFuncs;
m_pCS = pCS;
CPDF_Dictionary* pDict = pShadingStream->GetDict();
m_nCoordBits = pDict->GetInteger("BitsPerCoordinate");
m_nCompBits = pDict->GetInteger("BitsPerComponent");
m_nFlagBits = pDict->GetInteger("BitsPerFlag");
if (!m_nCoordBits || !m_nCompBits) {
return FALSE;
}
int nComps = pCS->CountComponents();
if (nComps > 8) {
return FALSE;
}
m_nComps = nFuncs ? 1 : nComps;
if (((int)m_nComps < 0) || m_nComps > 8) {
return FALSE;
}
m_CoordMax = m_nCoordBits == 32 ? -1 : (1 << m_nCoordBits) - 1;
m_CompMax = (1 << m_nCompBits) - 1;
CPDF_Array* pDecode = pDict->GetArray("Decode");
if (!pDecode || pDecode->GetCount() != 4 + m_nComps * 2) {
return FALSE;
}
m_xmin = pDecode->GetNumber(0);
m_xmax = pDecode->GetNumber(1);
m_ymin = pDecode->GetNumber(2);
m_ymax = pDecode->GetNumber(3);
for (FX_DWORD i = 0; i < m_nComps; i++) {
m_ColorMin[i] = pDecode->GetNumber(i * 2 + 4);
m_ColorMax[i] = pDecode->GetNumber(i * 2 + 5);
}
return TRUE;
}
FX_DWORD CPDF_MeshStream::GetFlag() {
return m_BitStream.GetBits(m_nFlagBits) & 0x03;
}
void CPDF_MeshStream::GetCoords(FX_FLOAT& x, FX_FLOAT& y) {
if (m_nCoordBits == 32) {
x = m_xmin + (FX_FLOAT)(m_BitStream.GetBits(m_nCoordBits) *
(m_xmax - m_xmin) / (double)m_CoordMax);
y = m_ymin + (FX_FLOAT)(m_BitStream.GetBits(m_nCoordBits) *
(m_ymax - m_ymin) / (double)m_CoordMax);
} else {
x = m_xmin +
m_BitStream.GetBits(m_nCoordBits) * (m_xmax - m_xmin) / m_CoordMax;
y = m_ymin +
m_BitStream.GetBits(m_nCoordBits) * (m_ymax - m_ymin) / m_CoordMax;
}
}
void CPDF_MeshStream::GetColor(FX_FLOAT& r, FX_FLOAT& g, FX_FLOAT& b) {
FX_DWORD i;
FX_FLOAT color_value[8];
for (i = 0; i < m_nComps; i++) {
color_value[i] = m_ColorMin[i] +
m_BitStream.GetBits(m_nCompBits) *
(m_ColorMax[i] - m_ColorMin[i]) / m_CompMax;
}
if (m_nFuncs) {
static const int kMaxResults = 8;
FX_FLOAT result[kMaxResults];
int nResults;
FXSYS_memset(result, 0, sizeof(result));
for (FX_DWORD i = 0; i < m_nFuncs; i++) {
if (m_pFuncs[i] && m_pFuncs[i]->CountOutputs() <= kMaxResults) {
m_pFuncs[i]->Call(color_value, 1, result, nResults);
}
}
m_pCS->GetRGB(result, r, g, b);
} else {
m_pCS->GetRGB(color_value, r, g, b);
}
}
FX_DWORD CPDF_MeshStream::GetVertex(CPDF_MeshVertex& vertex,
CFX_Matrix* pObject2Bitmap) {
FX_DWORD flag = GetFlag();
GetCoords(vertex.x, vertex.y);
pObject2Bitmap->Transform(vertex.x, vertex.y);
GetColor(vertex.r, vertex.g, vertex.b);
m_BitStream.ByteAlign();
return flag;
}
FX_BOOL CPDF_MeshStream::GetVertexRow(CPDF_MeshVertex* vertex,
int count,
CFX_Matrix* pObject2Bitmap) {
for (int i = 0; i < count; i++) {
if (m_BitStream.IsEOF()) {
return FALSE;
}
GetCoords(vertex[i].x, vertex[i].y);
pObject2Bitmap->Transform(vertex[i].x, vertex[i].y);
GetColor(vertex[i].r, vertex[i].g, vertex[i].b);
m_BitStream.ByteAlign();
}
return TRUE;
}
CFX_FloatRect GetShadingBBox(CPDF_Stream* pStream,
ShadingType type,
const CFX_Matrix* pMatrix,
CPDF_Function** pFuncs,
int nFuncs,
CPDF_ColorSpace* pCS) {
if (!pStream || !pStream->IsStream() || !pFuncs || !pCS)
return CFX_FloatRect(0, 0, 0, 0);
CPDF_MeshStream stream;
if (!stream.Load(pStream, pFuncs, nFuncs, pCS))
return CFX_FloatRect(0, 0, 0, 0);
CFX_FloatRect rect;
FX_BOOL bStarted = FALSE;
FX_BOOL bGouraud = type == kFreeFormGouraudTriangleMeshShading ||
type == kLatticeFormGouraudTriangleMeshShading;
int point_count = kSingleCoordinatePair;
if (type == kTensorProductPatchMeshShading)
point_count = kTensorCoordinatePairs;
else if (type == kCoonsPatchMeshShading)
point_count = kCoonsCoordinatePairs;
int color_count = kSingleColorPerPatch;
if (type == kCoonsPatchMeshShading || type == kTensorProductPatchMeshShading)
color_count = kQuadColorsPerPatch;
while (!stream.m_BitStream.IsEOF()) {
FX_DWORD flag = 0;
if (type != kLatticeFormGouraudTriangleMeshShading)
flag = stream.GetFlag();
if (!bGouraud && flag) {
point_count -= 4;
color_count -= 2;
}
for (int i = 0; i < point_count; i++) {
FX_FLOAT x, y;
stream.GetCoords(x, y);
if (bStarted) {
rect.UpdateRect(x, y);
} else {
rect.InitRect(x, y);
bStarted = TRUE;
}
}
stream.m_BitStream.SkipBits(stream.m_nComps * stream.m_nCompBits *
color_count);
if (bGouraud)
stream.m_BitStream.ByteAlign();
}
rect.Transform(pMatrix);
return rect;
}
|
[
"Justin"
] |
Justin
|
d2af5dd5cc4a3cc9c26152b5e879de0ba86e106e
|
8f1601062c4a5452f2bdd0f75f3d12a79b98ba62
|
/examples/tankwars/Terrain.cpp
|
15ae0280d1a8d6ef494aa43ef8bcb26bb69a81c9
|
[] |
no_license
|
chadaustin/isugamedev
|
200a54f55a2581cd2c62c94eb96b9e238abcf3dd
|
d3008ada042d2dd98c6e05711773badf6f1fd85c
|
refs/heads/master
| 2016-08-11T17:59:38.504631
| 2005-01-25T23:17:11
| 2005-01-25T23:17:11
| 36,483,500
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,262
|
cpp
|
// Terrain.cpp: implementation of the Terrain class.
//
//////////////////////////////////////////////////////////////////////
#include "Terrain.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Terrain::Terrain()
{
xsize = 5.0f;
zsize = 5.0f;
xPos = 0.0;
zPos = 0.0;
extents = 28.0;
}
Terrain::~Terrain()
{
}
void Terrain::draw()
{
glTranslatef(-3.0f, 0.0f, -11.0f*zsize);
glRotatef(-45.0f, 0.0f, 1.0f, 0.0f);
glBindTexture(GL_TEXTURE_2D, terrainTex[0]);
for (int x = 0; x<13; x++)
{
glTranslatef(xsize, 0.0f, 0.0f);
for (int z = 0; z<13; z++)
{
glTranslatef(0.0f, 0.0f, zsize);
glBegin(GL_QUADS); // coordinates for the square
//glNormal3f(0.0f, 1.0f, 0.0f);
glTexCoord2f(0.02f, 0.02f); glVertex3f(0.0f, 0.0f, 0.0f);
glTexCoord2f(.98f, 0.02f); glVertex3f(xsize, 0.0f, 0.0f);
glTexCoord2f(0.98f, 0.98f); glVertex3f(xsize, 0.0f, zsize);
glTexCoord2f(0.02f, 0.98f); glVertex3f(0.0f, 0.0f, zsize);
glEnd();
}
glTranslatef(0.0f, 0.0f, -13*zsize);
}
return;
}
void Terrain::setx(GLfloat x)
{
xsize = x;
return;
}
void Terrain::setz(GLfloat z)
{
zsize = z;
return;
}
|
[
"viperscum@84b32ba4-53c3-423c-be69-77cca6335494"
] |
viperscum@84b32ba4-53c3-423c-be69-77cca6335494
|
22d8b87956241d56037d92ffcab2d5ae4967988e
|
90e63bf53e58790a6bc8862bba1fd492747823a8
|
/boost_variant/src/main.cc
|
cc97d593ffe392c2a76be8b42a134d585cbf4411
|
[] |
no_license
|
gucchisk/cpp-samples
|
48dc64b18a41b05e13b7f758eb658c789811269a
|
d9d421edc9c97e26c0651f85969a41a050bae85a
|
refs/heads/main
| 2021-11-24T07:45:39.299140
| 2021-11-23T01:52:32
| 2021-11-23T01:52:32
| 231,418,593
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 105
|
cc
|
#include <hello.h>
#include <iostream>
int main() {
std::cout << hello(3) << std::endl;
return 0;
}
|
[
"gucchi_sk@yahoo.co.jp"
] |
gucchi_sk@yahoo.co.jp
|
e9c31d9be30d6288b01828bc04cf3ea78ec43a28
|
131223db8fe76478768e174d85828cf10862c0dc
|
/interfaces/innerkits/native_cpp/include/bluetooth_gatt_client.h
|
9815b0af1f39da5d97dee69e9684e3db501af632
|
[
"Apache-2.0"
] |
permissive
|
openharmony-gitee-mirror/communication_bluetooth
|
e3c834043d8d96be666401ba6baa3f55e1f1f3d2
|
444309918cd00a65a10b8d798a0f5a78f8cf13be
|
refs/heads/master
| 2023-08-24T10:05:20.001354
| 2021-10-19T01:45:18
| 2021-10-19T01:45:18
| 400,050,270
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,531
|
h
|
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* 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.
*/
/**
* @addtogroup Bluetooth
* @{
*
* @brief Defines a bluetooth system that provides basic bluetooth connection and profile functions,
* including A2DP, AVRCP, BLE, GATT, HFP, MAP, PBAP, and SPP, etc.
*
* @since 6
*
*/
/**
* @file bluetooth_gatt_client.h
*
* @brief Bluetooth gatt client interface.
*
* @since 6
*
*/
#ifndef BLUETOOTH_GATT_CLIENT_H
#define BLUETOOTH_GATT_CLIENT_H
#include "bluetooth_def.h"
#include "bluetooth_gatt_service.h"
#include "bluetooth_remote_device.h"
namespace OHOS {
namespace Bluetooth {
/**
* @brief Class for GattClientCallback functions.
*
* @since 6
*
*/
class GattClientCallback {
public:
/**
* @brief The function to OnConnectionStateChanged.
*
* @param connectionState callback of gattClientCallback.
* @param ret ret of GattClientCallback.
* @since 6
*
*/
virtual void OnConnectionStateChanged(int connectionState, int ret) = 0;
/**
* @brief The function to OnCharacteristicChanged.
*
* @param characteristic Characteristic object to changed.
* @since 6
*
*/
virtual void OnCharacteristicChanged(const GattCharacteristic &characteristic)
{}
/**
* @brief The function to OnCharacteristicReadResult.
*
* @param characteristic Characteristic object.
* @param ret ret of GattClientCallback.
* @since 6
*
*/
virtual void OnCharacteristicReadResult(const GattCharacteristic &characteristic, int ret)
{}
/**
* @brief The function to OnCharacteristicWriteResult.
*
* @param characteristic Characteristic object.
* @param ret ret of GattClientCallback.
* @since 6
*
*/
virtual void OnCharacteristicWriteResult(const GattCharacteristic &characteristic, int ret)
{}
/**
* @brief The function to OnDescriptorReadResult.
*
* @param descriptor descriptor object.
* @param ret ret of GattClientCallback.
* @since 6
*
*/
virtual void OnDescriptorReadResult(const GattDescriptor &descriptor, int ret)
{}
/**
* @brief The function to OnDescriptorWriteResult.
*
* @param descriptor descriptor object.
* @param ret ret of GattClientCallback.
* @since 6
*
*/
virtual void OnDescriptorWriteResult(const GattDescriptor &descriptor, int ret)
{}
/**
* @brief The function to OnMtuUpdate.
*
* @param mtu mtu to update.
* @param ret ret of GattClientCallback.
* @since 6
*
*/
virtual void OnMtuUpdate(int mtu, int ret)
{}
/**
* @brief The function to OnServicesDiscovered.
*
* @param status Status object.
* @since 6
*
*/
virtual void OnServicesDiscovered(int status)
{}
/**
* @brief The function to OnConnectionParameterChanged.
*
* @param interval interval object.
* @param latency latency object.
* @param timeout timeout object.
* @param status status object.
* @since 6
*
*/
virtual void OnConnectionParameterChanged(int interval, int latency, int timeout, int status)
{}
/**
* @brief The function to OnSetNotifyCharacteristic.
*
* @param status status object.
* @since 6
*
*/
virtual void OnSetNotifyCharacteristic(int status)
{}
/**
* @brief A destructor of GattClientCallback.
*
* @since 6
*
*/
virtual ~GattClientCallback()
{}
};
/**
* @brief Class for GattClient functions.
*
* @since 6
*
*/
class BLUETOOTH_API GattClient {
public:
/**
* @brief The function to Connect.
*
* @param callback callback of gattClientCallback.
* @param isAutoConnect isAutoConnect of GattClient.
* @param transport transport of GattClient.
* @return int api accept status.
* @since 6
*
*/
int Connect(GattClientCallback &callback, bool isAutoConnect, int transport);
/**
* @brief The function to request connection priority.
*
* @param connPriority connPriority of GattClient.
* @return int api accept status.
* @since 6
*
*/
int RequestConnectionPriority(int connPriority);
/**
* @brief The function to disconnect.
*
* @return int api accept status.
* @since 6
*
*/
int Disconnect();
/**
* @brief The function to discover services.
*
* @return int api accept status.
* @since 6
*
*/
int DiscoverServices();
/**
* @brief The function to get service.
*
* @param uuid uuid of GattClient.
* @return service.
* @since 6
*
*/
std::optional<std::reference_wrapper<GattService>> GetService(const UUID &uuid);
/**
* @brief The function to get service.
*
* @return list of services.
* @since 6
*
*/
std::vector<GattService> &GetService();
/**
* @brief The function to read characteristic.
*
* @param characteristic Characteristic object.
* @return int read characteristic.
* @since 6
*
*/
int ReadCharacteristic(GattCharacteristic &characteristic);
/**
* @brief The function to read descriptor.
*
* @param descriptor descriptor object.
* @return int read descriptor.
* @since 6
*
*/
int ReadDescriptor(GattDescriptor &descriptor);
/**
* @brief The function to RequestBleMtuSize.
*
* @param mtu mtu of GattClient.
* @return int request ble mtu size.
* @since 6
*
*/
int RequestBleMtuSize(int mtu);
/**
* @brief The function to SetNotifyCharacteristic.
*
* @param characteristic characteristic object.
* @param enable enable of GattClient.
* @return result of #GATT_STATUS.
* @since 6
*
*/
int SetNotifyCharacteristic(GattCharacteristic &characteristic, bool enable);
/**
* @brief The function to write characteristic.
*
* @param characteristic characteristic object.
* @return int write characteristic.
* @since 6
*
*/
int WriteCharacteristic(GattCharacteristic &characteristic);
/**
* @brief The function to write characteristic.
*
* @param descriptor descriptor object.
* @return int write descriptor.
* @since 6
*
*/
int WriteDescriptor(GattDescriptor &descriptor);
/**
* @brief A constructor of GattClient.
*
* @param device Remote device object.
* @since 6
*
*/
explicit GattClient(const BluetoothRemoteDevice &device);
/**
* @brief A destructor of GattClient.
*
* @since 6
*
*/
~GattClient();
BLUETOOTH_DISALLOW_COPY_AND_ASSIGN(GattClient);
private:
BLUETOOTH_DECLARE_IMPL();
};
} // namespace Bluetooth
} // namespace OHOS
#endif // BLUETOOTH_GATT_CLIENT_H
|
[
"guohong.cheng@huawei.com"
] |
guohong.cheng@huawei.com
|
d9173d3c1a26832112b88a1f5128e721285bef4c
|
5898d3bd9e4cb58043b40fa58961c7452182db08
|
/part1/ch03/3-3-2-move-container/src/Vector.h
|
b271a71c67ca72f7884de8018083db1716883577
|
[] |
no_license
|
sasaki-seiji/ProgrammingLanguageCPP4th
|
1e802f3cb15fc2ac51fa70403b95f52878223cff
|
2f686b385b485c27068328c6533926903b253687
|
refs/heads/master
| 2020-04-04T06:10:32.942026
| 2017-08-10T11:35:08
| 2017-08-10T11:35:08
| 53,772,682
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 524
|
h
|
/*
* Vector.h
*
* Created on: 2016/03/21
* Author: sasaki
*/
#ifndef VECTOR_H_
#define VECTOR_H_
class Vector {
private:
double* elem;
int sz;
public:
Vector(int s);
~Vector();
Vector(const Vector& a);
Vector& operator=(const Vector& a);
// move
Vector(Vector&& a);
Vector& operator=(Vector&& a);
double& operator[](int i);
const double& operator[](int i) const;
int size() const;
};
class Vector_size_mismatch { };
Vector operator+(const Vector& a, const Vector& b);
#endif /* VECTOR_H_ */
|
[
"sasaki-seiji@msj.biglobe.ne.jp"
] |
sasaki-seiji@msj.biglobe.ne.jp
|
02d129d1778a189284744ab22ba49c5f2a542ebc
|
ea5a58975f7d756191b05cd7ee8e414978961311
|
/Code/OpenCVDisplay.cpp
|
2fbd2c5654f1c5508510fc848f9e7c1af89c0d16
|
[] |
no_license
|
Lukemtesta/Cpp-openCV---Rendering-a-Scene-Described-by-a-File
|
af71b6ef353179338417d7192fe2f850da506dff
|
1765c51edf5f2dba6c71c3c705da692c5e92e56a
|
refs/heads/master
| 2016-09-10T01:12:35.862205
| 2014-07-30T15:40:50
| 2014-07-30T15:40:50
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,779
|
cpp
|
/*
* OpenCVDisplay.cpp
*
* Created on: 5 Nov 2013
* Author: nicolas
*/
#include "OpenCVDisplay.h"
namespace SceneDisplay {
OpenCVDisplay::OpenCVDisplay(int w, int h) throw(DisplayException) : image(NULL) {
initializeImage(w,h);
}
OpenCVDisplay::~OpenCVDisplay() {
releaseImage();
}
void OpenCVDisplay::resize( int width, int height ) throw(DisplayException) {
BaseDisplay::resize(width,height);
initializeImage(width,height);
}
void OpenCVDisplay::releaseImage() {
if(image)
cvReleaseImage(&image);
cvDestroyWindow("image");
}
void OpenCVDisplay::initializeImage( int width, int height ) throw(DisplayException) {
releaseImage();
image = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3);
if(!image)
throw DisplayException("Could not create an OpenCV image!");
}
void OpenCVDisplay::show() throw(DisplayException) {
if( image ){
cvShowImage("image", image);
cvWaitKey();
} else
throw DisplayException("Display front-end (OpenCV) needs to be initialised to a correct size before calling the show() method!");
}
void OpenCVDisplay::drawCircle( int x, int y, int radius, int red, int green, int blue ) throw(DisplayException) {
if( image )
cvCircle(image, cvPoint(x,y), radius, CV_RGB(red, green, blue), CV_FILLED);
else
throw DisplayException("Display front-end (OpenCV) needs to be initialised to a correct size before drawing!");
}
void OpenCVDisplay::drawRectangle( int x, int y, int width, int height, int red, int green, int blue ) throw(DisplayException) {
if( image )
cvRectangle(image, cvPoint(x,y), cvPoint(x+width,y+height), CV_RGB(red, green, blue), CV_FILLED);
else
throw DisplayException("Display front-end (OpenCV) needs to be initialised to a correct size before drawing!");
}
} // SceneDisplay
|
[
"luke_Testa@hotmail.com"
] |
luke_Testa@hotmail.com
|
61ddca7a35eb4d5f6011adc3c76230a8151e71b0
|
79d737df7d3ecb6404911ffc561942be740d2f4c
|
/rstudio-server/JAGS-v4.3.0/include/JAGS/graph/ArrayStochasticNode.h
|
62bddeb58ac93c636bc89d6d46fac2c7931e23ed
|
[] |
no_license
|
omicsclass/biodocker
|
18d3d611488173fb9dd65c6fee6c5a10cf47d170
|
6e77a4aaef187a26ff3ba628d12905093fe320ec
|
refs/heads/master
| 2023-01-05T13:26:41.664515
| 2022-12-26T10:16:53
| 2022-12-26T10:16:53
| 248,117,776
| 0
| 4
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,429
|
h
|
#ifndef ARRAY_STOCHASTIC_NODE_H_
#define ARRAY_STOCHASTIC_NODE_H_
#include <graph/StochasticNode.h>
namespace jags {
class ArrayDist;
/**
* @short Array-valued Node defined by the BUGS-language operator ~
*/
class ArrayStochasticNode : public StochasticNode {
ArrayDist const * const _dist;
std::vector<std::vector<unsigned int> > _dims;
void sp(double *lower, double *upper, unsigned int length,
unsigned int chain) const;
public:
/**
* Construct
* distribution and an array of parent nodes, considered as
* parameters to the distribution.
*/
ArrayStochasticNode(ArrayDist const *dist, unsigned int nchain,
std::vector<Node const *> const ¶meters,
Node const *lower, Node const *upper,
double const *data=0, unsigned int length=0);
double logDensity(unsigned int chain, PDFType type) const;
void randomSample(RNG *rng, unsigned int chain);
void truncatedSample(RNG *rng, unsigned int chain,
double const *lower, double const *upper);
void deterministicSample(unsigned int chain);
bool checkParentValues(unsigned int chain) const;
//StochasticNode *clone(std::vector<Node const *> const &parents,
//Node const *lower, Node const *upper) const;
unsigned int df() const;
double KL(unsigned int chain1, unsigned int chain2, RNG *rng, unsigned int nrep) const;
};
} /* namespace jags */
#endif /* ARRAY_STOCHASTIC_NODE_H_ */
|
[
"huang2002003@qq.com"
] |
huang2002003@qq.com
|
fefcca12e1cf28969df4f50b1f456d87a8599269
|
5f49c9c5b1edcd4384bd08fea7bf571dced7c0b5
|
/menu/c_aiming.cpp
|
4cd82bc28230eca94f6d5657d579316235020a71
|
[] |
no_license
|
MyNameIsKodak/rifk7-fix
|
ca8608cff5ba5f898aab7c8937409c01613449e2
|
faf59344ba58bd052e35bb823c880f25845624a4
|
refs/heads/master
| 2023-07-27T01:56:25.631846
| 2021-09-02T18:46:25
| 2021-09-02T18:46:25
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,010
|
cpp
|
#include "c_aiming.h"
#include "../security/string_obfuscation.h"
#include "framework/c_group_box.h"
#include "framework/c_checkbox.h"
#include "../utils/c_config.h"
#include "framework/c_float_select.h"
#include "framework/c_hotkey_select.h"
c_aiming::c_aiming(const c_vector2d size) : c_flow_layout(size, c_vector2d(12, 12))
{
add_child(std::make_shared<c_group_box>(__("General"), std::initializer_list<std::shared_ptr<c_drawable>> {
make_child(c_checkbox, __("Enabled"), config.rage.enabled),
make_child(c_checkbox, __("LBY Breaker"), config.rage.experimental_aa),
make_child(c_hotkey_select, __("Flip Desync Side"), config.rage.experimental_aa_flip),
make_child(c_hotkey_select, __("Slowwalk"), config.rage.slow_walk)
}, c_vector2d(275, 75)));
add_child(std::make_shared<c_group_box>(__("Auto Snipers"), std::initializer_list<std::shared_ptr<c_drawable>> {
make_child(c_float_select, __("Hitchance"), config.rage.auto_snipe.hitchance),
make_child(c_float_select, __("Minimum Damage"), config.rage.auto_snipe.min_dmg),
make_child(c_float_select, __("Head Scale"), config.rage.auto_snipe.head_scale, 100.f),
make_child(c_float_select, __("Body Scale"), config.rage.auto_snipe.body_scale, 100.f)
}, c_vector2d(275, 75)));
add_child(std::make_shared<c_group_box>(__("Scout"), std::initializer_list<std::shared_ptr<c_drawable>> {
make_child(c_float_select, __("Hitchance"), config.rage.scout.hitchance),
make_child(c_float_select, __("Minimum Damage"), config.rage.scout.min_dmg),
make_child(c_float_select, __("Head Scale"), config.rage.scout.head_scale, 100.f),
make_child(c_float_select, __("Body Scale"), config.rage.scout.body_scale, 100.f)
}, c_vector2d(275, 75)));
add_child(std::make_shared<c_group_box>(__("AWP"), std::initializer_list<std::shared_ptr<c_drawable>> {
make_child(c_float_select, __("Hitchance"), config.rage.awp.hitchance),
make_child(c_float_select, __("Minimum Damage"), config.rage.awp.min_dmg),
make_child(c_float_select, __("Head Scale"), config.rage.awp.head_scale, 100.f),
make_child(c_float_select, __("Body Scale"), config.rage.awp.body_scale, 100.f)
}, c_vector2d(275, 75)));
add_child(std::make_shared<c_group_box>(__("Light Pistols"), std::initializer_list<std::shared_ptr<c_drawable>> {
make_child(c_float_select, __("Hitchance"), config.rage.pistol.hitchance),
make_child(c_float_select, __("Minimum Damage"), config.rage.pistol.min_dmg),
make_child(c_float_select, __("Head Scale"), config.rage.pistol.head_scale, 100.f),
make_child(c_float_select, __("Body Scale"), config.rage.pistol.body_scale, 100.f)
}, c_vector2d(275, 75)));
add_child(std::make_shared<c_group_box>(__("Heavy Pistols"), std::initializer_list<std::shared_ptr<c_drawable>> {
make_child(c_float_select, __("Hitchance"), config.rage.heavy.hitchance),
make_child(c_float_select, __("Minimum Damage"), config.rage.heavy.min_dmg),
make_child(c_float_select, __("Head Scale"), config.rage.heavy.head_scale, 100.f),
make_child(c_float_select, __("Body Scale"), config.rage.heavy.body_scale, 100.f)
}, c_vector2d(275, 75)));
add_child(std::make_shared<c_group_box>(__("Rifles"), std::initializer_list<std::shared_ptr<c_drawable>> {
make_child(c_float_select, __("Hitchance"), config.rage.rifle.hitchance),
make_child(c_float_select, __("Minimum Damage"), config.rage.rifle.min_dmg),
make_child(c_float_select, __("Head Scale"), config.rage.rifle.head_scale, 100.f),
make_child(c_float_select, __("Body Scale"), config.rage.rifle.body_scale, 100.f)
}, c_vector2d(275, 75)));
add_child(std::make_shared<c_group_box>(__("Other Guns"), std::initializer_list<std::shared_ptr<c_drawable>> {
make_child(c_float_select, __("Hitchance"), config.rage.misc.hitchance),
make_child(c_float_select, __("Minimum Damage"), config.rage.misc.min_dmg),
make_child(c_float_select, __("Head Scale"), config.rage.misc.head_scale, 100.f),
make_child(c_float_select, __("Body Scale"), config.rage.misc.body_scale, 100.f)
}, c_vector2d(275, 75)));
}
|
[
"somageller06@gmail.com"
] |
somageller06@gmail.com
|
3157042ebeb7a519c118aee3513d882610a76905
|
68a76eb015df500ab93125396cf351dff1e53356
|
/Codeforces/104A.cpp
|
48eb987444850c23294ce20b678a8092e00a21f2
|
[] |
no_license
|
deepakn97/Competitive-Programming
|
a84999c0755a187a55a0bb2f384c216e7ee4bf15
|
aae415839c6d823daba5cd830935bf3350de895e
|
refs/heads/master
| 2021-10-04T08:00:59.867642
| 2018-12-03T15:37:32
| 2018-12-03T15:37:32
| 81,475,571
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 703
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
#define Pi 3.141592653589793
#define eps 1e-9
#define SQR(n) (n*n)
#define MEM(a,val) memset(a,val,sizeof(a))
#define vi vector<int>
#define vii vector< vector<int> >
#define pb push_back
#define F first
#define S second
#define SS stringstream
#define all(v) (v.begin(),v.end())
#define FOR(i,a,b) for(int i = a; i <= b; i++)
#define FORD(i,a,b) for(int i = b; i >= a; i--)
#define ll long long
#define ul unsigned long
int main()
{
int n;
cin >> n;
n -= 10;
int ans = 0;
if(n == 1)
ans = 4;
else if(n >= 2 && n <= 9)
ans = 4;
else if(n == 10)
ans = 4*4 - 1;
else if(n == 11)
ans = 4;
else
ans = 0;
cout << ans << endl;
return 0;
}
|
[
"deepak54354@gmail.com"
] |
deepak54354@gmail.com
|
172549e7a617ae45837d4360c65058e72ca4b184
|
bbd0ed6a7ecc2a038132b105b87de4c6a1e357e8
|
/examples/occa/simple/simple.cpp
|
a639d4c588009a90150d57b7640034c00714580b
|
[
"MIT"
] |
permissive
|
holke/CUDA_ATPESC15
|
08aa7a76c54afb7d06ca6dc8e947c1737d3d5548
|
a0b74b5da4f6bcb8cd0e868420fe216b7449ac33
|
refs/heads/master
| 2020-04-05T23:46:20.221140
| 2015-08-05T20:25:46
| 2015-08-05T20:25:46
| 40,311,884
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,069
|
cpp
|
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include "occa.hpp"
int main(int argc, char **argv){
/* hard code platform and device number */
int plat = 0;
int dev = 0;
occa::device device;
device.setup("OpenCL", plat, dev);
// build jacobi kernel from source file
const char *functionName = "";
// build Jacobi kernel
occa::kernel simple = device.buildKernelFromSource("simple.occa", "simple");
// size of array
int N = 256;
// set thread array for Jacobi iteration
int T = 32;
int dims = 1;
occa::dim inner(T);
occa::dim outer((N+T-1)/T);
simple.setWorkingDims(dims, inner, outer);
size_t sz = N*sizeof(float);
// allocate array on HOST
float *h_x = (float*) malloc(sz);
for(int n=0;n<N;++n)
h_x[n] = 123;
// allocate array on DEVICE (copy from HOST)
occa::memory c_x = device.malloc(sz, h_x);
// queue kernel
simple(N, c_x);
// copy result to HOST
c_x.copyTo(h_x);
/* print out results */
for(int n=0;n<N;++n)
printf("h_x[%d] = %g\n", n, h_x[n]);
exit(0);
}
|
[
"timwar@Tims-MacBook-Pro.local"
] |
timwar@Tims-MacBook-Pro.local
|
423785318712c30856912e714b2169fdc8c11280
|
f83ef53177180ebfeb5a3e230aa29794f52ce1fc
|
/ACE/ACE_wrappers/TAO/TAO_IDL/be/be_visitor_null_return_value.cpp
|
6965580b91d971590acd159c3f2b937df60f495e
|
[
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"LicenseRef-scancode-proprietary-license",
"LicenseRef-scancode-sun-iiop"
] |
permissive
|
msrLi/portingSources
|
fe7528b3fd08eed4a1b41383c88ee5c09c2294ef
|
57d561730ab27804a3172b33807f2bffbc9e52ae
|
refs/heads/master
| 2021-07-08T01:22:29.604203
| 2019-07-10T13:07:06
| 2019-07-10T13:07:06
| 196,183,165
| 2
| 1
|
Apache-2.0
| 2020-10-13T14:30:53
| 2019-07-10T10:16:46
| null |
UTF-8
|
C++
| false
| false
| 4,398
|
cpp
|
#include "be_visitor_null_return_value.h"
#include "be_visitor_context.h"
#include "be_helper.h"
#include "be_array.h"
#include "be_component.h"
#include "be_enum.h"
#include "be_eventtype.h"
#include "be_home.h"
#include "be_predefined_type.h"
#include "be_sequence.h"
#include "be_string.h"
#include "be_structure.h"
#include "be_typedef.h"
#include "be_union.h"
#include "be_valuebox.h"
#include "be_valuetype.h"
be_visitor_null_return_value::be_visitor_null_return_value (
be_visitor_context *ctx)
: be_visitor_decl (ctx),
os_ (*ctx->stream ())
{
}
be_visitor_null_return_value::~be_visitor_null_return_value (void)
{
}
int
be_visitor_null_return_value::visit_array (be_array *node)
{
os_ << "static_cast< ::" << node->full_name ()
<< "_slice *> (0)";
return 0;
}
int
be_visitor_null_return_value::visit_component (be_component *node)
{
return this->visit_interface (node);
}
int
be_visitor_null_return_value::visit_enum (be_enum *node)
{
os_ << "static_cast< ::" << node->full_name () << "> (0UL)";
return 0;
}
int
be_visitor_null_return_value::visit_eventtype (be_eventtype *node)
{
return this->visit_valuetype (node);
}
int
be_visitor_null_return_value::visit_home (be_home *node)
{
return this->visit_interface (node);
}
int
be_visitor_null_return_value::visit_interface (be_interface *node)
{
os_ << " ::" << node->full_name () << "::_nil ()";
return 0;
}
int
be_visitor_null_return_value::visit_predefined_type (be_predefined_type *node)
{
switch (node->pt ())
{
case AST_PredefinedType::PT_boolean:
os_ << "false";
break;
case AST_PredefinedType::PT_octet:
case AST_PredefinedType::PT_char:
case AST_PredefinedType::PT_wchar:
case AST_PredefinedType::PT_short:
case AST_PredefinedType::PT_ushort:
case AST_PredefinedType::PT_long:
case AST_PredefinedType::PT_ulong:
case AST_PredefinedType::PT_ulonglong:
case AST_PredefinedType::PT_value:
case AST_PredefinedType::PT_any:
os_ << "0";
break;
case AST_PredefinedType::PT_longlong:
os_ << "ACE_CDR_LONGLONG_INITIALIZER";
break;
case AST_PredefinedType::PT_float:
os_ << "0.0f";
break;
case AST_PredefinedType::PT_double:
os_ << "0.0";
break;
case AST_PredefinedType::PT_longdouble:
os_ << "ACE_CDR_LONG_DOUBLE_INITIALIZER";
break;
case AST_PredefinedType::PT_object:
os_ << " ::CORBA::Object::_nil ()";
break;
case AST_PredefinedType::PT_abstract:
os_ << " ::CORBA::AbstractBase::_nil ()";
break;
case AST_PredefinedType::PT_pseudo:
os_ << " ::CORBA::TypeCode::_nil ()";
break;
default: // PT_void not handled.
break;
}
return 0;
}
int
be_visitor_null_return_value::visit_sequence (be_sequence *node)
{
const char *fname = node->full_name ();
be_typedef *td = this->ctx_->tdef ();
if (td != 0)
{
fname = td->full_name ();
}
os_ << "static_cast< ::" << fname << " *> (0)";
return 0;
}
int
be_visitor_null_return_value::visit_string (be_string *node)
{
if (node->width () == (ssize_t) sizeof (char))
{
os_ << "static_cast<char *> (0)";
}
else
{
os_ << "static_cast< ::CORBA::WChar *> (0)";
}
return 0;
}
int
be_visitor_null_return_value::visit_structure (be_structure *node)
{
if (node->size_type () == AST_Type::FIXED)
{
os_ << " ::" << node->full_name () << " ()";
}
else
{
os_ << "static_cast< ::" << node->full_name ()
<< " *> (0)";
}
return 0;
}
int
be_visitor_null_return_value::visit_typedef (be_typedef *node)
{
this->ctx_->tdef (node);
return node->primitive_base_type ()->accept (this);
}
int
be_visitor_null_return_value::visit_union (be_union *node)
{
if (node->size_type () == AST_Type::FIXED)
{
os_ << " ::" << node->full_name () << " ()";
}
else
{
os_ << "static_cast< ::" << node->full_name ()
<< " *> (0)";
}
return 0;
}
int
be_visitor_null_return_value::visit_valuebox (be_valuebox *node)
{
os_ << "static_cast< ::" << node->full_name ()
<< " *> (0)";
return 0;
}
int
be_visitor_null_return_value::visit_valuetype (be_valuetype *node)
{
os_ << "static_cast< ::" << node->full_name ()
<< " *> (0)";
return 0;
}
|
[
"lihuibin705@163.com"
] |
lihuibin705@163.com
|
411768db6d2a464c6bf54e4e19d359dd147db23a
|
d3893a2ee04e4752cecbc873b369a8fa7113b70d
|
/third_party/skia_m63/src/gpu/effects/GrBlurredEdgeFragmentProcessor.h
|
e27905ca292f0874a0fb7ce2159f7a636fb771b0
|
[
"BSD-3-Clause",
"MIT"
] |
permissive
|
kniefliu/WindowsSamples
|
e849137467acdfe5351e8fdd31945c37203be3c5
|
c841268ef4a0f1c6f89b8e95bf68058ea2548394
|
refs/heads/master
| 2021-01-09T10:25:49.744308
| 2020-08-12T12:37:05
| 2020-08-12T12:37:05
| 242,264,984
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,543
|
h
|
/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/*
* This file was autogenerated from GrBlurredEdgeFragmentProcessor.fp; do not modify.
*/
#ifndef GrBlurredEdgeFragmentProcessor_DEFINED
#define GrBlurredEdgeFragmentProcessor_DEFINED
#include "SkTypes.h"
#if SK_SUPPORT_GPU
#include "GrFragmentProcessor.h"
#include "GrCoordTransform.h"
#include "GrColorSpaceXform.h"
class GrBlurredEdgeFragmentProcessor : public GrFragmentProcessor {
public:
enum Mode { kGaussian_Mode = 0, kSmoothStep_Mode = 1 };
int mode() const { return fMode; }
static std::unique_ptr<GrFragmentProcessor> Make(int mode) {
return std::unique_ptr<GrFragmentProcessor>(new GrBlurredEdgeFragmentProcessor(mode));
}
GrBlurredEdgeFragmentProcessor(const GrBlurredEdgeFragmentProcessor& src);
std::unique_ptr<GrFragmentProcessor> clone() const override;
const char* name() const override { return "BlurredEdgeFragmentProcessor"; }
private:
GrBlurredEdgeFragmentProcessor(int mode)
: INHERITED(kGrBlurredEdgeFragmentProcessor_ClassID, kNone_OptimizationFlags)
, fMode(mode) {}
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
bool onIsEqual(const GrFragmentProcessor&) const override;
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
int fMode;
typedef GrFragmentProcessor INHERITED;
};
#endif
#endif
|
[
"liuxiufeng@qiyi.com"
] |
liuxiufeng@qiyi.com
|
28b809ff9fcf849f4923d0360b4b2f9910052838
|
57c31af7487bfffc1e334a11a2ea7c929264af18
|
/tests_boost/test-encode-decode-interest.cpp
|
e5fc83f8686db2bbfaa63137300d26812165f80d
|
[] |
no_license
|
cawka/packaging-ndn-cpp-dev
|
85a99240109d5fccb81c2b73250135aea3dd496b
|
baed2d2a6fcd365dddae0174185db184e5057638
|
refs/heads/master
| 2021-01-20T01:03:46.083951
| 2014-01-24T03:00:58
| 2014-01-24T03:00:58
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,491
|
cpp
|
/**
* Copyright (C) 2013 Regents of the University of California.
* @author: Jeff Thompson <jefft0@remap.ucla.edu>
* See COPYING for copyright and distribution information.
*/
#include <boost/test/unit_test.hpp>
#include <ndn-cpp-dev/interest.hpp>
using namespace std;
using namespace ndn;
BOOST_AUTO_TEST_SUITE(TestInterest)
const uint8_t Interest1[] = {
0x1, 0x41, // NDN Interest
0x3, 0x14, // Name
0x4, 0x5, // NameComponent
0x6c, 0x6f, 0x63, 0x61, 0x6c,
0x4, 0x3, // NameComponent
0x6e, 0x64, 0x6e,
0x4, 0x6, // NameComponent
0x70, 0x72, 0x65, 0x66, 0x69, 0x78,
0x5, 0x1f, // Selectors
0x09, 0x1, 0x1, // MinSuffix
0x0a, 0x1, 0x1, // MaxSuffix
0x0c, 0x14, // Exclude
0x4, 0x4, // NameComponent
0x61, 0x6c, 0x65, 0x78,
0x4, 0x4, // NameComponent
0x78, 0x78, 0x78, 0x78,
0xf, 0x0, // Any
0x4, 0x4, // NameComponent
0x79, 0x79, 0x79, 0x79,
0x0d, 0x1, // ChildSelector
0x1,
0x6, 0x1, // Nonce
0x1,
0x7, 0x1, // Scope
0x1,
0x8, // InterestLifetime
0x2, 0x3, 0xe8
};
BOOST_AUTO_TEST_CASE (Decode)
{
Block interestBlock(Interest1, sizeof(Interest1));
ndn::Interest i;
BOOST_REQUIRE_NO_THROW(i.wireDecode(interestBlock));
BOOST_REQUIRE_EQUAL(i.getName().toUri(), "/local/ndn/prefix");
BOOST_REQUIRE_EQUAL(i.getScope(), 1);
BOOST_REQUIRE_EQUAL(i.getInterestLifetime(), 1000);
BOOST_REQUIRE_EQUAL(i.getMinSuffixComponents(), 1);
BOOST_REQUIRE_EQUAL(i.getMaxSuffixComponents(), 1);
BOOST_REQUIRE_EQUAL(i.getChildSelector(), 1);
BOOST_REQUIRE_EQUAL(i.getMustBeFresh(), false);
BOOST_REQUIRE_EQUAL(i.getExclude().toUri(), "alex,xxxx,*,yyyy");
BOOST_REQUIRE_EQUAL(i.getNonce(), 1);
}
BOOST_AUTO_TEST_CASE (Encode)
{
ndn::Interest i(ndn::Name("/local/ndn/prefix"));
i.setScope(1);
i.setInterestLifetime(1000);
i.setMinSuffixComponents(1);
i.setMaxSuffixComponents(1);
i.setChildSelector(1);
i.setMustBeFresh(false);
i.getExclude().excludeOne("alex").excludeRange("xxxx", "yyyy");
i.setNonce(1);
const Block &wire = i.wireEncode();
BOOST_REQUIRE_EQUAL_COLLECTIONS(Interest1, Interest1+sizeof(Interest1),
wire.begin(), wire.end());
}
BOOST_AUTO_TEST_SUITE_END()
|
[
"alexander.afanasyev@ucla.edu"
] |
alexander.afanasyev@ucla.edu
|
bfc1436d0073444c1e0a6a34010268bf0c729481
|
e7305bf4b50cedfbecf236a545f109bd825840fa
|
/mesh/MeshLoader.hpp
|
9e098722747dd2797d6a4ee6e7993b13f6898fa2
|
[] |
no_license
|
lucmobz/pacs-project
|
df03257ccf4b745692b1daf30919e7db188ef573
|
e54500b96dcf0e3d44aa07fa2970f95a5ac5c4b5
|
refs/heads/main
| 2023-04-30T11:49:55.701913
| 2021-05-21T20:27:13
| 2021-05-21T20:27:13
| 369,647,056
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,662
|
hpp
|
#pragma once
#include <fstream>
#include <memory>
#include <string>
#include <vector>
#include "Mesh.hpp"
#include "MeshConnectivity.hpp"
namespace wave {
/**
\brief A MeshLoader is an abstract loader for loading mesh files.
A pure abstract class that represents an object with access to the internals
of a Mesh. using the make method a concrete loader can be instantiated (such
as MeshLoader Voro), which can then load a Mesh according to the specific
format. Addition of a new concrete loader for a different mesh format just
requires to add the concrete loader to the make method and implement it.
*/
class MeshLoader {
public:
/// \brief virtual Destructor to have inheritance.
virtual ~MeshLoader() = default;
/**
\brief Creates a specific concrete loader according to the format specified.
\param format The string containing the format.
\return Returns a unique pointer to the concrete loader instance.
*/
static auto make(const std::string& format) -> std::unique_ptr<MeshLoader>;
/**
\brief Pure virtual load method.
\param file The string containing the file path.
\param mesh The Mesh to load the file into.
*/
virtual void load(const std::string& file, Mesh& mesh) const = 0;
protected:
/// \brief Skips the given number of lines from the input stream.
static auto skip(std::ifstream& input, int nlines) -> std::ifstream&;
/// \brief Sets the input stream past the target line
static auto skip(std::ifstream& input, const std::string& target_line)
-> std::ifstream&;
/// \brief Access the internal geometrical information in a Mesh (the
/// coordinate vector).
static auto ref_geometry(Mesh& mesh) -> std::vector<double>&;
/**
\brief Access the internal topological connectivity information in a Mesh.
For example to get access to the elements in a mesh set d0 = 3, d1 = 0.
\param mesh The Mesh.
\param d0 The first topological dimension.
\param d1 The second topological dimension.
\return Returns a reference to a MeshConnectivity inside the Mesh.
*/
static auto ref_topology(Mesh& mesh, int d0, int d1) -> MeshConnectivity&;
/// \brief Finalizes the mesh by computing the sizes and last parameters.
static void finalize(Mesh& mesh);
};
//------------------------------------------------------------------------------
inline auto MeshLoader::ref_geometry(Mesh& mesh) -> std::vector<double>& {
return const_cast<std::vector<double>&>(mesh.geometry());
}
inline auto MeshLoader::ref_topology(Mesh& mesh, int d0, int d1)
-> MeshConnectivity& {
return const_cast<MeshConnectivity&>(mesh.topology(d0, d1));
}
} // namespace wave
|
[
"luca.mobz.work@gmail.com"
] |
luca.mobz.work@gmail.com
|
b87b112a4cfc818f65c22ae2d5e69202037f48c9
|
6b0ed1000d6340fe8e0a5b5a0be609bf42ad5a50
|
/133.cpp
|
5559848bc23fecb1c9839795c7933e455ed98214
|
[] |
no_license
|
HarshRaikwar/Leetcode-Submissions
|
5bcdb96b63548cf0bb4522258800ebb7a3ae8b29
|
6b7aeb5def21e6652ad7b299f472e8152bafaab0
|
refs/heads/master
| 2023-07-29T18:50:46.607706
| 2021-09-13T14:35:47
| 2021-09-13T14:35:47
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 886
|
cpp
|
/*
class Node {
public:
int val;
vector<Node*> neighbors;
Node() {
val = 0;
neighbors = vector<Node*>();
}
Node(int _val) {
val = _val;
neighbors = vector<Node*>();
}
Node(int _val, vector<Node*> _neighbors) {
val = _val;
neighbors = _neighbors;
}
};
*/
class Solution {
public:
unordered_map<Node* , Node*> mp;
Node* dfs(Node* node){
if(node == NULL)return NULL;
if(mp.find(node) != mp.end())return mp[node];
Node *root = new Node(node->val);
vector<Node*> ch = node->neighbors;
vector<Node*> v;
mp[node] = root;
for(int i=0 ; i<ch.size() ; i++){
v.push_back(dfs(ch[i]));
}
root->neighbors = v;
return mp[node] = root;
}
Node* cloneGraph(Node* node) {
return dfs(node);
}
};
|
[
"sharmadeeksha325@gmail.com"
] |
sharmadeeksha325@gmail.com
|
e9ca3ba693fe11684c141ce2abc103a90527fd90
|
26f8393e1f47baa89e0c8342a3427a4107778b3e
|
/stepdriver_fw/inc/beeper.h
|
df55b92748797d14d9d5ee7936024ee48b9594d7
|
[] |
no_license
|
roma-jam/stepdriver
|
1351f26c59d1446e0947d05c2a5e2a941cb72620
|
965c89174e45ea14fc8f744b25e54bc8aaf502d3
|
refs/heads/master
| 2020-12-18T22:18:39.723280
| 2016-06-11T10:26:47
| 2016-06-11T10:26:47
| 32,232,665
| 0
| 0
| null | null | null | null |
ISO-8859-5
|
C++
| false
| false
| 984
|
h
|
/*
* beeper.h
*
* Created on: 08 рту. 2015 у.
* Author: RomaJam
*/
#ifndef INC_BEEPER_H_
#define INC_BEEPER_H_
#include "kl_lib_f100.h"
#define BEEPER_DURATION_MS 51
#define BEEPER_DELAY_MS 99
#define BEEPER_GPIO GPIOB
#define BEEPER_PIN 7
#define BEEPER_TIM TIM4
#define BEEPER_CH CCR2
#define BEEPER_ENDPOINT_SEQ 1
#define BEEPER_WIFI_RDY_SEQ 2
#define BEEPER_START_SEQ 3
struct BeeperSequence_t {
// uint8_t Delay;
uint8_t Count; // count to beep
};
class beeper_t {
private:
VirtualTimer Timer;
bool isOn;
BeeperSequence_t Seq;
void BeeperOn() { PinSet(BEEPER_GPIO, BEEPER_PIN); isOn = true; }
void BeeperOff() { PinClear(BEEPER_GPIO, BEEPER_PIN); isOn = false; }
public:
void Init();
void Beep();
void Sequence(uint8_t BeepCnt);
void Timeout();
bool isBeep() { return isOn; }
};
extern beeper_t Beeper;
#endif /* INC_BEEPER_H_ */
|
[
"jam_roma@yahoo.com"
] |
jam_roma@yahoo.com
|
6847e5b54bdd836d61ecb1e1fbbecc1c5bde9dff
|
b01e58e74ba0f989c5beb8f532eec2c11f5439b5
|
/CampIme2017/Day4/wall.cpp
|
c5400debe94fa2d8d7bd8b17b5e67b418e2f7a78
|
[] |
no_license
|
breno-helf/TAPA.EXE
|
54d56e2a2c15e709819c172695200479b1b34729
|
3ac36a3d2401a2d4861fc7a51ce9b1b6a20ab112
|
refs/heads/master
| 2021-01-19T11:18:15.958602
| 2018-08-03T22:25:03
| 2018-08-03T22:25:03
| 82,236,704
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 694
|
cpp
|
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
const int maxn = 1e5 + 10;
int t, n;
int w[2][maxn];
int h[2][maxn];
int main(){
scanf("%d",&t);
while(t--){
scanf("%d",&n);
int hmin = INT_MAX;
int wmin = INT_MAX;
int hmax = INT_MIN;
int wmax = INT_MIN;
FOR(i,1,n){
scanf("%d%d%d%d",&w[0][i],&w[1][i],&h[0][i],&h[1][i]);
hmin = min(hmin,h[0][i]);
hmax = max(hmax,h[1][i]);
wmin = min(wmin,w[0][i]);
wmax = max(wmax,w[1][i]);
}
bool ok = 0;
FOR(i,1,n)
if(h[0][i] <= hmin && hmax <= h[1][i] && w[0][i] <= wmin && wmax <= w[1][i])
ok = true;
if(ok) printf("ANO\n");
else printf("NIE\n");
}
return 0;
}
|
[
"breno.moura@hotmail.com"
] |
breno.moura@hotmail.com
|
d8f219c9efefc72f246451231b204f27c365818f
|
713926478a1f876c0d30744d90f829109cd1bd64
|
/Lol2019/Day_10/F/check.cpp
|
2d9fbbc26b8092f8e2381c690731676a753d2916
|
[] |
no_license
|
Igor-SeVeR/OlympiadProblems
|
f8b191488c11bf92bdfc580bbac660f6ed7bddef
|
7197aa7a6853ff916ee9da090d53580253dabffb
|
refs/heads/master
| 2020-06-10T21:45:20.565411
| 2019-07-21T18:18:55
| 2019-07-21T18:18:55
| 193,752,484
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,237
|
cpp
|
/* Autogenerated code, forces testlib to return exit codes for EJUDGE. */
#define EJUDGE
#include "testlib.h"
#include <sstream>
using namespace std;
string ending(long long x)
{
x %= 100;
if (x / 10 == 1)
return "th";
if (x % 10 == 1)
return "st";
if (x % 10 == 2)
return "nd";
if (x % 10 == 3)
return "rd";
return "th";
}
string ltoa(long long n)
{
char c[32];
sprintf(c, "%I64d", n);
return c;
}
int main(int argc, char * argv[])
{
setName("compare ordered sequences of signed int%d numbers", 8 * sizeof(long long));
registerTestlibCmd(argc, argv);
int n = 0;
string firstElems;
while (!ans.seekEof())
{
n++;
long long j = ans.readLong();
long long p = ouf.readLong();
if (j != p)
quitf(_wa, "%d%s numbers differ - expected: '%I64d', found: '%I64d'", n, ending(n).c_str(), j, p);
else
if (n <= 5)
{
if (firstElems.length() > 0)
firstElems += " ";
firstElems += ltoa(j);
}
}
if (n <= 5)
{
quitf(_ok, "%d number(s): \"%s\"", n, firstElems.c_str());
}
else
quitf(_ok, "%d numbers", n);
}
|
[
"voafanasev@edu.hse.ru"
] |
voafanasev@edu.hse.ru
|
1b046e7067c62110336820345ab58256fbd55967
|
20fb95593cc0c97e53a5e78883408051269db0fc
|
/cpp_modules/sub/sub.cc
|
1288088d3200f01b169cb7eaa949f27a3adde77b
|
[] |
no_license
|
petrenkoVitaliy/ts_cpp
|
a7f26b87eaebba0b7d54fdfa12959ab7d4b609ec
|
b393b0ac10babd630204c1bc54a1187e441df82c
|
refs/heads/master
| 2023-09-04T16:45:48.823416
| 2021-11-22T01:12:51
| 2021-11-22T01:12:51
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 621
|
cc
|
#include <napi.h>
#include "sub.h"
Napi::Value Sub(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
if (info.Length() < 2) {
Napi::TypeError::New(env, "Wrong number of arguments")
.ThrowAsJavaScriptException();
return env.Null();
}
if (!info[0].IsNumber() || !info[1].IsNumber()) {
Napi::TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
return env.Null();
}
double arg0 = info[0].As<Napi::Number>().DoubleValue();
double arg1 = info[1].As<Napi::Number>().DoubleValue();
Napi::Number num = Napi::Number::New(env, arg0 - arg1);
return num;
}
|
[
"vitaliy.ptt@gmail.com"
] |
vitaliy.ptt@gmail.com
|
2c35c53bb41d2281e65dd57d67d29096cb078108
|
674826516f037601155f727833823078435fb015
|
/算法/入门/reverseString/reverseString.cpp
|
7c5709ff09cd37508f87bb081daf411a063d08a6
|
[] |
no_license
|
smy-10/leetcode
|
1fd89f371600e33a64abd5768c57067f1b2b57d3
|
1cd286d224ef4047583d78d1d7c98ef36dc8f993
|
refs/heads/main
| 2023-09-05T18:32:40.511990
| 2021-11-11T06:12:30
| 2021-11-11T06:12:30
| 391,800,624
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,912
|
cpp
|
// reverseString.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
/*
编写一个函数,其作用是将输入的字符串反转过来。输入字符串以字符数组 s 的形式给出。
不要给另外的数组分配额外的空间,你必须原地修改输入数组、使用 O(1) 的额外空间解决这一问题。
示例 1:
输入:s = ["h","e","l","l","o"]
输出:["o","l","l","e","h"]
示例 2:
输入:s = ["H","a","n","n","a","h"]
输出:["h","a","n","n","a","H"]
提示:
1 <= s.length <= 105
s[i] 都是 ASCII 码表中的可打印字符
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/reverse-string
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
*/
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
void reverseString(vector<char>& s)
{
int left = 0;
int right = s.size() - 1;
while (left < right)
{
char temp = s[right];
s[right] = s[left];
s[left] = temp;
left++;
right--;
}
}
};
int main()
{
Solution s;
vector<char> vec{ 'h','e' ,'l' ,'l' ,'o' };
s.reverseString(vec);
std::cout << "Hello World!\n";
}
// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单
// 入门使用技巧:
// 1. 使用解决方案资源管理器窗口添加/管理文件
// 2. 使用团队资源管理器窗口连接到源代码管理
// 3. 使用输出窗口查看生成输出和其他消息
// 4. 使用错误列表窗口查看错误
// 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
// 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件
|
[
"33865665+smy-10@users.noreply.github.com"
] |
33865665+smy-10@users.noreply.github.com
|
caa80c68c7cf5bb388abb3215bce4af3038e2b37
|
f8817ace5321a3ff1b0b5739604111dce658b6e2
|
/MPU6050_complementary/MPU6050_complementary.ino
|
ba59bacb7b04bbd20bce64b329a3fc1c3ea12457
|
[] |
no_license
|
HapCoderWei/MyArduino
|
8c2d326ed864eab2414fdacb13ea15c49b52fbec
|
9704c9bb6f9a59c61ef9d31ea4bca430df4fa1ef
|
refs/heads/master
| 2021-01-10T17:45:34.827262
| 2018-08-15T15:47:04
| 2018-08-15T15:47:04
| 48,595,973
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,047
|
ino
|
#include "Wire.h"
#include "I2Cdev.h"
#include "MPU6050_6Axis_MotionApps20.h"
MPU6050 mpu;
#define LED_PIN 13 // (Arduino is 13, Teensy is 11, Teensy++ is 6)
bool blinkState = false;
// Use the following global variables and access functions to help store the overall
// rotation angle of the sensor
unsigned long last_read_time;
float last_x_angle; // These are the filtered angles
float last_y_angle;
float last_z_angle;
float last_gyro_x_angle; // Store the gyro angles to compare drift
float last_gyro_y_angle;
float last_gyro_z_angle;
void set_last_read_angle_data(unsigned long time, float x, float y, float z, float x_gyro, float y_gyro, float z_gyro) {
last_read_time = time;
last_x_angle = x;
last_y_angle = y;
last_z_angle = z;
last_gyro_x_angle = x_gyro;
last_gyro_y_angle = y_gyro;
last_gyro_z_angle = z_gyro;
}
inline unsigned long get_last_time() {return last_read_time;}
inline float get_last_x_angle() {return last_x_angle;}
inline float get_last_y_angle() {return last_y_angle;}
inline float get_last_z_angle() {return last_z_angle;}
inline float get_last_gyro_x_angle() {return last_gyro_x_angle;}
inline float get_last_gyro_y_angle() {return last_gyro_y_angle;}
inline float get_last_gyro_z_angle() {return last_gyro_z_angle;}
// Use the following global variables
// to calibrate the gyroscope sensor and accelerometer readings
float base_x_gyro = 0;
float base_y_gyro = 0;
float base_z_gyro = 0;
float base_x_accel = 0;
float base_y_accel = 0;
float base_z_accel = 0;
// This global variable tells us how to scale gyroscope data
float GYRO_FACTOR;
// This global varible tells how to scale acclerometer data
float ACCEL_FACTOR;
// Variables to store the values from the sensor readings
int16_t ax, ay, az;
int16_t gx, gy, gz;
unsigned long startLoop = 0;
unsigned long loopTime = 1;
unsigned int freq = 0;
// ================================================================
// === CALIBRATION_ROUTINE ===
// ================================================================
// Simple calibration - just average first few readings to subtract
// from the later data
void calibrate_sensors() {
int num_readings = 10;
// Discard the first reading (don't know if this is needed or
// not, however, it won't hurt.)
mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
// Read and average the raw values
for (int i = 0; i < num_readings; i++) {
mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
base_x_gyro += gx;
base_y_gyro += gy;
base_z_gyro += gz;
base_x_accel += ax;
base_y_accel += ay;
base_y_accel += az;
}
base_x_gyro /= num_readings;
base_y_gyro /= num_readings;
base_z_gyro /= num_readings;
base_x_accel /= num_readings;
base_y_accel /= num_readings;
base_z_accel /= num_readings;
}
void setup() {
// put your setup code here, to run once:
Wire.begin();
Serial.begin(57600);
// Set the full scale range of the gyro
uint8_t FS_SEL = 0;
//mpu.setFullScaleGyroRange(FS_SEL);
// get default full scale value of gyro - may have changed from default
// function call returns values between 0 and 3
uint8_t READ_FS_SEL = mpu.getFullScaleGyroRange();
Serial.print("FS_SEL = ");
Serial.println(READ_FS_SEL);
GYRO_FACTOR = 131.0/(FS_SEL + 1);
// get default full scale value of accelerometer - may not be default value.
// Accelerometer scale factor doesn't reall matter as it divides out
uint8_t READ_AFS_SEL = mpu.getFullScaleAccelRange();
Serial.print("AFS_SEL = ");
Serial.println(READ_AFS_SEL);
pinMode(LED_PIN, OUTPUT);
// get calibration values for sensors
calibrate_sensors();
set_last_read_angle_data(millis(), 0, 0, 0, 0, 0, 0);
}
void loop() {
// put your main code here, to run repeatedly:
const float RADIANS_TO_DEGREES = 57.2958; //180/3.14159
startLoop = micros();
mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
// Get time of last raw data read
unsigned long t_now = millis();
// Remove offsets and scale gyro data
float gyro_x = (gx - base_x_gyro)/GYRO_FACTOR;
float gyro_y = (gy - base_y_gyro)/GYRO_FACTOR;
float gyro_z = (gz - base_z_gyro)/GYRO_FACTOR;
float accel_x = ax; // - base_x_accel;
float accel_y = ay; // - base_y_accel;
float accel_z = az; // - base_z_accel;
float accel_angle_y = atan(-1*accel_x/sqrt(pow(accel_y,2) + pow(accel_z,2)))*RADIANS_TO_DEGREES;
float accel_angle_x = atan(accel_y/sqrt(pow(accel_x,2) + pow(accel_z,2)))*RADIANS_TO_DEGREES;
float accel_angle_z = 0;
// Compute the (filtered) gyro angles
float dt =(t_now - get_last_time())/1000.0;
float gyro_angle_x = gyro_x*dt + get_last_x_angle();
float gyro_angle_y = gyro_y*dt + get_last_y_angle();
float gyro_angle_z = gyro_z*dt + get_last_z_angle();
// Compute the drifting gyro angles
float unfiltered_gyro_angle_x = gyro_x*dt + get_last_gyro_x_angle();
float unfiltered_gyro_angle_y = gyro_y*dt + get_last_gyro_y_angle();
float unfiltered_gyro_angle_z = gyro_z*dt + get_last_gyro_z_angle();
// Apply the complementary filter to figure out the change in angle - choice of alpha is
// estimated now. Alpha depends on the sampling rate...
const float alpha = 0.96;
float angle_x = alpha*gyro_angle_x + (1.0 - alpha)*accel_angle_x;
float angle_y = alpha*gyro_angle_y + (1.0 - alpha)*accel_angle_y;
float angle_z = gyro_angle_z; //Accelerometer doesn't give z-angle
// Update the saved data with the latest values
set_last_read_angle_data(t_now, angle_x, angle_y, angle_z, unfiltered_gyro_angle_x, unfiltered_gyro_angle_y, unfiltered_gyro_angle_z);
//Serial.print("CMP:");
Serial.print(get_last_x_angle(), 2);
Serial.print(" ");
Serial.print(get_last_y_angle(), 2);
Serial.print(" ");
Serial.println(-get_last_z_angle(), 2);
// Serial.print("\t");
// Serial.println(freq);
blinkState = !blinkState;
digitalWrite(LED_PIN, blinkState);
}
|
[
"taihengw@gmail.com"
] |
taihengw@gmail.com
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.