Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
E
EMAM2Cpp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
12
Issues
12
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
1
Merge Requests
1
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
monticore
EmbeddedMontiArc
generators
EMAM2Cpp
Commits
2123b848
Commit
2123b848
authored
Feb 12, 2020
by
Ahmed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
define types
parent
640ba3f0
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
103 additions
and
67 deletions
+103
-67
src/main/java/de/monticore/lang/monticar/generator/BluePrint.java
.../java/de/monticore/lang/monticar/generator/BluePrint.java
+4
-0
src/main/java/de/monticore/lang/monticar/generator/cpp/commands/BoundingRectCommand.java
.../monticar/generator/cpp/commands/BoundingRectCommand.java
+8
-1
src/main/java/de/monticore/lang/monticar/generator/cpp/commands/LargestContourCommand.java
...onticar/generator/cpp/commands/LargestContourCommand.java
+5
-2
src/main/java/de/monticore/lang/monticar/generator/cpp/commands/RectangleCommand.java
...ang/monticar/generator/cpp/commands/RectangleCommand.java
+6
-1
src/main/java/de/monticore/lang/monticar/generator/cpp/converter/ComponentConverter.java
.../monticar/generator/cpp/converter/ComponentConverter.java
+34
-7
src/main/java/de/monticore/lang/monticar/generator/cpp/converter/ComponentConverterMethodGeneration.java
...tor/cpp/converter/ComponentConverterMethodGeneration.java
+12
-6
src/test/java/de/monticore/lang/monticar/generator/cpp/armadillo/ArmadilloFunctionTest.java
...nticar/generator/cpp/armadillo/ArmadilloFunctionTest.java
+2
-2
src/test/resources/results/armadillo/testMath/l0/test_math_boundingRectCommandTest.h
...armadillo/testMath/l0/test_math_boundingRectCommandTest.h
+1
-1
src/test/resources/results/armadillo/testMath/l0/test_math_erodeAndGaussianBlurCommandTest.h
...o/testMath/l0/test_math_erodeAndGaussianBlurCommandTest.h
+14
-19
src/test/resources/results/armadillo/testMath/l0/test_math_findContoursCommandTest.h
...armadillo/testMath/l0/test_math_findContoursCommandTest.h
+2
-5
src/test/resources/results/armadillo/testMath/l0/test_math_largestContourCommandTest.h
...madillo/testMath/l0/test_math_largestContourCommandTest.h
+2
-2
src/test/resources/results/armadillo/testMath/l0/test_math_rectangleCommandTest.h
...ts/armadillo/testMath/l0/test_math_rectangleCommandTest.h
+1
-1
src/test/resources/test/math/ErodeAndGaussianBlurCommandTest.emam
.../resources/test/math/ErodeAndGaussianBlurCommandTest.emam
+10
-17
src/test/resources/test/math/FindContoursCommandTest.emam
src/test/resources/test/math/FindContoursCommandTest.emam
+2
-3
No files found.
src/main/java/de/monticore/lang/monticar/generator/BluePrint.java
View file @
2123b848
...
@@ -5,6 +5,7 @@ import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instance
...
@@ -5,6 +5,7 @@ import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instance
import
de.monticore.lang.monticar.generator.optimization.MathInformationRegister
;
import
de.monticore.lang.monticar.generator.optimization.MathInformationRegister
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Optional
;
...
@@ -67,6 +68,9 @@ public class BluePrint {
...
@@ -67,6 +68,9 @@ public class BluePrint {
variables
.
remove
(
v
);
variables
.
remove
(
v
);
}
}
public
void
replaceVariable
(
Variable
varOld
,
Variable
varNew
){
Collections
.
replaceAll
(
variables
,
varOld
,
varNew
);
}
public
void
addMethod
(
Method
method
)
{
public
void
addMethod
(
Method
method
)
{
methods
.
add
(
method
);
methods
.
add
(
method
);
}
}
...
...
src/main/java/de/monticore/lang/monticar/generator/cpp/commands/BoundingRectCommand.java
View file @
2123b848
...
@@ -7,6 +7,7 @@ import de.monticore.lang.monticar.generator.BluePrint;
...
@@ -7,6 +7,7 @@ import de.monticore.lang.monticar.generator.BluePrint;
import
de.monticore.lang.monticar.generator.MathCommand
;
import
de.monticore.lang.monticar.generator.MathCommand
;
import
de.monticore.lang.monticar.generator.cpp.BluePrintCPP
;
import
de.monticore.lang.monticar.generator.cpp.BluePrintCPP
;
import
de.monticore.lang.monticar.generator.cpp.MathFunctionFixer
;
import
de.monticore.lang.monticar.generator.cpp.MathFunctionFixer
;
import
de.monticore.lang.monticar.generator.cpp.converter.ComponentConverter
;
import
de.monticore.lang.monticar.generator.cpp.converter.ExecuteMethodGenerator
;
import
de.monticore.lang.monticar.generator.cpp.converter.ExecuteMethodGenerator
;
import
de.monticore.lang.monticar.generator.cpp.converter.MathConverter
;
import
de.monticore.lang.monticar.generator.cpp.converter.MathConverter
;
import
de.monticore.lang.monticar.generator.cpp.symbols.MathStringExpression
;
import
de.monticore.lang.monticar.generator.cpp.symbols.MathStringExpression
;
...
@@ -46,10 +47,16 @@ public class BoundingRectCommand extends MathCommand{
...
@@ -46,10 +47,16 @@ public class BoundingRectCommand extends MathCommand{
public
void
convertUsingArmadilloBackend
(
MathExpressionSymbol
mathExpressionSymbol
,
BluePrint
bluePrint
)
{
public
void
convertUsingArmadilloBackend
(
MathExpressionSymbol
mathExpressionSymbol
,
BluePrint
bluePrint
)
{
MathMatrixNameExpressionSymbol
mathMatrixNameExpressionSymbol
=
(
MathMatrixNameExpressionSymbol
)
mathExpressionSymbol
;
MathMatrixNameExpressionSymbol
mathMatrixNameExpressionSymbol
=
(
MathMatrixNameExpressionSymbol
)
mathExpressionSymbol
;
mathMatrixNameExpressionSymbol
.
setNameToAccess
(
""
);
mathMatrixNameExpressionSymbol
.
setNameToAccess
(
""
);
BluePrintCPP
bluePrintCPP
=
(
BluePrintCPP
)
bluePrint
;
String
valueListString
=
""
;
String
valueListString
=
""
;
for
(
MathMatrixAccessSymbol
accessSymbol
:
mathMatrixNameExpressionSymbol
.
getMathMatrixAccessOperatorSymbol
().
getMathMatrixAccessSymbols
())
for
(
MathMatrixAccessSymbol
accessSymbol
:
mathMatrixNameExpressionSymbol
.
getMathMatrixAccessOperatorSymbol
().
getMathMatrixAccessSymbols
())
MathFunctionFixer
.
fixMathFunctions
(
accessSymbol
,
(
BluePrintCPP
)
bluePrint
);
MathFunctionFixer
.
fixMathFunctions
(
accessSymbol
,
bluePrintCPP
);
String
nameOfFirstParameter
=
mathMatrixNameExpressionSymbol
.
getMathMatrixAccessOperatorSymbol
().
getMathMatrixAccessSymbols
().
get
(
0
).
getTextualRepresentation
();
ComponentConverter
.
fixVariableType
(
nameOfFirstParameter
,
bluePrintCPP
,
"Q"
,
"vector<cv::Point>"
,
""
);
valueListString
+=
ExecuteMethodGenerator
.
generateExecuteCode
(
mathExpressionSymbol
,
new
ArrayList
<
String
>());
valueListString
+=
ExecuteMethodGenerator
.
generateExecuteCode
(
mathExpressionSymbol
,
new
ArrayList
<
String
>());
List
<
MathMatrixAccessSymbol
>
newMatrixAccessSymbols
=
new
ArrayList
<>();
List
<
MathMatrixAccessSymbol
>
newMatrixAccessSymbols
=
new
ArrayList
<>();
MathStringExpression
stringExpression
=
new
MathStringExpression
(
"boundingRect"
+
valueListString
,
mathMatrixNameExpressionSymbol
.
getMathMatrixAccessOperatorSymbol
().
getMathMatrixAccessSymbols
());
MathStringExpression
stringExpression
=
new
MathStringExpression
(
"boundingRect"
+
valueListString
,
mathMatrixNameExpressionSymbol
.
getMathMatrixAccessOperatorSymbol
().
getMathMatrixAccessSymbols
());
...
...
src/main/java/de/monticore/lang/monticar/generator/cpp/commands/LargestContourCommand.java
View file @
2123b848
...
@@ -10,6 +10,7 @@ import de.monticore.lang.monticar.generator.cpp.converter.ExecuteMethodGenerator
...
@@ -10,6 +10,7 @@ import de.monticore.lang.monticar.generator.cpp.converter.ExecuteMethodGenerator
import
de.monticore.lang.monticar.generator.cpp.converter.MathConverter
;
import
de.monticore.lang.monticar.generator.cpp.converter.MathConverter
;
import
de.monticore.lang.monticar.generator.cpp.symbols.MathStringExpression
;
import
de.monticore.lang.monticar.generator.cpp.symbols.MathStringExpression
;
import
de.se_rwth.commons.logging.Log
;
import
de.se_rwth.commons.logging.Log
;
import
de.monticore.lang.monticar.generator.cpp.converter.ComponentConverter
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -45,11 +46,13 @@ public class LargestContourCommand extends MathCommand {
...
@@ -45,11 +46,13 @@ public class LargestContourCommand extends MathCommand {
public
void
convertUsingArmadilloBackend
(
MathExpressionSymbol
mathExpressionSymbol
,
BluePrint
bluePrint
)
{
public
void
convertUsingArmadilloBackend
(
MathExpressionSymbol
mathExpressionSymbol
,
BluePrint
bluePrint
)
{
MathMatrixNameExpressionSymbol
mathMatrixNameExpressionSymbol
=
(
MathMatrixNameExpressionSymbol
)
mathExpressionSymbol
;
MathMatrixNameExpressionSymbol
mathMatrixNameExpressionSymbol
=
(
MathMatrixNameExpressionSymbol
)
mathExpressionSymbol
;
mathMatrixNameExpressionSymbol
.
setNameToAccess
(
""
);
mathMatrixNameExpressionSymbol
.
setNameToAccess
(
""
);
BluePrintCPP
bluePrintCPP
=
(
BluePrintCPP
)
bluePrint
;
String
valueListString
=
""
;
String
valueListString
=
""
;
for
(
MathMatrixAccessSymbol
accessSymbol
:
mathMatrixNameExpressionSymbol
.
getMathMatrixAccessOperatorSymbol
().
getMathMatrixAccessSymbols
())
for
(
MathMatrixAccessSymbol
accessSymbol
:
mathMatrixNameExpressionSymbol
.
getMathMatrixAccessOperatorSymbol
().
getMathMatrixAccessSymbols
())
MathFunctionFixer
.
fixMathFunctions
(
accessSymbol
,
(
BluePrintCPP
)
bluePrint
);
MathFunctionFixer
.
fixMathFunctions
(
accessSymbol
,
bluePrintCPP
);
String
nameOfFirstParameter
=
mathMatrixNameExpressionSymbol
.
getMathMatrixAccessOperatorSymbol
().
getMathMatrixAccessSymbols
().
get
(
0
).
getTextualRepresentation
();
ComponentConverter
.
fixVariableType
(
nameOfFirstParameter
,
bluePrintCPP
,
"Q"
,
"vector<vector<cv::Point>>"
,
""
);
Method
largestContourMethod
=
getLargestContourMethod
();
Method
largestContourMethod
=
getLargestContourMethod
();
valueListString
+=
ExecuteMethodGenerator
.
generateExecuteCode
(
mathExpressionSymbol
,
new
ArrayList
<
String
>());
valueListString
+=
ExecuteMethodGenerator
.
generateExecuteCode
(
mathExpressionSymbol
,
new
ArrayList
<
String
>());
List
<
MathMatrixAccessSymbol
>
newMatrixAccessSymbols
=
new
ArrayList
<>();
List
<
MathMatrixAccessSymbol
>
newMatrixAccessSymbols
=
new
ArrayList
<>();
...
...
src/main/java/de/monticore/lang/monticar/generator/cpp/commands/RectangleCommand.java
View file @
2123b848
...
@@ -6,6 +6,7 @@ import de.monticore.lang.math._symboltable.matrix.MathMatrixNameExpressionSymbol
...
@@ -6,6 +6,7 @@ import de.monticore.lang.math._symboltable.matrix.MathMatrixNameExpressionSymbol
import
de.monticore.lang.monticar.generator.*
;
import
de.monticore.lang.monticar.generator.*
;
import
de.monticore.lang.monticar.generator.cpp.BluePrintCPP
;
import
de.monticore.lang.monticar.generator.cpp.BluePrintCPP
;
import
de.monticore.lang.monticar.generator.cpp.MathFunctionFixer
;
import
de.monticore.lang.monticar.generator.cpp.MathFunctionFixer
;
import
de.monticore.lang.monticar.generator.cpp.converter.ComponentConverter
;
import
de.monticore.lang.monticar.generator.cpp.converter.ExecuteMethodGenerator
;
import
de.monticore.lang.monticar.generator.cpp.converter.ExecuteMethodGenerator
;
import
de.monticore.lang.monticar.generator.cpp.converter.MathConverter
;
import
de.monticore.lang.monticar.generator.cpp.converter.MathConverter
;
import
de.monticore.lang.monticar.generator.cpp.symbols.MathStringExpression
;
import
de.monticore.lang.monticar.generator.cpp.symbols.MathStringExpression
;
...
@@ -45,10 +46,14 @@ public class RectangleCommand extends MathCommand{
...
@@ -45,10 +46,14 @@ public class RectangleCommand extends MathCommand{
public
void
convertUsingArmadilloBackend
(
MathExpressionSymbol
mathExpressionSymbol
,
BluePrint
bluePrint
)
{
public
void
convertUsingArmadilloBackend
(
MathExpressionSymbol
mathExpressionSymbol
,
BluePrint
bluePrint
)
{
MathMatrixNameExpressionSymbol
mathMatrixNameExpressionSymbol
=
(
MathMatrixNameExpressionSymbol
)
mathExpressionSymbol
;
MathMatrixNameExpressionSymbol
mathMatrixNameExpressionSymbol
=
(
MathMatrixNameExpressionSymbol
)
mathExpressionSymbol
;
mathMatrixNameExpressionSymbol
.
setNameToAccess
(
""
);
mathMatrixNameExpressionSymbol
.
setNameToAccess
(
""
);
BluePrintCPP
bluePrintCPP
=
(
BluePrintCPP
)
bluePrint
;
String
valueListString
=
""
;
String
valueListString
=
""
;
for
(
MathMatrixAccessSymbol
accessSymbol
:
mathMatrixNameExpressionSymbol
.
getMathMatrixAccessOperatorSymbol
().
getMathMatrixAccessSymbols
())
for
(
MathMatrixAccessSymbol
accessSymbol
:
mathMatrixNameExpressionSymbol
.
getMathMatrixAccessOperatorSymbol
().
getMathMatrixAccessSymbols
())
MathFunctionFixer
.
fixMathFunctions
(
accessSymbol
,
(
BluePrintCPP
)
bluePrint
);
MathFunctionFixer
.
fixMathFunctions
(
accessSymbol
,
bluePrintCPP
);
String
nameOfSecondParameter
=
mathMatrixNameExpressionSymbol
.
getMathMatrixAccessOperatorSymbol
().
getMathMatrixAccessSymbols
().
get
(
1
).
getTextualRepresentation
();
ComponentConverter
.
fixVariableType
(
nameOfSecondParameter
,
bluePrintCPP
,
"Q"
,
"Rect"
,
""
);
Method
rectangleHelperMethod
=
getRectangleHelperMethod
();
Method
rectangleHelperMethod
=
getRectangleHelperMethod
();
valueListString
+=
ExecuteMethodGenerator
.
generateExecuteCode
(
mathExpressionSymbol
,
new
ArrayList
<
String
>());
valueListString
+=
ExecuteMethodGenerator
.
generateExecuteCode
(
mathExpressionSymbol
,
new
ArrayList
<
String
>());
...
...
src/main/java/de/monticore/lang/monticar/generator/cpp/converter/ComponentConverter.java
View file @
2123b848
...
@@ -69,17 +69,17 @@ public class ComponentConverter {
...
@@ -69,17 +69,17 @@ public class ComponentConverter {
if
(
mathStatementsSymbol
!=
null
)
{
if
(
mathStatementsSymbol
!=
null
)
{
List
<
MathExpressionSymbol
>
mathExpressionSymbols
=
mathStatementsSymbol
.
getMathExpressionSymbols
();
List
<
MathExpressionSymbol
>
mathExpressionSymbols
=
mathStatementsSymbol
.
getMathExpressionSymbols
();
for
(
MathExpressionSymbol
mathExpressionSymbol
:
mathExpressionSymbols
){
for
(
MathExpressionSymbol
mathExpressionSymbol
:
mathExpressionSymbols
){
namesOfFunctions
.
add
(
getNameOfMathCommand
(
mathExpressionSymbol
));
String
nameOfFunction
=
getNameOfMathCommand
(
mathExpressionSymbol
);
namesOfFunctions
.
add
(
nameOfFunction
);
fixFunctionTypes
(
nameOfFunction
,
mathExpressionSymbol
,
bluePrint
);
}
}
}
}
if
(
namesOfFunctions
!=
null
)
{
if
(
namesOfFunctions
!=
null
)
{
for
(
String
nameOfFunction
:
namesOfFunctions
){
for
(
String
nameOfFunction
:
namesOfFunctions
){
usedMathCommand
.
add
(
bluePrint
.
getMathCommandRegister
().
getMathCommand
(
nameOfFunction
));
usedMathCommand
.
add
(
bluePrint
.
getMathCommandRegister
().
getMathCommand
(
nameOfFunction
));
}
}
}
}
if
(
mathStatementsSymbol
!=
null
){
if
(
mathStatementsSymbol
!=
null
){
//handleDependenceOfCVCommands(mathStatementsSymbol, BluePrintCPP bluePrint);
//handleDependenceOfCVCommands(mathStatementsSymbol, BluePrintCPP bluePrint);
}
}
...
@@ -314,7 +314,7 @@ public class ComponentConverter {
...
@@ -314,7 +314,7 @@ public class ComponentConverter {
initLine
.
ifPresent
(
s
->
method
.
addInstruction
(
new
TargetCodeInstruction
(
s
)));
initLine
.
ifPresent
(
s
->
method
.
addInstruction
(
new
TargetCodeInstruction
(
s
)));
}
}
}
}
//TODO: Try to modify this Method
public
static
void
handleDependenceOfCVCommands
(
MathStatementsSymbol
mathStatementsSymbol
,
BluePrintCPP
bluePrint
)
{
public
static
void
handleDependenceOfCVCommands
(
MathStatementsSymbol
mathStatementsSymbol
,
BluePrintCPP
bluePrint
)
{
List
<
MathExpressionSymbol
>
mathExpressionSymbols
=
mathStatementsSymbol
.
getMathExpressionSymbols
();
List
<
MathExpressionSymbol
>
mathExpressionSymbols
=
mathStatementsSymbol
.
getMathExpressionSymbols
();
int
mathExpressionSymbolsSize
=
mathExpressionSymbols
.
size
();
int
mathExpressionSymbolsSize
=
mathExpressionSymbols
.
size
();
...
@@ -332,9 +332,6 @@ public class ComponentConverter {
...
@@ -332,9 +332,6 @@ public class ComponentConverter {
}
}
}
}
}
}
}
}
}
}
}
}
...
@@ -395,4 +392,34 @@ public class ComponentConverter {
...
@@ -395,4 +392,34 @@ public class ComponentConverter {
public
static
void
fixMathFunctions
(
MathExpressionSymbol
mathExpressionSymbol
,
BluePrintCPP
bluePrintCPP
)
{
public
static
void
fixMathFunctions
(
MathExpressionSymbol
mathExpressionSymbol
,
BluePrintCPP
bluePrintCPP
)
{
MathFunctionFixer
.
fixMathFunctions
(
mathExpressionSymbol
,
bluePrintCPP
);
MathFunctionFixer
.
fixMathFunctions
(
mathExpressionSymbol
,
bluePrintCPP
);
}
}
private
static
void
fixFunctionTypes
(
String
nameOfFunction
,
MathExpressionSymbol
mathExpressionSymbol
,
BluePrintCPP
bluePrintCPP
)
{
String
outputName
=
getNameOfOutput
(
mathExpressionSymbol
);
switch
(
nameOfFunction
)
{
case
"findContours"
:
fixVariableType
(
outputName
,
bluePrintCPP
,
"Q"
,
"vector<vector<cv::Point>>"
,
""
);
break
;
case
"largestContour"
:
fixVariableType
(
outputName
,
bluePrintCPP
,
"Q"
,
"vector<cv::Point>"
,
""
);
break
;
case
"boundingRect"
:
fixVariableType
(
outputName
,
bluePrintCPP
,
"Q"
,
"Rect"
,
""
);
break
;
}
}
public
static
void
fixVariableType
(
String
variableName
,
BluePrintCPP
bluePrint
,
String
typeNameMontiCar
,
String
typeNameTargetLanguage
,
String
includeName
){
List
<
Variable
>
variables
=
bluePrint
.
getVariables
();
for
(
Variable
var
:
variables
){
if
(
var
.
getName
().
equals
(
variableName
)){
fixType
(
var
,
typeNameMontiCar
,
typeNameTargetLanguage
,
includeName
);
}
}
}
private
static
void
fixType
(
Variable
variable
,
String
typeNameMontiCar
,
String
typeNameTargetLanguage
,
String
includeName
){
VariableType
varTypeNew
=
new
VariableType
(
typeNameMontiCar
,
typeNameTargetLanguage
,
includeName
);
variable
.
setVariableType
(
varTypeNew
);
}
}
}
src/main/java/de/monticore/lang/monticar/generator/cpp/converter/ComponentConverterMethodGeneration.java
View file @
2123b848
...
@@ -23,6 +23,7 @@ import java.util.Collection;
...
@@ -23,6 +23,7 @@ import java.util.Collection;
import
java.util.List
;
import
java.util.List
;
import
static
de
.
monticore
.
lang
.
monticar
.
generator
.
cpp
.
converter
.
ComponentConverter
.
getNameOfOutput
;
import
static
de
.
monticore
.
lang
.
monticar
.
generator
.
cpp
.
converter
.
ComponentConverter
.
getNameOfOutput
;
import
static
de
.
monticore
.
lang
.
monticar
.
generator
.
cpp
.
converter
.
ComponentConverter
.
getNameOfMathCommand
;
/**
/**
*/
*/
...
@@ -195,13 +196,16 @@ public class ComponentConverterMethodGeneration {
...
@@ -195,13 +196,16 @@ public class ComponentConverterMethodGeneration {
MathFunctionFixer
.
fixMathFunctions
(
mathExpressionSymbol
,
bluePrint
);
MathFunctionFixer
.
fixMathFunctions
(
mathExpressionSymbol
,
bluePrint
);
String
result
=
ExecuteMethodGenerator
.
generateExecuteCode
(
mathExpressionSymbol
,
includeStrings
);
String
result
=
ExecuteMethodGenerator
.
generateExecuteCode
(
mathExpressionSymbol
,
includeStrings
);
String
outputName
=
""
;
String
outputName
=
""
;
for
(
MathCommand
mathCommand
:
ComponentConverter
.
usedMathCommand
)
for
(
MathCommand
mathCommand
:
ComponentConverter
.
usedMathCommand
)
{
if
(
mathCommand
!=
null
)
{
if
(
mathCommand
!=
null
)
{
String
argumentNoReturnFunctionName
=
mathCommand
.
getMathCommandName
();
String
argumentNoReturnFunctionName
=
mathCommand
.
getMathCommandName
();
if
(
mathCommand
.
isArgumentNoReturnMathCommand
()
&&
result
.
contains
(
argumentNoReturnFunctionName
))
{
if
(
mathCommand
.
isArgumentNoReturnMathCommand
()
&&
result
.
contains
(
argumentNoReturnFunctionName
))
{
outputName
=
getNameOfOutput
(
mathExpressionSymbol
);
outputName
=
getNameOfOutput
(
mathExpressionSymbol
);
result
=
fixArgumentNoReturnInstruction
(
result
,
outputName
);
result
=
fixArgumentNoReturnInstruction
(
result
,
outputName
);
//TODO Add fixType Here ---> think about put the function here or down
}
}
}
//fixVariableTypes(mathCommand, result,mathExpressionSymbol, bluePrint);
}
}
TargetCodeMathInstruction
instruction
=
new
TargetCodeMathInstruction
(
result
,
mathExpressionSymbol
);
TargetCodeMathInstruction
instruction
=
new
TargetCodeMathInstruction
(
result
,
mathExpressionSymbol
);
Log
.
info
(
mathExpressionSymbol
.
getClass
().
getName
()
+
" "
+
mathExpressionSymbol
.
getTextualRepresentation
(),
"GenerateSymbol:"
);
Log
.
info
(
mathExpressionSymbol
.
getClass
().
getName
()
+
" "
+
mathExpressionSymbol
.
getTextualRepresentation
(),
"GenerateSymbol:"
);
...
@@ -378,4 +382,6 @@ public class ComponentConverterMethodGeneration {
...
@@ -378,4 +382,6 @@ public class ComponentConverterMethodGeneration {
}
}
}
}
src/test/java/de/monticore/lang/monticar/generator/cpp/armadillo/ArmadilloFunctionTest.java
View file @
2123b848
...
@@ -284,9 +284,9 @@ public class ArmadilloFunctionTest extends AbstractSymtabTest {
...
@@ -284,9 +284,9 @@ public class ArmadilloFunctionTest extends AbstractSymtabTest {
public
void
testRectangleCommand
()
throws
IOException
{
public
void
testRectangleCommand
()
throws
IOException
{
testMathCommand
(
"rectangle"
);
testMathCommand
(
"rectangle"
);
}
}
/*
@Test
//only for testing
@Test
//only for testing
public
void
testErodeAndGaussianBlur
()
throws
IOException
{
public
void
testErodeAndGaussianBlur
()
throws
IOException
{
testMathCommand
(
"erodeAndGaussianBlur"
);
testMathCommand
(
"erodeAndGaussianBlur"
);
}
*/
}
}
}
src/test/resources/results/armadillo/testMath/l0/test_math_boundingRectCommandTest.h
View file @
2123b848
...
@@ -9,7 +9,7 @@ using namespace arma;
...
@@ -9,7 +9,7 @@ using namespace arma;
using
namespace
cv
;
using
namespace
cv
;
class
test_math_boundingRectCommandTest
{
class
test_math_boundingRectCommandTest
{
public:
public:
double
contour
;
vector
<
cv
::
Point
>
contour
;
double
rect
;
double
rect
;
void
init
()
void
init
()
{
{
...
...
src/test/resources/results/armadillo/testMath/l0/test_math_erodeAndGaussianBlurCommandTest.h
View file @
2123b848
...
@@ -5,25 +5,27 @@
...
@@ -5,25 +5,27 @@
#endif
#endif
#include "armadillo"
#include "armadillo"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgproc.hpp"
#include <vector>
#include "opencv2/imgproc.hpp"
#include "opencv2/imgproc.hpp"
using
namespace
arma
;
using
namespace
arma
;
using
namespace
cv
;
using
namespace
cv
;
class
test_math_erodeAndGaussianBlurCommandTest
{
class
test_math_erodeAndGaussianBlurCommandTest
{
public:
public:
mat
src
;
cube
src
;
int
erosion_elem
;
int
erosion_elemIn
;
int
iterations
;
colvec
sizeY
;
int
sizeX
;
colvec
two
;
int
sizeY
;
cube
outMatrix
;
double
sigmaX
;
mat
out2Matrix
;
double
sigmaY
;
mat
dstB
;
void
init
()
void
init
()
{
{
src
=
mat
(
n
,
m
);
src
=
cube
(
3
,
n
,
m
);
dstB
=
mat
(
n
,
m
);
sizeY
=
colvec
(
3
);
two
=
colvec
(
2
);
outMatrix
=
cube
(
3
,
n
,
m
);
out2Matrix
=
mat
(
2
,
m
);
}
}
void
erodeHelper
(
mat
src
,
mat
dst
,
int
erosion_elem
,
int
iterations
)
void
erodeHelper
(
cube
src
,
cube
dst
,
int
erosion_elem
,
int
iterations
)
{
{
int
erosion_type
=
0
;
int
erosion_type
=
0
;
if
(
erosion_elem
==
0
){
erosion_type
=
MORPH_RECT
;
}
if
(
erosion_elem
==
0
){
erosion_type
=
MORPH_RECT
;
}
...
@@ -35,17 +37,10 @@ void erodeHelper(mat src, mat dst, int erosion_elem, int iterations)
...
@@ -35,17 +37,10 @@ void erodeHelper(mat src, mat dst, int erosion_elem, int iterations)
Point
(
-
1
,
-
1
)
);
Point
(
-
1
,
-
1
)
);
erode
(
src
,
dst
,
element
,
Point
(
-
1
,
-
1
),
iterations
);
erode
(
src
,
dst
,
element
,
Point
(
-
1
,
-
1
),
iterations
);
}
}
void
gaussianBlurHelper
(
mat
src
,
mat
dst
,
int
sizeX
,
int
sizeY
,
double
sigmaX
,
double
sigmaY
)
{
gaussianBlur
(
src
,
dst
,
Size
(
sizeX
,
sizeY
),
sigmaX
,
sigmaY
);
}
void
execute
()
void
execute
()
{
{
mat
dst
=
mat
(
n
,
m
);
findContours
(
image
,
contours
,
mode
,
method
);
erodeHelper
(
src
,
dst
,
erosion_elem
,
iterations
);
erodeHelper
(
src
,
dst
,
erosion_elem
,
iterations
);
mat
deterMat
=
(
det
(
dst
));
mat
dstB
;
gaussianBlurHelper
(
dst
,
dstB
,
sizeX
,
sizeY
,
sigmaX
,
sigmaY
);
}
}
};
};
...
...
src/test/resources/results/armadillo/testMath/l0/test_math_findContoursCommandTest.h
View file @
2123b848
...
@@ -13,17 +13,14 @@ public:
...
@@ -13,17 +13,14 @@ public:
mat
image
;
mat
image
;
int
mode
;
int
mode
;
int
method
;
int
method
;
mat
hierarchy
;
vector
<
vector
<
cv
::
Point
>>
contours
;
mat
contours
;
void
init
()
void
init
()
{
{
image
=
mat
(
n
,
m
);
image
=
mat
(
n
,
m
);
hierarchy
=
mat
(
x
,
y
);
contours
=
mat
(
w
,
z
);
}
}
void
execute
()
void
execute
()
{
{
findContours
(
image
,
contours
,
hierarchy
,
mode
,
method
);
findContours
(
image
,
contours
,
mode
,
method
);
}
}
};
};
...
...
src/test/resources/results/armadillo/testMath/l0/test_math_largestContourCommandTest.h
View file @
2123b848
...
@@ -9,8 +9,8 @@ using namespace arma;
...
@@ -9,8 +9,8 @@ using namespace arma;
using
namespace
cv
;
using
namespace
cv
;
class
test_math_largestContourCommandTest
{
class
test_math_largestContourCommandTest
{
public:
public:
double
contours
;
vector
<
vector
<
cv
::
Point
>>
contours
;
double
lContour
;
vector
<
cv
::
Point
>
lContour
;
void
init
()
void
init
()
{
{
}
}
...
...
src/test/resources/results/armadillo/testMath/l0/test_math_rectangleCommandTest.h
View file @
2123b848
...
@@ -10,7 +10,7 @@ using namespace cv;
...
@@ -10,7 +10,7 @@ using namespace cv;
class
test_math_rectangleCommandTest
{
class
test_math_rectangleCommandTest
{
public:
public:
cube
src
;
cube
src
;
double
rect
;
Rect
rect
;
colvec
color
;
colvec
color
;
int
thickness
;
int
thickness
;
int
lineType
;
int
lineType
;
...
...
src/test/resources/test/math/ErodeAndGaussianBlurCommandTest.emam
View file @
2123b848
...
@@ -3,23 +3,16 @@ package test.math;
...
@@ -3,23 +3,16 @@ package test.math;
component
ErodeAndGaussianBlurCommandTest
{
component
ErodeAndGaussianBlurCommandTest
{
port
port
in
Q
^{
n
,
m
}
src
,
in
Q
^{
3
,
n
,
m
}
src
,
in
Z
erosion_elemIn
,
in
Z
erosion_elemIn
,
in
Z
iterationsIn1
,
in
Q
^{
3
}
sizeY
,
in
Z
sizeX
,
in
Q
^{
2
}
two
,
in
Z
sizeY
,
out
Q
^{
3
,
n
,
m
}
outMatrix
,
in
Q
sigmaX
,
out
Q
^{
2
,
m
}
out2Matrix
;
in
Q
sigmaY
,
out
Q
^{
n
,
m
}
dstB
;
instance
ErodeCommandTest
erode
;
implementation
Math
{
connect
erosion_elemIn
->
erode
.
erosion_elem
;
contours
=
findContours
(
image
,
mode
,
method
);
connect
iterationsIn1
->
erode
.
iterations
;
dst
=
erode
(
src
,
erosion_elem
,
iterations
);
//
connect
erode
.
dst
->
dilate
.
dst
;
//
implementation
Math
{
}
//
Q
^{
n
,
m
}
dst
;
//
dst
=
erode
(
src
,
erosion_elem
,
iterations
);
//
Q
^{
2
,
3
}
deterMat
=
det
(
dst
);
//
Q
^{
n
,
m
}
dstB
=
gaussianBlur
(
dst
,
sizeX
,
sizeY
,
sigmaX
,
sigmaY
);
//}
}
}
src/test/resources/test/math/FindContoursCommandTest.emam
View file @
2123b848
...
@@ -6,10 +6,9 @@ component FindContoursCommandTest{
...
@@ -6,10 +6,9 @@ component FindContoursCommandTest{
in
Q
^{
n
,
m
}
image
,
in
Q
^{
n
,
m
}
image
,
in
Z
mode
,
in
Z
mode
,
in
Z
method
,
in
Z
method
,
out
Q
^{
x
,
y
}
hierarchy
,
out
Q
contours
;
out
Q
^{
w
,
z
}
contours
;
implementation
Math
{
implementation
Math
{
contours
=
findContours
(
image
,
hierarchy
,
mode
,
method
);
contours
=
findContours
(
image
,
mode
,
method
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment